Rev 9389 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
9389 | Boppan | 1 | import os |
9390 | Boppan | 2 | import shutil |
9389 | Boppan | 3 | |
4 | from .network import download |
||
5 | from .constants import tools_cache |
||
6 | |||
9390 | Boppan | 7 | def builds_get(path, output_path = None): |
9389 | Boppan | 8 | url = f"http://builds.kolibrios.org/{path}" |
9390 | Boppan | 9 | cached_path = f"{tools_cache}/builds.kolibrios.org/{path}" |
10 | os.makedirs(os.path.dirname(cached_path), exist_ok = True) |
||
11 | download(url, cached_path, skip_exist = True) |
||
12 | if output_path != None: |
||
13 | shutil.copyfile(cached_path, output_path) |
||
14 | return output_path |
||
15 | return cached_path |
||
9389 | Boppan | 16 | |
17 | def builds_get_contents(path): |
||
18 | output_path = builds_get(path) |
||
19 | with open(output_path, "rb") as f: |
||
20 | return f.read() |
||
21 |