From 460c5f63292315c6cd1db068d34e5b31b1cc122e Mon Sep 17 00:00:00 2001 From: "Magomed Kostoev (mkostoevr)" Date: Sat, 4 Dec 2021 09:59:17 +0000 Subject: [PATCH] [WS] Move download_if_exist to lib git-svn-id: svn://kolibrios.org@9382 a494cfbc-eb01-0410-851d-a64ba20cac60 --- _tools/lib/network.py | 4 ++++ _tools/workspace/run.py | 7 +++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/_tools/lib/network.py b/_tools/lib/network.py index 197ef3a8cc..97fa44e3a5 100644 --- a/_tools/lib/network.py +++ b/_tools/lib/network.py @@ -1,3 +1,4 @@ +import os import urllib.request from .logging import log @@ -6,4 +7,7 @@ def download(link, path): 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 58df8058b5..2c02140191 100644 --- a/_tools/workspace/run.py +++ b/_tools/workspace/run.py @@ -14,7 +14,7 @@ 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 +from lib.network import download_if_not_exist # TODO: Move into _tools/lib def run_qemu(start_dir = "workspace"): @@ -44,9 +44,8 @@ if __name__ == "__main__": os.makedirs("workspace", exist_ok = True) - if not os.path.exists("workspace/kolibri.unmodified.img"): - img_url = "http://builds.kolibrios.org/eng/data/data/kolibri.img" - download(img_url, "workspace/kolibri.unmodified.img") + img_url = "http://builds.kolibrios.org/eng/data/data/kolibri.img" + download_if_not_exist(img_url, "workspace/kolibri.unmodified.img") # Create a copy of IMG shutil.copyfile("workspace/kolibri.unmodified.img", "workspace/kolibri.img")