-
Notifications
You must be signed in to change notification settings - Fork 18
/
versions_util.py
87 lines (64 loc) · 2.15 KB
/
versions_util.py
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
import requests
__versions = None
def __get_major(v):
return int(v.split(".")[0])
def __getVersions():
"""Get the versions number for each channel
Returns:
dict: versions for each channel
"""
r = requests.get("https://product-details.mozilla.org/1.0/firefox_versions.json")
data = r.json()
nightly = data["FIREFOX_NIGHTLY"]
esr = data["FIREFOX_ESR_NEXT"]
if not esr:
esr = data["FIREFOX_ESR"]
if esr.endswith("esr"):
esr = esr[:-3]
return {
"release": data["LATEST_FIREFOX_VERSION"],
"beta": data["LATEST_FIREFOX_RELEASED_DEVEL_VERSION"],
"nightly": nightly,
"esr": esr,
}
def get(base=False):
"""Get current version number by channel
Returns:
dict: containing version by channel
"""
global __versions
if not __versions:
__versions = __getVersions()
if base:
res = {}
for k, v in __versions.items():
res[k] = __get_major(v)
return res
return __versions
def getStabilityReleases(base):
r = requests.get(
"https://product-details.mozilla.org/1.0/firefox_history_stability_releases.json"
)
data = r.json()
return [v for v in data.keys() if v.startswith(base + ".")]
def getDevelopmentReleases(base):
r = requests.get(
"https://product-details.mozilla.org/1.0/firefox_history_development_releases.json"
)
data = r.json()
return [v for v in data.keys() if v.startswith(base + ".")]
def get_channel_versions(channel, product="Firefox"):
channel = channel.lower()
version = str(get(base=True)[channel])
if channel == "nightly":
return ["{}.0a1".format(version)]
elif channel == "release":
return ["{}.0".format(version)] + getStabilityReleases(version)
elif channel == "beta":
return getDevelopmentReleases(version)
else:
assert False, "Unknown channel {}".format(channel)