Add version-related methods

pull/2/merge v1.10
Raphaël Vinot 2015-09-18 12:03:56 +02:00
parent d735e6a3d3
commit a7c3d8869c
3 changed files with 38 additions and 2 deletions

View File

@ -1 +1,3 @@
__version__ = '1.10'
from .api import PyMISP

View File

@ -5,9 +5,10 @@
import json
import datetime
import requests
import os
import base64
import re
try:
from urllib.parse import urljoin
except ImportError:
@ -17,6 +18,14 @@ import zipfile
import warnings
import functools
try:
import requests
HAVE_REQUESTS = True
except ImportError:
HAVE_REQUESTS = False
from . import __version__
# Least dirty way to support python 2 and 3
try:
basestring
@ -38,6 +47,10 @@ class NewAttributeError(PyMISPError):
pass
class MissingDependency(PyMISPError):
pass
def deprecated(func):
'''This is a decorator which can be used to mark functions
as deprecated. It will result in a warning being emitted
@ -92,6 +105,8 @@ class PyMISP(object):
(overwrite the constructor)
"""
if not HAVE_REQUESTS:
raise MissingDependency('Missing dependency, install requests (`pip install requests`)')
if force_out is not None:
out = force_out
else:
@ -597,6 +612,23 @@ class PyMISP(object):
# ########## Version ##########
def get_api_version(self):
"""
Returns the current version of PyMISP installed on the system
"""
return {'version': __version__}
def get_api_version_master(self):
"""
Get the most recent version of PyMISP from github
"""
r = requests.get('https://raw.githubusercontent.com/MISP/PyMISP/master/pymisp/__init__.py')
if r.status_code == 200:
version = re.findall("__version__ = '(.*)'", r.text)
return {'version': version[0]}
else:
return {'message': 'Impossible to retrieve the version of the master branch.'}
def get_version(self):
"""
Returns the version of the instance.

View File

@ -1,10 +1,12 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
from setuptools import setup
import pymisp
setup(
name='pymisp',
version='1.10',
version=pymisp.__version__,
author='Raphaël Vinot',
author_email='raphael.vinot@circl.lu',
maintainer='Raphaël Vinot',