mirror of https://github.com/MISP/PyMISP
fix: jerry rig support for old python
parent
7e0d91af2b
commit
f4c0b92305
|
@ -36,6 +36,10 @@ try:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
HAVE_REQUESTS = False
|
HAVE_REQUESTS = False
|
||||||
|
|
||||||
|
if (3, 0) <= sys.version_info < (3, 6):
|
||||||
|
OLD_PY3 = True
|
||||||
|
else:
|
||||||
|
OLD_PY3 = False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from requests_futures.sessions import FuturesSession
|
from requests_futures.sessions import FuturesSession
|
||||||
|
@ -127,6 +131,9 @@ class PyMISP(object):
|
||||||
|
|
||||||
def get_local_describe_types(self):
|
def get_local_describe_types(self):
|
||||||
with open(os.path.join(self.resources_path, 'describeTypes.json'), 'rb') as f:
|
with open(os.path.join(self.resources_path, 'describeTypes.json'), 'rb') as f:
|
||||||
|
if OLD_PY3:
|
||||||
|
describe_types = json.loads(f.read().decode())
|
||||||
|
else:
|
||||||
describe_types = json.load(f)
|
describe_types = json.load(f)
|
||||||
return describe_types['result']
|
return describe_types['result']
|
||||||
|
|
||||||
|
|
|
@ -189,8 +189,6 @@ class ExpandedPyMISP(PyMISP):
|
||||||
me.load(e)
|
me.load(e)
|
||||||
to_return.append(me)
|
to_return.append(me)
|
||||||
elif controller == 'attributes':
|
elif controller == 'attributes':
|
||||||
# FIXME: if the query doesn't match, the request returns an empty list, and not a dictionary;
|
|
||||||
if normalized_response:
|
|
||||||
for a in normalized_response.get('Attribute'):
|
for a in normalized_response.get('Attribute'):
|
||||||
ma = MISPAttribute()
|
ma = MISPAttribute()
|
||||||
ma.from_dict(**a)
|
ma.from_dict(**a)
|
||||||
|
|
|
@ -1011,6 +1011,11 @@ class MISPObject(AbstractMISP):
|
||||||
else:
|
else:
|
||||||
self._known_template = False
|
self._known_template = False
|
||||||
|
|
||||||
|
if kwargs.get('timestamp'):
|
||||||
|
if sys.version_info >= (3, 3):
|
||||||
|
self.timestamp = datetime.datetime.fromtimestamp(int(kwargs.pop('timestamp')), datetime.timezone.utc)
|
||||||
|
else:
|
||||||
|
self.timestamp = datetime.datetime.fromtimestamp(int(kwargs.pop('timestamp')), UTC())
|
||||||
if kwargs.get('Attribute'):
|
if kwargs.get('Attribute'):
|
||||||
for a in kwargs.pop('Attribute'):
|
for a in kwargs.pop('Attribute'):
|
||||||
self.add_attribute(**a)
|
self.add_attribute(**a)
|
||||||
|
|
Loading…
Reference in New Issue