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:
|
||||
HAVE_REQUESTS = False
|
||||
|
||||
if (3, 0) <= sys.version_info < (3, 6):
|
||||
OLD_PY3 = True
|
||||
else:
|
||||
OLD_PY3 = False
|
||||
|
||||
try:
|
||||
from requests_futures.sessions import FuturesSession
|
||||
|
@ -127,7 +131,10 @@ class PyMISP(object):
|
|||
|
||||
def get_local_describe_types(self):
|
||||
with open(os.path.join(self.resources_path, 'describeTypes.json'), 'rb') as f:
|
||||
describe_types = json.load(f)
|
||||
if OLD_PY3:
|
||||
describe_types = json.loads(f.read().decode())
|
||||
else:
|
||||
describe_types = json.load(f)
|
||||
return describe_types['result']
|
||||
|
||||
def get_live_describe_types(self):
|
||||
|
|
|
@ -189,12 +189,10 @@ class ExpandedPyMISP(PyMISP):
|
|||
me.load(e)
|
||||
to_return.append(me)
|
||||
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'):
|
||||
ma = MISPAttribute()
|
||||
ma.from_dict(**a)
|
||||
to_return.append(ma)
|
||||
for a in normalized_response.get('Attribute'):
|
||||
ma = MISPAttribute()
|
||||
ma.from_dict(**a)
|
||||
to_return.append(ma)
|
||||
elif controller == 'objects':
|
||||
raise Exception('Not implemented yet')
|
||||
return to_return
|
||||
|
|
|
@ -1011,6 +1011,11 @@ class MISPObject(AbstractMISP):
|
|||
else:
|
||||
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'):
|
||||
for a in kwargs.pop('Attribute'):
|
||||
self.add_attribute(**a)
|
||||
|
|
Loading…
Reference in New Issue