new: Added base async imports

pull/80/head
Hannah Ward 2017-02-16 15:23:42 +00:00
parent 98a008e67a
commit bb00201aaf
No known key found for this signature in database
GPG Key ID: 6F3BAD60DE190290
1 changed files with 10 additions and 1 deletions

View File

@ -82,7 +82,7 @@ class PyMISP(object):
threat_level = threat_level threat_level = threat_level
analysis = analysis analysis = analysis
def __init__(self, url, key, ssl=True, out_type='json', debug=False, proxies=None, cert=None): def __init__(self, url, key, ssl=True, out_type='json', debug=False, proxies=None, cert=None, asynch=False):
if not url: if not url:
raise NoURL('Please provide the URL of your MISP instance.') raise NoURL('Please provide the URL of your MISP instance.')
if not key: if not key:
@ -93,6 +93,15 @@ class PyMISP(object):
self.ssl = ssl self.ssl = ssl
self.proxies = proxies self.proxies = proxies
self.cert = cert self.cert = cert
self.asynch = asynch
if self.asynch:
try:
from requests_futures.sessions import FuturesSession
except ImportError:
print("You set Async, but you haven't got requests_futures installed")
print("Reverting to synchronous")
self.asynch = False
self.ressources_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'data') self.ressources_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'data')
if out_type != 'json': if out_type != 'json':
raise PyMISPError('The only output type supported by PyMISP is JSON. If you still rely on XML, use PyMISP v2.4.49') raise PyMISPError('The only output type supported by PyMISP is JSON. If you still rely on XML, use PyMISP v2.4.49')