Merge pull request 'clan-vm-manager: remove type assertions' (#1974) from nixos-facter into main
This commit is contained in:
@@ -13,7 +13,7 @@ from typing import IO, ClassVar
|
|||||||
|
|
||||||
import gi
|
import gi
|
||||||
from clan_cli import vms
|
from clan_cli import vms
|
||||||
from clan_cli.clan_uri import ClanURI, FlakeId
|
from clan_cli.clan_uri import ClanURI
|
||||||
from clan_cli.dirs import vm_state_dir
|
from clan_cli.dirs import vm_state_dir
|
||||||
from clan_cli.history.add import HistoryEntry
|
from clan_cli.history.add import HistoryEntry
|
||||||
from clan_cli.machines.machines import Machine
|
from clan_cli.machines.machines import Machine
|
||||||
@@ -51,7 +51,6 @@ class VMObject(GObject.Object):
|
|||||||
|
|
||||||
# Store the data from the history entry
|
# Store the data from the history entry
|
||||||
self.data: HistoryEntry = data
|
self.data: HistoryEntry = data
|
||||||
assert isinstance(self.data.flake.vm.flake_url, FlakeId)
|
|
||||||
self.build_log_cb = build_log_cb
|
self.build_log_cb = build_log_cb
|
||||||
|
|
||||||
# Create a process object to store the VM process
|
# Create a process object to store the VM process
|
||||||
@@ -99,7 +98,6 @@ class VMObject(GObject.Object):
|
|||||||
return GLib.SOURCE_REMOVE
|
return GLib.SOURCE_REMOVE
|
||||||
|
|
||||||
def update(self, data: HistoryEntry) -> None:
|
def update(self, data: HistoryEntry) -> None:
|
||||||
assert isinstance(data.flake.flake_url, FlakeId)
|
|
||||||
self.data = data
|
self.data = data
|
||||||
|
|
||||||
def _on_vm_status_changed(self, source: "VMObject") -> None:
|
def _on_vm_status_changed(self, source: "VMObject") -> None:
|
||||||
@@ -181,14 +179,12 @@ class VMObject(GObject.Object):
|
|||||||
return GLib.SOURCE_REMOVE
|
return GLib.SOURCE_REMOVE
|
||||||
|
|
||||||
def __start(self) -> None:
|
def __start(self) -> None:
|
||||||
assert isinstance(self.data.flake.vm.flake_url, FlakeId)
|
|
||||||
with self._create_machine() as machine:
|
with self._create_machine() as machine:
|
||||||
# Start building VM
|
# Start building VM
|
||||||
tstart = datetime.now()
|
tstart = datetime.now()
|
||||||
log.info(f"Building VM {self.get_id()}")
|
log.info(f"Building VM {self.get_id()}")
|
||||||
log_dir = Path(str(self.log_dir.name))
|
log_dir = Path(str(self.log_dir.name))
|
||||||
|
|
||||||
assert isinstance(self.data.flake.vm.flake_url, FlakeId)
|
|
||||||
# Start the build process
|
# Start the build process
|
||||||
self.build_process = spawn(
|
self.build_process = spawn(
|
||||||
on_except=None,
|
on_except=None,
|
||||||
@@ -275,7 +271,6 @@ class VMObject(GObject.Object):
|
|||||||
self.emit("vm_status_changed", self)
|
self.emit("vm_status_changed", self)
|
||||||
return
|
return
|
||||||
log.debug(f"VM state dir {self.log_dir.name}")
|
log.debug(f"VM state dir {self.log_dir.name}")
|
||||||
assert isinstance(self.data.flake.vm.flake_url, FlakeId)
|
|
||||||
self._start_thread = threading.Thread(target=self.__start)
|
self._start_thread = threading.Thread(target=self.__start)
|
||||||
self._start_thread.start()
|
self._start_thread.start()
|
||||||
|
|
||||||
|
|||||||
@@ -110,12 +110,8 @@ class ClanStore:
|
|||||||
def log_details(gfile: Gio.File) -> None:
|
def log_details(gfile: Gio.File) -> None:
|
||||||
self.log_details(vm, gfile)
|
self.log_details(vm, gfile)
|
||||||
|
|
||||||
assert isinstance(entry.flake.flake_url, FlakeId)
|
|
||||||
|
|
||||||
vm = VMObject(icon=icon, data=entry, build_log_cb=log_details)
|
vm = VMObject(icon=icon, data=entry, build_log_cb=log_details)
|
||||||
assert isinstance(vm.data.flake.flake_url, FlakeId)
|
|
||||||
self.push(vm)
|
self.push(vm)
|
||||||
assert isinstance(vm.data.flake.flake_url, FlakeId)
|
|
||||||
|
|
||||||
def log_details(self, vm: VMObject, gfile: Gio.File) -> None:
|
def log_details(self, vm: VMObject, gfile: Gio.File) -> None:
|
||||||
views = ViewStack.use().view
|
views = ViewStack.use().view
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import logging
|
|||||||
import threading
|
import threading
|
||||||
|
|
||||||
import gi
|
import gi
|
||||||
from clan_cli.clan_uri import FlakeId
|
|
||||||
from clan_cli.history.list import list_history
|
from clan_cli.history.list import list_history
|
||||||
|
|
||||||
from clan_vm_manager.components.interfaces import ClanConfig
|
from clan_vm_manager.components.interfaces import ClanConfig
|
||||||
@@ -74,7 +73,6 @@ class MainWindow(Adw.ApplicationWindow):
|
|||||||
# Execute `clan flakes add <path>` to democlan for this to work
|
# Execute `clan flakes add <path>` to democlan for this to work
|
||||||
# TODO: Make list_history a generator function
|
# TODO: Make list_history a generator function
|
||||||
for entry in list_history():
|
for entry in list_history():
|
||||||
assert isinstance(entry.flake.flake_url, FlakeId)
|
|
||||||
GLib.idle_add(ClanStore.use().create_vm_task, entry)
|
GLib.idle_add(ClanStore.use().create_vm_task, entry)
|
||||||
|
|
||||||
GLib.idle_add(self._set_clan_store_ready)
|
GLib.idle_add(self._set_clan_store_ready)
|
||||||
|
|||||||
Reference in New Issue
Block a user