Fix checks of recommended version

pull/83/head
Lukas Bernhard 2017-05-03 14:47:06 +02:00
parent 0bee414592
commit 3e4e76c21e
1 changed files with 6 additions and 9 deletions

View File

@ -117,18 +117,15 @@ class PyMISP(object):
try: try:
# Make sure the MISP instance is working and the URL is valid # Make sure the MISP instance is working and the URL is valid
pymisp_version = __version__.split('.')
response = self.get_recommended_api_version() response = self.get_recommended_api_version()
if not response.get('version'): if not response.get('version'):
logger.warning("Unable to check the recommended PyMISP version (MISP <2.4.60), please upgrade.") logger.warning("Unable to check the recommended PyMISP version (MISP <2.4.60), please upgrade.")
else: else:
recommended_pymisp_version = response['version'].split('.') pymisp_version_tup = tuple(int(x) for x in __version__.split('.'))
for a, b in zip(pymisp_version, recommended_pymisp_version): recommended_version_tup = tuple(int(x) for x in response['version'].split('.'))
if a == b: if recommended_version_tup < pymisp_version_tup:
continue
elif a > b:
logger.warning("The version of PyMISP recommended by the MISP instance ({}) is older than the one you're using now ({}). Please upgrade the MISP instance or use an older PyMISP version.".format(response['version'], __version__)) logger.warning("The version of PyMISP recommended by the MISP instance ({}) is older than the one you're using now ({}). Please upgrade the MISP instance or use an older PyMISP version.".format(response['version'], __version__))
else: # a < b elif pymisp_version_tup < recommended_version_tup:
logger.warning("The version of PyMISP recommended by the MISP instance ({}) is newer than the one you're using now ({}). Please upgrade PyMISP.".format(response['version'], __version__)) logger.warning("The version of PyMISP recommended by the MISP instance ({}) is newer than the one you're using now ({}). Please upgrade PyMISP.".format(response['version'], __version__))
except Exception as e: except Exception as e: