[WS] Small refactoring

git-svn-id: svn://kolibrios.org@9385 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Magomed Kostoev (mkostoevr) 2021-12-04 10:55:50 +00:00
parent b8453028f7
commit e954bb32fd
2 changed files with 17 additions and 5 deletions

View File

@ -6,7 +6,7 @@ import os
from lib.network import download from lib.network import download
from lib.logging import log from lib.logging import log
from lib.constants import tools_cache, tools_cache_kolibri_img from lib.constants import tools, tools_workspace, tools_cache, tools_cache_kolibri_img
def generate_script_executing_script(script_to_execute): def generate_script_executing_script(script_to_execute):
script_to_execute = script_to_execute.replace("\\", "\\\\") script_to_execute = script_to_execute.replace("\\", "\\\\")
@ -25,9 +25,8 @@ def create_workspace_script(name, script_to_execute):
log("Done") log("Done")
if __name__ == "__main__": if __name__ == "__main__":
tools_get_started_py = os.path.abspath(__file__) # Create _tools/cache folder if not exist
tools = os.sep.join(tools_get_started_py.split(os.sep)[:-1]) os.makedirs(tools_cache, exist_ok = True)
tools_workspace = os.sep.join([tools, "workspace"])
# Create (in current directory) scripts that execute # Create (in current directory) scripts that execute
# the same named scripts from _tools/workspace # the same named scripts from _tools/workspace
tools_workspace_run_py = os.path.join(tools_workspace, "run.py") tools_workspace_run_py = os.path.join(tools_workspace, "run.py")
@ -38,6 +37,5 @@ if __name__ == "__main__":
# TODO: Do anything if tup doesn't exist # TODO: Do anything if tup doesn't exist
os.system("tup init") os.system("tup init")
# Download IMG to _tools/cache # Download IMG to _tools/cache
os.makedirs(tools_cache, exist_ok = True)
img_url = "http://builds.kolibrios.org/eng/data/data/kolibri.img" img_url = "http://builds.kolibrios.org/eng/data/data/kolibri.img"
download(img_url, tools_cache_kolibri_img, skip_exist = True) download(img_url, tools_cache_kolibri_img, skip_exist = True)

View File

@ -1,8 +1,22 @@
import os import os
### PATHS
# _tools/lib/constants.py
tools_lib_constants_py = os.path.abspath(__file__) tools_lib_constants_py = os.path.abspath(__file__)
# _tools/lib
tools_lib = os.path.dirname(tools_lib_constants_py) tools_lib = os.path.dirname(tools_lib_constants_py)
# _tools
tools = os.path.dirname(tools_lib) tools = os.path.dirname(tools_lib)
# _tools/workspace
tools_workspace = os.path.join(tools, "workspace")
# _tools/cache
tools_cache = os.path.join(tools, "cache") tools_cache = os.path.join(tools, "cache")
# _tools/cache/kolibri.img
tools_cache_kolibri_img = os.path.join(tools_cache, "kolibri.img") tools_cache_kolibri_img = os.path.join(tools_cache, "kolibri.img")