From e7668f6e41bd36af7b1af29d16c39c0948e642c2 Mon Sep 17 00:00:00 2001 From: Qubasa Date: Tue, 30 Jan 2024 15:32:35 +0700 Subject: [PATCH] Machine __str__ impl --- pkgs/clan-cli/clan_cli/machines/machines.py | 6 ++++++ pkgs/clan-vm-manager/clan_vm_manager/views/list.py | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/pkgs/clan-cli/clan_cli/machines/machines.py b/pkgs/clan-cli/clan_cli/machines/machines.py index 54ac651ab..69a5ef2b9 100644 --- a/pkgs/clan-cli/clan_cli/machines/machines.py +++ b/pkgs/clan-cli/clan_cli/machines/machines.py @@ -31,6 +31,12 @@ class Machine: if deployment_info is not None: self.deployment_info = deployment_info + def __str__(self) -> str: + return f"Machine(name={self.name}, flake={self.flake})" + + def __repr__(self) -> str: + return str(self) + def get_deployment_info(self) -> None: self.deployment_info = json.loads( self.build_nix("config.system.clan.deployment.file").read_text() diff --git a/pkgs/clan-vm-manager/clan_vm_manager/views/list.py b/pkgs/clan-vm-manager/clan_vm_manager/views/list.py index 3f5f1fc49..08e1f5c7a 100644 --- a/pkgs/clan-vm-manager/clan_vm_manager/views/list.py +++ b/pkgs/clan-vm-manager/clan_vm_manager/views/list.py @@ -189,9 +189,9 @@ class ClanList(Gtk.Box): def vm_status_changed(self, switch: Gtk.Switch, vm: VM, _vm: VM) -> None: switch.set_active(vm.is_running()) switch.set_state(vm.is_running()) - print("====> Set switch to", vm.is_running()) exitc = vm.process.proc.exitcode - if not vm.is_running() and exitc != 0 and exitc != -15: + print("VM exited with code:", exitc) + if not vm.is_running() and exitc != 0: print("VM exited with error. Exitcode:", exitc) print(vm.read_log()) - self.show_error_dialog(vm.read_log()) + # self.show_error_dialog(vm.read_log())