generated from Luis/nextjs-python-web-template
CLI: Restructured TaskManager and log collection
This commit is contained in:
@@ -1,10 +1,24 @@
|
||||
import argparse
|
||||
import asyncio
|
||||
from uuid import UUID
|
||||
import threading
|
||||
import queue
|
||||
|
||||
from ..dirs import get_clan_flake_toplevel
|
||||
from ..webui.routers import vms
|
||||
from ..webui.schemas import VmConfig
|
||||
from typing import Any, Iterator
|
||||
from fastapi.responses import StreamingResponse
|
||||
import pdb
|
||||
|
||||
def read_stream_response(stream: StreamingResponse) -> Iterator[Any]:
|
||||
iterator = stream.body_iterator
|
||||
while True:
|
||||
try:
|
||||
tem = asyncio.run(iterator.__anext__())
|
||||
except StopAsyncIteration:
|
||||
break
|
||||
yield tem
|
||||
|
||||
def create(args: argparse.Namespace) -> None:
|
||||
clan_dir = get_clan_flake_toplevel().as_posix()
|
||||
@@ -18,6 +32,13 @@ def create(args: argparse.Namespace) -> None:
|
||||
|
||||
res = asyncio.run(vms.create_vm(vm))
|
||||
print(res.json())
|
||||
uuid = UUID(res.uuid)
|
||||
|
||||
res = asyncio.run(vms.get_vm_logs(uuid))
|
||||
|
||||
for line in read_stream_response(res):
|
||||
print(line)
|
||||
|
||||
|
||||
|
||||
def register_create_parser(parser: argparse.ArgumentParser) -> None:
|
||||
|
||||
Reference in New Issue
Block a user