diff --git a/docker/scripts/generate_launcher_config.py b/docker/scripts/generate_launcher_config.py index 0496140e..21a8beb6 100755 --- a/docker/scripts/generate_launcher_config.py +++ b/docker/scripts/generate_launcher_config.py @@ -6,34 +6,37 @@ def run(input_path, apps_path, out_path): default_command_flags = [ - '--host', '${host}', - '--port', '${port}', - '--authKey', '${secret}', - '--server', + "--host", + "${host}", + "--port", + "${port}", + "--authKey", + "${secret}", + "--server", ] - default_ready_line = 'Starting factory' + default_ready_line = "Starting factory" - with open(input_path, 'r') as rf: + with open(input_path, "r") as rf: input_dict = json.load(rf) if not Path(apps_path).exists(): - raise Exception(f'{apps_path} does not exist') + raise Exception(f"{apps_path} does not exist") - with open(apps_path, 'r') as rf: + with open(apps_path, "r") as rf: apps_dict = json.load(rf) if not apps_dict: - raise Exception(f'{apps_path} is empty') + raise Exception(f"{apps_path} is empty") for app_name, config in apps_dict.items(): - if 'app' not in config: + if "app" not in config: msg = ( f'In {apps_path}, every app must contain an "app" key, but ' f'"{app_name}" does not' ) raise Exception(msg) - if 'cmd' in config and 'args' in config: + if "cmd" in config and "args" in config: msg = ( f'In {apps_path}, "args" and "cmd" cannot both be specified. ' '"args" is for appending extra args to the default "cmd", but ' @@ -42,33 +45,33 @@ def run(input_path, apps_path, out_path): ) raise Exception(msg) - app = config['app'] + app = config["app"] default_cmd = [app] + default_command_flags - cmd = config.get('cmd', default_cmd) - cmd += config.get('args', []) - ready_line = config.get('ready_line', default_ready_line) - - input_dict.setdefault('apps', {}) - input_dict['apps'][app_name] = { - 'cmd': cmd, - 'ready_line': ready_line, + cmd = config.get("cmd", default_cmd) + cmd += config.get("args", []) + ready_line = config.get("ready_line", default_ready_line) + + input_dict.setdefault("apps", {}) + input_dict["apps"][app_name] = { + "cmd": cmd, + "ready_line": ready_line, } - if 'trame' not in input_dict['apps']: + if "trame" not in input_dict["apps"]: # Make a copy of the first app and put it in PyWebVue, so that # the default localhost:9000 web page will use that app. - first_key = next(iter(input_dict['apps'])) - input_dict['apps']['trame'] = input_dict['apps'][first_key] + first_key = next(iter(input_dict["apps"])) + input_dict["apps"]["trame"] = input_dict["apps"][first_key] - with open(out_path, 'w') as wf: + with open(out_path, "w") as wf: json.dump(input_dict, wf, indent=2) -if __name__ == '__main__': - default_input_path = '/opt/trame/default-launcher.json' - override_input_path = '/deploy/setup/launcher.json' - apps_path = '/opt/trame/apps.json' - out_path = '/deploy/server/launcher.json' +if __name__ == "__main__": + default_input_path = "/opt/trame/default-launcher.json" + override_input_path = "/deploy/setup/launcher.json" + apps_path = "/opt/trame/apps.json" + out_path = "/deploy/server/launcher.json" if Path(override_input_path).exists(): input_path = override_input_path diff --git a/docker/scripts/generate_www.py b/docker/scripts/generate_www.py index 5c2a27ea..60f2a0de 100755 --- a/docker/scripts/generate_www.py +++ b/docker/scripts/generate_www.py @@ -6,10 +6,10 @@ def run(apps_path, out_path, *modules): # generate www content - cmd = ["python", "-m", "trame.tools.www", "--output", f'{out_path}', *modules] + cmd = ["python", "-m", "trame.tools.www", "--output", f"{out_path}", *modules] subprocess.run(cmd) - with open(apps_path, 'r') as rf: + with open(apps_path, "r") as rf: apps_dict = json.load(rf) # FIXME need to generate index.html => {app_name}.html @@ -19,8 +19,17 @@ def run(apps_path, out_path, *modules): # => replace data-app-name="trame" => data-app-name="{name}" -if __name__ == '__main__': - apps_path = '/opt/trame/apps.json' - out_path = '/deploy/server/www' - modules = ["client", "trame", "vtk", "vuetify", "plotly", "router", "vega", "markdown"] +if __name__ == "__main__": + apps_path = "/opt/trame/apps.json" + out_path = "/deploy/server/www" + modules = [ + "client", + "trame", + "vtk", + "vuetify", + "plotly", + "router", + "vega", + "markdown", + ] run(apps_path, out_path, *modules) diff --git a/docker/scripts/yaml_to_json.py b/docker/scripts/yaml_to_json.py index ff30ad5f..26287aed 100755 --- a/docker/scripts/yaml_to_json.py +++ b/docker/scripts/yaml_to_json.py @@ -5,13 +5,13 @@ import yaml if len(sys.argv) < 3: - sys.exit('Usage: