forked from scp-fs2open/nightlybuild
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bintray.py
49 lines (33 loc) · 1.34 KB
/
bintray.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
import re
import requests
from files import ReleaseFile
from util import retry_multi, GLOBAL_TIMEOUT
def get_file_list(tag_name, config):
@retry_multi(5)
def execute_request(path):
headers = {
}
url = "https://bintray.com/api/v1" + path
response = requests.get(url, headers=headers, timeout=GLOBAL_TIMEOUT)
response.raise_for_status()
return response.json()
tag_regex = re.compile("nightly_(.*)")
build_group_regex = re.compile("nightly_.*-builds-([^.]*).*")
bintray_version = tag_regex.match(tag_name).group(1)
path = "/packages/{subject}/{repo}/{package}/versions/{version}/files".format(**{
"subject": config["bintray"]["subject"],
"repo": config["bintray"]["repo"],
"package": config["bintray"]["package"],
"version": bintray_version,
})
files = execute_request(path)
out_data = []
for file in files:
group_match = build_group_regex.match(file["path"]).group(1)
download_url = "https://dl.bintray.com/{subject}/{repo}/{file_path}".format(**{
"subject": config["bintray"]["subject"],
"repo": file["repo"],
"file_path": file["path"]
})
out_data.append(ReleaseFile(file["name"], download_url, file["sha1"], group_match))
return sorted(out_data, key=lambda x: x.group)