From 3d61178d46401aacb91dbfd55a7e6724f2d83702 Mon Sep 17 00:00:00 2001 From: Daniel Fernandes Date: Thu, 10 Jul 2025 12:21:09 +0000 Subject: [PATCH 1/6] Add API_KEY --- src/blueapi/config.py | 2 ++ 1 file changed, 2 insertions(+) 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) From 424cfb45dbe9b6353d59081e02f352a4c06e4bdc Mon Sep 17 00:00:00 2001 From: Daniel Fernandes Date: Thu, 10 Jul 2025 12:32:55 +0000 Subject: [PATCH 2/6] Add run-command --- src/blueapi/cli/cli.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/blueapi/cli/cli.py b/src/blueapi/cli/cli.py index 7bafa831f5..5013133628 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 @@ -182,6 +183,13 @@ 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""" + subprocess.run(commands) + + @main.group() @click.option( "-o", From 4fdfff808a888f0721d99ce322a4116fe655c41f Mon Sep 17 00:00:00 2001 From: Daniel Fernandes Date: Mon, 2 Mar 2026 15:58:56 +0000 Subject: [PATCH 3/6] Add test_run_command --- tests/unit_tests/cli/test_cli.py | 5 +++++ 1 file changed, 5 insertions(+) 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 From 83c3c740a2c0e8b3fd1ee2c53a9aa5e7b23b8349 Mon Sep 17 00:00:00 2001 From: Daniel Fernandes Date: Thu, 10 Jul 2025 12:45:49 +0000 Subject: [PATCH 4/6] Make run_command return result of subprocess --- src/blueapi/cli/cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/blueapi/cli/cli.py b/src/blueapi/cli/cli.py index 5013133628..a413f510b4 100644 --- a/src/blueapi/cli/cli.py +++ b/src/blueapi/cli/cli.py @@ -187,7 +187,7 @@ def start_application(obj: dict): @click.argument("commands", nargs=-1) def run_command(commands: str) -> Any | None: """Run shell command remotely""" - subprocess.run(commands) + return subprocess.run(commands) @main.group() From 35d8067258b4b7e1ee3b787019ad66d229f86995 Mon Sep 17 00:00:00 2001 From: Daniel Fernandes Date: Fri, 11 Jul 2025 07:25:58 +0000 Subject: [PATCH 5/6] Add download argument --- src/blueapi/cli/cli.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/blueapi/cli/cli.py b/src/blueapi/cli/cli.py index a413f510b4..3f6821a03a 100644 --- a/src/blueapi/cli/cli.py +++ b/src/blueapi/cli/cli.py @@ -190,6 +190,12 @@ def run_command(commands: str) -> Any | None: 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", From 510664703b8dcfd68bdce0010f776e6824d945b1 Mon Sep 17 00:00:00 2001 From: Daniel Fernandes Date: Fri, 11 Jul 2025 08:09:24 +0000 Subject: [PATCH 6/6] Add username and password --- src/blueapi/cli/cli.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/blueapi/cli/cli.py b/src/blueapi/cli/cli.py index 3f6821a03a..853b3b1b9d 100644 --- a/src/blueapi/cli/cli.py +++ b/src/blueapi/cli/cli.py @@ -77,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"} )