Merge "Remove CPickle"
This commit is contained in:
commit
38da3437ed
@ -21,9 +21,8 @@ from collections import defaultdict
|
|||||||
import copy
|
import copy
|
||||||
import hashlib
|
import hashlib
|
||||||
import itertools
|
import itertools
|
||||||
|
import pickle
|
||||||
import random
|
import random
|
||||||
import six
|
|
||||||
from six.moves import cPickle
|
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
import zlib
|
import zlib
|
||||||
@ -102,11 +101,8 @@ def md5(obj):
|
|||||||
if isinstance(obj, tuple):
|
if isinstance(obj, tuple):
|
||||||
obj = str([str(o) for o in obj])
|
obj = str([str(o) for o in obj])
|
||||||
|
|
||||||
if isinstance(obj, six.string_types):
|
if isinstance(obj, str):
|
||||||
if six.PY2:
|
return hashlib.md5(obj.encode('utf-8')).hexdigest()
|
||||||
return hashlib.md5(obj).hexdigest()
|
|
||||||
else:
|
|
||||||
return hashlib.md5(obj.encode('utf-8')).hexdigest()
|
|
||||||
raise Exception('Unknown object for md5 %s' % obj)
|
raise Exception('Unknown object for md5 %s' % obj)
|
||||||
|
|
||||||
|
|
||||||
@ -143,7 +139,7 @@ def timed_method(log_results=False, warn_above_sec=-1):
|
|||||||
|
|
||||||
|
|
||||||
def compress_obj(obj, level=9):
|
def compress_obj(obj, level=9):
|
||||||
str_data = cPickle.dumps(obj)
|
str_data = pickle.dumps(obj)
|
||||||
data = base64.b64encode(zlib.compress(str_data, level))
|
data = base64.b64encode(zlib.compress(str_data, level))
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@ -151,7 +147,7 @@ def compress_obj(obj, level=9):
|
|||||||
def decompress_obj(blob):
|
def decompress_obj(blob):
|
||||||
decoded_blob = base64.standard_b64decode(blob)
|
decoded_blob = base64.standard_b64decode(blob)
|
||||||
str_data = zlib.decompress(decoded_blob)
|
str_data = zlib.decompress(decoded_blob)
|
||||||
obj = cPickle.loads(str_data)
|
obj = pickle.loads(str_data)
|
||||||
del decoded_blob
|
del decoded_blob
|
||||||
del str_data
|
del str_data
|
||||||
return obj
|
return obj
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
import re
|
import re
|
||||||
import six
|
|
||||||
|
|
||||||
from vitrage.evaluator.template_validation.base import ValidationError
|
from vitrage.evaluator.template_validation.base import ValidationError
|
||||||
|
|
||||||
@ -41,7 +40,7 @@ def _recursive_resolve_function(func_info, template, template_block,
|
|||||||
resolve, **kwargs):
|
resolve, **kwargs):
|
||||||
|
|
||||||
for key, value in template_block.items():
|
for key, value in template_block.items():
|
||||||
if isinstance(value, six.string_types) and \
|
if isinstance(value, str) and \
|
||||||
_is_wanted_function(value, func_info.name):
|
_is_wanted_function(value, func_info.name):
|
||||||
|
|
||||||
if not func_info.func:
|
if not func_info.func:
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
import six
|
|
||||||
|
|
||||||
from vitrage.common.exception import VitrageAlgorithmError
|
from vitrage.common.exception import VitrageAlgorithmError
|
||||||
from vitrage.graph.filter import check_filter
|
from vitrage.graph.filter import check_filter
|
||||||
@ -170,7 +169,7 @@ def _generate_result(final_subgraphs):
|
|||||||
subgraph_vertices = dict()
|
subgraph_vertices = dict()
|
||||||
for v in mapping.get_vertices():
|
for v in mapping.get_vertices():
|
||||||
v_id = v[MAPPED_V_ID]
|
v_id = v[MAPPED_V_ID]
|
||||||
if isinstance(v_id, six.string_types) and v_id is not NEG_VERTEX:
|
if isinstance(v_id, str) and v_id is not NEG_VERTEX:
|
||||||
subgraph_vertices[v.vertex_id] = v[GRAPH_VERTEX]
|
subgraph_vertices[v.vertex_id] = v[GRAPH_VERTEX]
|
||||||
|
|
||||||
if subgraph_vertices not in result:
|
if subgraph_vertices not in result:
|
||||||
|
@ -18,7 +18,7 @@ import json
|
|||||||
import networkx as nx
|
import networkx as nx
|
||||||
from networkx.algorithms.operators.binary import compose
|
from networkx.algorithms.operators.binary import compose
|
||||||
from networkx.readwrite import json_graph
|
from networkx.readwrite import json_graph
|
||||||
from six.moves import cPickle
|
import pickle
|
||||||
|
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
|
|
||||||
@ -359,7 +359,7 @@ class NXGraph(Graph):
|
|||||||
return json.dumps(node_link_data)
|
return json.dumps(node_link_data)
|
||||||
|
|
||||||
def write_gpickle(self):
|
def write_gpickle(self):
|
||||||
return cPickle.dumps(self._g, cPickle.HIGHEST_PROTOCOL)
|
return pickle.dumps(self._g, pickle.HIGHEST_PROTOCOL)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def read_gpickle(data, graph_to_update=None):
|
def read_gpickle(data, graph_to_update=None):
|
||||||
@ -367,7 +367,7 @@ class NXGraph(Graph):
|
|||||||
graph = graph_to_update
|
graph = graph_to_update
|
||||||
else:
|
else:
|
||||||
graph = NXGraph()
|
graph = NXGraph()
|
||||||
graph._g = cPickle.loads(data)
|
graph._g = pickle.loads(data)
|
||||||
return graph
|
return graph
|
||||||
|
|
||||||
def union(self, other_graph):
|
def union(self, other_graph):
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
import six
|
|
||||||
|
|
||||||
from vitrage.common.exception import VitrageError
|
from vitrage.common.exception import VitrageError
|
||||||
|
|
||||||
@ -103,7 +102,7 @@ def _create_query_expression(query, parent_operator=None):
|
|||||||
|
|
||||||
def _evaluable_str(value):
|
def _evaluable_str(value):
|
||||||
"""wrap string/unicode with back tick"""
|
"""wrap string/unicode with back tick"""
|
||||||
if isinstance(value, six.string_types):
|
if isinstance(value, str):
|
||||||
return '\'' + value + '\''
|
return '\'' + value + '\''
|
||||||
else:
|
else:
|
||||||
return str(value)
|
return str(value)
|
||||||
|
Loading…
Reference in New Issue
Block a user