From 20a3397e97ba532dc0e1856f7fe371871773cfd4 Mon Sep 17 00:00:00 2001 From: Victor Seiji Hariki Date: Tue, 24 Jan 2023 19:44:30 -0300 Subject: [PATCH] add exception handler in case preload breaks? Signed-off-by: Victor Seiji Hariki --- preload.py | 3 ++- scripts/main.py | 20 +++++++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/preload.py b/preload.py index 29b726a..00a0a13 100644 --- a/preload.py +++ b/preload.py @@ -2,4 +2,5 @@ def preload(parser: argparse.ArgumentParser): parser.add_argument("--lock-oo-submodule", action='store_true', - help="(openOutpaint-webUI-extension) Prevent checking for main openOutpaint submodule updates.") \ No newline at end of file + help="(openOutpaint-webUI-extension) Prevent checking for main openOutpaint submodule updates.") + \ No newline at end of file diff --git a/scripts/main.py b/scripts/main.py index 3ac57c7..2a4a7e3 100644 --- a/scripts/main.py +++ b/scripts/main.py @@ -38,7 +38,7 @@ def started(demo, app: FastAPI): # Add to allowed files list app.blocks.temp_file_sets.append(force_allow) - + # Force allow paths for fixing symlinked extension directory references (base javascript files now) force_allow = get_files(extension_dir / "javascript") @@ -49,11 +49,21 @@ def started(demo, app: FastAPI): pass +def update_app(): + git = os.environ.get('GIT', "git") + run(f'"{git}" -C "' + scripts.basedir() + + '" submodule update --init --recursive --remote') + + def add_tab(): - if (not shared.cmd_opts.lock_oo_submodule): - git = os.environ.get('GIT', "git") - run(f'"{git}" -C "' + scripts.basedir() + - '" submodule update --init --recursive --remote') + try: + if shared.cmd_opts.lock_oo_submodule: + print(f"[openOutpaint] Submodule locked. Will skip submodule update.") + else: + update_app() + except Exception: + update_app() + with gr.Blocks(analytics_enabled=False) as ui: #refresh = gr.Button(value="refresh", variant="primary") canvas = gr.HTML(