Skip to content

Commit b5c4e6a

Browse files
commander: allow running commands inside the docker
1 parent cb1ca46 commit b5c4e6a

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

core/services/commander/main.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import json
44
import logging
55
import os
6+
import shlex
67
import shutil
78
import subprocess
89
import time
@@ -70,6 +71,20 @@ async def command_host(command: str, i_know_what_i_am_doing: bool = False) -> An
7071
return message
7172

7273

74+
@app.post("/command/blueos", status_code=status.HTTP_200_OK)
75+
@version(1, 0)
76+
async def command_blueos(command: str, i_know_what_i_am_doing: bool = False) -> Any:
77+
check_what_i_am_doing(i_know_what_i_am_doing)
78+
logger.debug(f"Running command: {command}")
79+
return subprocess.run(
80+
shlex.split(command),
81+
check=False,
82+
text=True,
83+
stdout=subprocess.PIPE,
84+
stderr=subprocess.PIPE,
85+
)
86+
87+
7388
@app.post("/set_time", status_code=status.HTTP_200_OK)
7489
@version(1, 0)
7590
async def set_time(unix_time_seconds: int, i_know_what_i_am_doing: bool = False) -> Any:

0 commit comments

Comments
 (0)