vm-manager: More error handling

This commit is contained in:
Qubasa
2024-01-02 06:23:55 +01:00
parent b6bcf8dfa7
commit 5d69830f1a
3 changed files with 25 additions and 20 deletions

View File

@@ -4,7 +4,9 @@ from pathlib import Path
from typing import Any
import gi
from clan_cli import history
from clan_cli.history.list import list_history
from .errors.show_error import show_error_dialog
gi.require_version("GdkPixbuf", "2.0")
@@ -64,24 +66,27 @@ def get_initial_vms(
) -> list[VM]:
vm_list = []
# Execute `clan flakes add <path>` to democlan for this to work
for entry in history.list.list_history():
icon = assets.loc / "placeholder.jpeg"
if entry.flake.icon is not None:
icon = entry.flake.icon
try:
# Execute `clan flakes add <path>` to democlan for this to work
for entry in list_history():
icon = assets.loc / "placeholder.jpeg"
if entry.flake.icon is not None:
icon = entry.flake.icon
status = False
if entry.flake.flake_url in running_vms:
status = True
status = False
if entry.flake.flake_url in running_vms:
status = True
base = VMBase(
icon=icon,
name=entry.flake.clan_name,
url=entry.flake.flake_url,
status=status,
_flake_attr=entry.flake.flake_attr,
)
vm_list.append(VM(base=base))
base = VMBase(
icon=icon,
name=entry.flake.clan_name,
url=entry.flake.flake_url,
status=status,
_flake_attr=entry.flake.flake_attr,
)
vm_list.append(VM(base=base))
except Exception as e:
show_error_dialog(e)
# start/end slices can be used for pagination
return vm_list[start:end]

View File

@@ -33,6 +33,7 @@ class OverviewWindow(Gtk.ApplicationWindow):
set_selected=self.set_selected,
selected_vm=None,
)
# Add named stacks
self.stack.add_titled(clan_list, "list", "List")
self.stack.add_titled(