ℹ️ HackerTray is a minimalist Hacker News app for Linux
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
hackertray/hackertray/version.py

29 lines
859 B

import requests
import pkg_resources
class Version:
PYPI_URL = "https://pypi.python.org/pypi/hackertray/json"
@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():
latest = Version.latest()
current = Version.current()
try:
if pkg_resources.parse_version(latest) > pkg_resources.parse_version(current):
print("[+] New version " + latest + " is available")
return True
else:
return False
except requests.exceptions.RequestException as e:
print("[+] There was an error in trying to fetch updates")
return False