From d735e6a3d35fb4ab28579a759bc9ce764eda10dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Thu, 17 Sep 2015 13:51:31 +0200 Subject: [PATCH] Add methods to query the version of MISP (master and local) --- pymisp/api.py | 21 +++++++++++++++++++++ setup.py | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/pymisp/api.py b/pymisp/api.py index 11a4fb8..dc457f4 100644 --- a/pymisp/api.py +++ b/pymisp/api.py @@ -595,6 +595,27 @@ class PyMISP(object): session = self.__prepare_session('rules') return session.get(template) + # ########## Version ########## + + def get_version(self): + """ + Returns the version of the instance. + """ + session = self.__prepare_session() + url = urljoin(self.root_url, 'servers/getVersion') + return session.get(url).json() + + def get_version_master(self): + """ + Get the most recent version from github + """ + r = requests.get('https://raw.githubusercontent.com/MISP/MISP/master/VERSION.json') + if r.status_code == 200: + master_version = json.loads(r.text) + return {'version': '{}.{}.{}'.format(master_version['major'], master_version['minor'], master_version['hotfix'])} + else: + return {'message': 'Impossible to retrieve the version of the master branch.'} + # ############## Deprecated (Pure XML API should not be used) ################## @deprecated diff --git a/setup.py b/setup.py index 42344d8..c7fc2e5 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ from setuptools import setup setup( name='pymisp', - version='1.9', + version='1.10', author='Raphaël Vinot', author_email='raphael.vinot@circl.lu', maintainer='Raphaël Vinot',