From b8453028f71f2401f900ead14e035f150fe4d3e9 Mon Sep 17 00:00:00 2001 From: "Magomed Kostoev (mkostoevr)" Date: Sat, 4 Dec 2021 10:41:27 +0000 Subject: [PATCH] [WS] Merge download_if_not_exist and download functions git-svn-id: svn://kolibrios.org@9384 a494cfbc-eb01-0410-851d-a64ba20cac60 --- _tools/get_started.py | 4 ++-- _tools/lib/network.py | 8 +++----- _tools/workspace/run.py | 1 - 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/_tools/get_started.py b/_tools/get_started.py index 89c6b39c0..15abfadef 100755 --- a/_tools/get_started.py +++ b/_tools/get_started.py @@ -4,7 +4,7 @@ import os -from lib.network import download_if_not_exist +from lib.network import download from lib.logging import log from lib.constants import tools_cache, tools_cache_kolibri_img @@ -40,4 +40,4 @@ if __name__ == "__main__": # Download IMG to _tools/cache os.makedirs(tools_cache, exist_ok = True) img_url = "http://builds.kolibrios.org/eng/data/data/kolibri.img" - download_if_not_exist(img_url, tools_cache_kolibri_img) + download(img_url, tools_cache_kolibri_img, skip_exist = True) diff --git a/_tools/lib/network.py b/_tools/lib/network.py index 97fa44e3a..9ac9c3a16 100644 --- a/_tools/lib/network.py +++ b/_tools/lib/network.py @@ -2,12 +2,10 @@ import os import urllib.request from .logging import log -def download(link, path): +def download(link, path, skip_exist = False): + if skip_exist and os.path.exists(path): + return log(f"Downloading {path}... ", end = "") urllib.request.urlretrieve(link, path) log("Done.") -def download_if_not_exist(link, path): - if not os.path.exists(path): - download(link, path) - diff --git a/_tools/workspace/run.py b/_tools/workspace/run.py index f50c4d9bf..c9010af7c 100644 --- a/_tools/workspace/run.py +++ b/_tools/workspace/run.py @@ -14,7 +14,6 @@ from workspace.build import build from lib.makeflop import Floppy from lib.platform import is_win32, path from lib.logging import log -from lib.network import download_if_not_exist from lib.constants import tools_cache_kolibri_img # TODO: Move into _tools/lib