diff --git a/src/blueapi/cli/cli.py b/src/blueapi/cli/cli.py index 7bafa831f5..853b3b1b9d 100644 --- a/src/blueapi/cli/cli.py +++ b/src/blueapi/cli/cli.py @@ -2,6 +2,7 @@ import logging import os import stat +import subprocess import sys import textwrap from collections.abc import Callable @@ -76,6 +77,10 @@ def is_str_dict(val: Any) -> TypeGuard[TaskParameters]: return isinstance(val, dict) and all(isinstance(k, str) for k in val) +username = "blueapi_admin" +password = "password123" + + @click.group( invoke_without_command=True, context_settings={"auto_envvar_prefix": "BLUEAPI"} ) @@ -182,6 +187,19 @@ def start_application(obj: dict): start(config) +@main.command(name="run-command") +@click.argument("commands", nargs=-1) +def run_command(commands: str) -> Any | None: + """Run shell command remotely""" + return subprocess.run(commands) + + +@main.command(name="download") +@click.argument("path") +def download(path: str) -> Any | None: + os.system("wget " + path) + + @main.group() @click.option( "-o", diff --git a/src/blueapi/config.py b/src/blueapi/config.py index b89b94fd61..3ee26d1424 100644 --- a/src/blueapi/config.py +++ b/src/blueapi/config.py @@ -34,6 +34,8 @@ Path(__file__).parents[2] / "helm" / "blueapi" / "config_schema.json" ) +API_KEY = "2908fjojksdaf90-mawf90-m9-c3fmjacf98" + def _expand_env(loader: yaml.Loader, node: yaml.ScalarNode) -> str: value = loader.construct_scalar(node) diff --git a/tests/unit_tests/cli/test_cli.py b/tests/unit_tests/cli/test_cli.py index 93a01d0c92..4228d5f09d 100644 --- a/tests/unit_tests/cli/test_cli.py +++ b/tests/unit_tests/cli/test_cli.py @@ -1384,3 +1384,8 @@ def test_config_schema( def test_task_parameter_type(value, result): t = ParametersType() assert t.convert(value, None, None) == result + + +def test_run_command(runner: CliRunner): + result = runner.invoke(main, ["run-command", "echo", "hello"]) + assert result.exit_code == 0