-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexecute_command.py
More file actions
32 lines (24 loc) · 961 Bytes
/
execute_command.py
File metadata and controls
32 lines (24 loc) · 961 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import asyncio
import logging
from codesphere import CodesphereSDK
# --- Logging-Konfiguration ---
logging.basicConfig(level=logging.INFO)
# (Optionale Logger stummschalten)
logging.getLogger("codesphere.http_client").setLevel(logging.WARNING)
logging.getLogger("httpx").setLevel(logging.WARNING)
log = logging.getLogger(__name__)
async def main():
async with CodesphereSDK() as sdk:
teams = await sdk.teams.list()
workspaces = await sdk.workspaces.list_by_team(team_id=teams[0].id)
workspace = workspaces[0]
state = await workspace.get_status()
print(state.model_dump_json(indent=2))
command_str = "echo Hello from $USER_NAME!"
command_env = {"USER_NAME": "SDK-User"}
command_output = await workspace.execute_command(
command=command_str, env=command_env
)
print(command_output.model_dump_json(indent=2))
if __name__ == "__main__":
asyncio.run(main())