2014-09-25 16:50:45 +00:00
|
|
|
import requests
|
|
|
|
import pkg_resources
|
|
|
|
|
2017-12-24 13:25:20 +00:00
|
|
|
|
2014-09-25 16:50:45 +00:00
|
|
|
class Version:
|
|
|
|
PYPI_URL = "https://pypi.python.org/pypi/hackertray/json"
|
2017-12-24 13:25:20 +00:00
|
|
|
|
2014-09-25 16:50:45 +00:00
|
|
|
@staticmethod
|
|
|
|
def latest():
|
|
|
|
res = requests.get(Version.PYPI_URL).json()
|
|
|
|
return res['info']['version']
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def current():
|
|
|
|
return pkg_resources.require("hackertray")[0].version
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def new_available():
|
2017-12-24 13:25:20 +00:00
|
|
|
latest = Version.latest()
|
2014-09-25 16:50:45 +00:00
|
|
|
current = Version.current()
|
|
|
|
try:
|
|
|
|
if pkg_resources.parse_version(latest) > pkg_resources.parse_version(current):
|
2017-12-24 11:13:07 +00:00
|
|
|
print("[+] New version " + latest + " is available")
|
2014-09-25 16:50:45 +00:00
|
|
|
return True
|
|
|
|
else:
|
|
|
|
return False
|
|
|
|
except requests.exceptions.RequestException as e:
|
2017-12-24 11:13:07 +00:00
|
|
|
print("[+] There was an error in trying to fetch updates")
|
2017-12-24 13:25:20 +00:00
|
|
|
return False
|