clan_vm_manager: Added suffix task to glib task functions
This commit is contained in:
parent
216e5a53d4
commit
78a50c5d74
@ -26,7 +26,7 @@ class JoinValue(GObject.Object):
|
|||||||
url: ClanURI
|
url: ClanURI
|
||||||
entry: HistoryEntry | None
|
entry: HistoryEntry | None
|
||||||
|
|
||||||
def _join_finished(self) -> bool:
|
def _join_finished_task(self) -> bool:
|
||||||
self.emit("join_finished", self)
|
self.emit("join_finished", self)
|
||||||
return GLib.SOURCE_REMOVE
|
return GLib.SOURCE_REMOVE
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ class JoinValue(GObject.Object):
|
|||||||
def __join(self) -> None:
|
def __join(self) -> None:
|
||||||
new_entry = add_history(self.url)
|
new_entry = add_history(self.url)
|
||||||
self.entry = new_entry
|
self.entry = new_entry
|
||||||
GLib.idle_add(self._join_finished)
|
GLib.idle_add(self._join_finished_task)
|
||||||
|
|
||||||
def join(self) -> None:
|
def join(self) -> None:
|
||||||
threading.Thread(target=self.__join).start()
|
threading.Thread(target=self.__join).start()
|
||||||
|
@ -37,7 +37,7 @@ class VM(GObject.Object):
|
|||||||
"vm_status_changed": (GObject.SignalFlags.RUN_FIRST, None, [GObject.Object])
|
"vm_status_changed": (GObject.SignalFlags.RUN_FIRST, None, [GObject.Object])
|
||||||
}
|
}
|
||||||
|
|
||||||
def vm_status_changed(self) -> bool:
|
def vm_status_changed_task(self) -> bool:
|
||||||
self.emit("vm_status_changed", self)
|
self.emit("vm_status_changed", self)
|
||||||
return GLib.SOURCE_REMOVE
|
return GLib.SOURCE_REMOVE
|
||||||
|
|
||||||
@ -130,7 +130,7 @@ class VM(GObject.Object):
|
|||||||
yield self.machine
|
yield self.machine
|
||||||
self.machine = None
|
self.machine = None
|
||||||
|
|
||||||
def _pulse_progress_bar(self) -> bool:
|
def _pulse_progress_bar_task(self) -> bool:
|
||||||
if self.progress_bar.is_visible():
|
if self.progress_bar.is_visible():
|
||||||
self.progress_bar.pulse()
|
self.progress_bar.pulse()
|
||||||
return GLib.SOURCE_CONTINUE
|
return GLib.SOURCE_CONTINUE
|
||||||
@ -150,7 +150,7 @@ class VM(GObject.Object):
|
|||||||
machine=machine,
|
machine=machine,
|
||||||
tmpdir=log_dir,
|
tmpdir=log_dir,
|
||||||
)
|
)
|
||||||
GLib.idle_add(self.vm_status_changed)
|
GLib.idle_add(self.vm_status_changed_task)
|
||||||
|
|
||||||
# Start the logs watcher
|
# Start the logs watcher
|
||||||
self._logs_id = GLib.timeout_add(
|
self._logs_id = GLib.timeout_add(
|
||||||
@ -162,7 +162,7 @@ class VM(GObject.Object):
|
|||||||
|
|
||||||
# Start the progress bar and show it
|
# Start the progress bar and show it
|
||||||
self.progress_bar.show()
|
self.progress_bar.show()
|
||||||
self.prog_bar_id = GLib.timeout_add(100, self._pulse_progress_bar)
|
self.prog_bar_id = GLib.timeout_add(100, self._pulse_progress_bar_task)
|
||||||
if self.prog_bar_id == 0:
|
if self.prog_bar_id == 0:
|
||||||
log.error("Couldn't spawn a progess bar task")
|
log.error("Couldn't spawn a progess bar task")
|
||||||
|
|
||||||
@ -175,7 +175,7 @@ class VM(GObject.Object):
|
|||||||
# Check if the VM was built successfully
|
# Check if the VM was built successfully
|
||||||
if self.build_process.proc.exitcode != 0:
|
if self.build_process.proc.exitcode != 0:
|
||||||
log.error(f"Failed to build VM {self.get_id()}")
|
log.error(f"Failed to build VM {self.get_id()}")
|
||||||
GLib.idle_add(self.vm_status_changed)
|
GLib.idle_add(self.vm_status_changed_task)
|
||||||
return
|
return
|
||||||
log.info(f"Successfully built VM {self.get_id()}")
|
log.info(f"Successfully built VM {self.get_id()}")
|
||||||
|
|
||||||
@ -187,7 +187,7 @@ class VM(GObject.Object):
|
|||||||
vm=self.data.flake.vm,
|
vm=self.data.flake.vm,
|
||||||
)
|
)
|
||||||
log.debug(f"Started VM {self.get_id()}")
|
log.debug(f"Started VM {self.get_id()}")
|
||||||
GLib.idle_add(self.vm_status_changed)
|
GLib.idle_add(self.vm_status_changed_task)
|
||||||
|
|
||||||
# Start the logs watcher
|
# Start the logs watcher
|
||||||
self._logs_id = GLib.timeout_add(50, self._get_logs_task, self.vm_process)
|
self._logs_id = GLib.timeout_add(50, self._get_logs_task, self.vm_process)
|
||||||
@ -198,7 +198,7 @@ class VM(GObject.Object):
|
|||||||
# Wait for the VM to stop
|
# Wait for the VM to stop
|
||||||
self.vm_process.proc.join()
|
self.vm_process.proc.join()
|
||||||
log.debug(f"VM {self.get_id()} has stopped")
|
log.debug(f"VM {self.get_id()} has stopped")
|
||||||
GLib.idle_add(self.vm_status_changed)
|
GLib.idle_add(self.vm_status_changed_task)
|
||||||
|
|
||||||
def start(self) -> None:
|
def start(self) -> None:
|
||||||
if self.is_running():
|
if self.is_running():
|
||||||
@ -274,7 +274,7 @@ class VM(GObject.Object):
|
|||||||
|
|
||||||
# Try 20 times to stop the VM
|
# Try 20 times to stop the VM
|
||||||
time.sleep(self.KILL_TIMEOUT / 20)
|
time.sleep(self.KILL_TIMEOUT / 20)
|
||||||
GLib.idle_add(self.vm_status_changed)
|
GLib.idle_add(self.vm_status_changed_task)
|
||||||
log.debug(f"VM {self.get_id()} has stopped")
|
log.debug(f"VM {self.get_id()} has stopped")
|
||||||
|
|
||||||
def shutdown(self) -> None:
|
def shutdown(self) -> None:
|
||||||
@ -348,6 +348,7 @@ class VMs:
|
|||||||
return GLib.SOURCE_REMOVE
|
return GLib.SOURCE_REMOVE
|
||||||
|
|
||||||
def push_history_entry(self, entry: HistoryEntry) -> None:
|
def push_history_entry(self, entry: HistoryEntry) -> None:
|
||||||
|
# TODO: We shouldn't do this here but in the list view
|
||||||
if entry.flake.icon is None:
|
if entry.flake.icon is None:
|
||||||
icon = assets.loc / "placeholder.jpeg"
|
icon = assets.loc / "placeholder.jpeg"
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user