2021-12-04 14:50:32 +03:00
|
|
|
import os
|
2021-12-04 15:07:06 +03:00
|
|
|
import shutil
|
2021-12-04 14:50:32 +03:00
|
|
|
|
|
|
|
from .network import download
|
|
|
|
from .constants import tools_cache
|
|
|
|
|
2021-12-04 15:07:06 +03:00
|
|
|
def builds_get(path, output_path = None):
|
2021-12-04 14:50:32 +03:00
|
|
|
url = f"http://builds.kolibrios.org/{path}"
|
2021-12-04 15:07:06 +03:00
|
|
|
cached_path = f"{tools_cache}/builds.kolibrios.org/{path}"
|
|
|
|
os.makedirs(os.path.dirname(cached_path), exist_ok = True)
|
|
|
|
download(url, cached_path, skip_exist = True)
|
|
|
|
if output_path != None:
|
|
|
|
shutil.copyfile(cached_path, output_path)
|
|
|
|
return output_path
|
|
|
|
return cached_path
|
2021-12-04 14:50:32 +03:00
|
|
|
|
|
|
|
def builds_get_contents(path):
|
|
|
|
output_path = builds_get(path)
|
|
|
|
with open(output_path, "rb") as f:
|
|
|
|
return f.read()
|
|
|
|
|