Skip to content

Commit

Permalink
chore(black): run black on source code
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick Avery <[email protected]>
  • Loading branch information
psavery committed May 31, 2022
1 parent a881ffb commit ea45740
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 48 deletions.
61 changes: 32 additions & 29 deletions docker/scripts/generate_launcher_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 '
Expand All @@ -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
Expand Down
21 changes: 15 additions & 6 deletions docker/scripts/generate_www.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
6 changes: 3 additions & 3 deletions docker/scripts/yaml_to_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
import yaml

if len(sys.argv) < 3:
sys.exit('Usage: <script> <input_yaml> <output_json>')
sys.exit("Usage: <script> <input_yaml> <output_json>")

input_file = sys.argv[1]
output_file = sys.argv[2]

with open(input_file, 'r') as rf:
with open(input_file, "r") as rf:
input_dict = yaml.safe_load(rf)

with open(output_file, 'w') as wf:
with open(output_file, "w") as wf:
json.dump(input_dict, wf, indent=2)
27 changes: 17 additions & 10 deletions docs/api/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,21 +59,26 @@

# -- Modify environment variables --------------------------------------------

os.environ.update({
"TRAME_PARAVIEW_FAIL_SILENTLY": "True",
})
os.environ.update(
{
"TRAME_PARAVIEW_FAIL_SILENTLY": "True",
}
)

# -- Hooks for sphinx events -------------------------------------------------


def run_apidoc(_):

# Override the apidoc options with what we want
apidoc.OPTIONS.clear()
apidoc.OPTIONS.extend([
"members",
"imported-members",
"show-inheritance",
])
apidoc.OPTIONS.extend(
[
"members",
"imported-members",
"show-inheritance",
]
)

exclude_paths = [
"env/utils.py",
Expand All @@ -91,8 +96,10 @@ def run_apidoc(_):
"-T",
"-e",
"-M",
"-o", cur_path,
"-t", templates_path,
"-o",
cur_path,
"-t",
templates_path,
module_path,
] + exclude_paths

Expand Down

0 comments on commit ea45740

Please sign in to comment.