From 8d390af122b948069eacb8dfdd3e8c892fa74df8 Mon Sep 17 00:00:00 2001 From: Qubasa Date: Wed, 27 Sep 2023 02:11:13 +0200 Subject: [PATCH] Working log streaming --- pkgs/clan-cli/clan_cli/webui/routers/vms.py | 2 +- pkgs/clan-cli/clan_cli/webui/task_manager.py | 2 +- pkgs/clan-cli/tests/test_vms_api.py | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pkgs/clan-cli/clan_cli/webui/routers/vms.py b/pkgs/clan-cli/clan_cli/webui/routers/vms.py index f0c35ac63..503962a3d 100644 --- a/pkgs/clan-cli/clan_cli/webui/routers/vms.py +++ b/pkgs/clan-cli/clan_cli/webui/routers/vms.py @@ -72,7 +72,7 @@ class BuildVmTask(BaseTask): vm_path = f"{''.join(proc.stdout[0])}/bin/run-nixos-vm" self.log.debug(f"vm_path: {vm_path}") - #self.run_cmd(vm_path) + self.run_cmd(vm_path) self.finished = True except Exception as e: self.failed = True diff --git a/pkgs/clan-cli/clan_cli/webui/task_manager.py b/pkgs/clan-cli/clan_cli/webui/task_manager.py index cdbc81551..dd53a70fe 100644 --- a/pkgs/clan-cli/clan_cli/webui/task_manager.py +++ b/pkgs/clan-cli/clan_cli/webui/task_manager.py @@ -43,7 +43,7 @@ class BaseTask(threading.Thread): stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding="utf-8", - # shell=True, + # shell=True, cwd=cwd, ) self.procs.append(CmdState(p)) diff --git a/pkgs/clan-cli/tests/test_vms_api.py b/pkgs/clan-cli/tests/test_vms_api.py index 5a1a16de2..c06d94ef2 100644 --- a/pkgs/clan-cli/tests/test_vms_api.py +++ b/pkgs/clan-cli/tests/test_vms_api.py @@ -3,7 +3,6 @@ from pathlib import Path import pytest from api import TestClient - # @pytest.mark.impure # def test_inspect(api: TestClient, test_flake_with_core: Path) -> None: # response = api.post( @@ -43,7 +42,8 @@ def test_create(api: TestClient, test_flake_with_core: Path) -> None: response = api.get(f"/api/vms/{uuid}/logs") print("=========LOGS==========") for line in response.stream: - print(f"line: {line}") assert line != b"", "Failed to get vm logs" - - assert response.status_code == 200, "Failed to get vm logs" \ No newline at end of file + print(line.decode("utf-8"), end="") + print("=========END LOGS==========") + assert response.status_code == 200, "Failed to get vm logs" + time.sleep(10) \ No newline at end of file