From 377e8313a0689757bfc78943f89c1aa54145f716 Mon Sep 17 00:00:00 2001 From: Ezio Melotti Date: Wed, 28 Jun 2023 21:51:19 +0200 Subject: [PATCH 1/2] Add a new "deploy" command to simoc-web.py. --- simoc-web.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/simoc-web.py b/simoc-web.py index 7a0f747d0..5ff6b682e 100644 --- a/simoc-web.py +++ b/simoc-web.py @@ -108,22 +108,28 @@ def build(): return docker_run('-it', '--entrypoint', 'npm', IMGNAME, 'run', 'build') @cmd -def copy_dist_dir(): +def copy_dist_dir(assume_yes=False): """Copy the dist dir into the "simoc" repo.""" # assume that both the simoc and simoc-web repos are in the same dir simoc_server_dir = SIMOC_DIR / 'simoc_server' simoc_web_dist_dir = SIMOC_WEB_DIR / 'dist' if not simoc_server_dir.exists(): print(f'* <{simoc_server_dir}> does not exist') + if not assume_yes: + return False p = input('* Please enter the path to the "simoc_server" dir: ') simoc_server_dir = pathlib.Path(p).resolve() - ans = input(f'* Copy <{simoc_web_dist_dir}> into <{simoc_server_dir}>? [Y/n] ') + ans = 'y' + if not assume_yes: + ans = input(f'* Copy <{simoc_web_dist_dir}> into <{simoc_server_dir}>? [Y/n] ') if ans.lower().strip() == 'n': print(f'* <{simoc_web_dist_dir}> not copied') return False simoc_dist_dir = simoc_server_dir / 'dist' if simoc_dist_dir.exists(): - ans = input(f'* <{simoc_dist_dir}> already exist, remove it? [Y/n] ') + ans = 'y' + if not assume_yes: + ans = input(f'* <{simoc_dist_dir}> already exist, remove it? [Y/n] ') if ans.lower().strip() == 'n': print(f'* <{simoc_web_dist_dir}> not copied') return False @@ -144,6 +150,12 @@ def setup(): return (install_docker() and build_image() and setup_deps() and build_and_copy()) +@cmd +def deploy(): + """Build the SIMOC frontend and copy it for deployment.""" + return (build_image() and setup_deps() and build() and + copy_dist_dir(assume_yes=True)) + def create_help(cmds): help = ['Full list of available commands:'] From 4c90369da1d1fc6a7f7e52c25ba134ff1e032093 Mon Sep 17 00:00:00 2001 From: Ezio Melotti Date: Wed, 28 Jun 2023 21:56:52 +0200 Subject: [PATCH 2/2] Restore Python 3.6 compatibility. --- simoc-web.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/simoc-web.py b/simoc-web.py index 5ff6b682e..e1bfe1835 100644 --- a/simoc-web.py +++ b/simoc-web.py @@ -40,7 +40,7 @@ def docker_run(*args): # detect and connect to the network if it's available net_name = 'simoc_simoc-net' cp = subprocess.run(['docker', 'network', 'inspect', net_name], - capture_output=True) + stdout=subprocess.DEVNULL) net_args = ['--network', net_name] if cp.returncode == 0 else [] fe_branch = f'VITE_FE_BRANCH={get_current_branch(SIMOC_WEB_DIR)}' be_branch = f'VITE_BE_BRANCH={get_current_branch(SIMOC_DIR)}'