[WS] Move download_if_exist to lib

git-svn-id: svn://kolibrios.org@9382 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Magomed Kostoev (mkostoevr) 2021-12-04 09:59:17 +00:00
parent f505262a89
commit 460c5f6329
2 changed files with 7 additions and 4 deletions

View File

@ -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)

View File

@ -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")