Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/blueapi/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import logging
import os
import stat
import subprocess
import sys
import textwrap
from collections.abc import Callable
Expand Down Expand Up @@ -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"}
)
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions src/blueapi/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions tests/unit_tests/cli/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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