aboutsummaryrefslogtreecommitdiffstats
path: root/reaktor/commands/version
blob: d9c4c5d5dc866b422ac147cc3c2b98ff2d34f471 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env python

import reaktor
import requests

url = "https://pypi.python.org/pypi/Reaktor/json"

cur_version = reaktor.__version__

ret = requests.get(url).json()
latest_version = ret["info"]["version"]


def vt(v):
    return tuple(map(int, (v.split("."))))


try:
    rel = ret["releases"][cur_version][0]["upload_time"]
except Exception:
    rel = "unknown release date"
print("{} - {}".format(cur_version, rel))
if vt(latest_version) > vt(cur_version):
    print("   newer release available: {}".format(latest_version))
elif vt(latest_version) < vt(cur_version):
    print("   ahead of official release: {}".format(latest_version))
else:
    # on the most current release
    pass