Merge pull request 'Added demo.sh to prepare demo environment' (#777) from Qubasa-origin/Qubasa-fix into main

This commit is contained in:
clan-bot
2024-01-30 08:04:49 +00:00
3 changed files with 33 additions and 11 deletions

View File

@@ -72,13 +72,12 @@ class VM(GObject.Object):
threading.Thread(target=self.__start).start() threading.Thread(target=self.__start).start()
if self._watcher_id == 0: # Every 50ms check if the VM is still running
# Every 50ms check if the VM is still running self._watcher_id = GLib.timeout_add(50, self._vm_watcher_task)
self._watcher_id = GLib.timeout_add(50, self._vm_watcher_task)
if self._watcher_id == 0: if self._watcher_id == 0:
log.error("Failed to add watcher") log.error("Failed to add watcher")
raise ClanError("Failed to add watcher") raise ClanError("Failed to add watcher")
def _vm_watcher_task(self) -> bool: def _vm_watcher_task(self) -> bool:
if self.is_running() != self._last_liveness: if self.is_running() != self._last_liveness:
@@ -88,6 +87,7 @@ class VM(GObject.Object):
# If the VM was running and now it is not, remove the watcher # If the VM was running and now it is not, remove the watcher
if prev_liveness and not self.is_running(): if prev_liveness and not self.is_running():
print("===>Removing watcher")
return GLib.SOURCE_REMOVE return GLib.SOURCE_REMOVE
return GLib.SOURCE_CONTINUE return GLib.SOURCE_CONTINUE

View File

@@ -189,8 +189,9 @@ class ClanList(Gtk.Box):
def vm_status_changed(self, switch: Gtk.Switch, vm: VM, _vm: VM) -> None: def vm_status_changed(self, switch: Gtk.Switch, vm: VM, _vm: VM) -> None:
switch.set_active(vm.is_running()) switch.set_active(vm.is_running())
switch.set_state(vm.is_running()) switch.set_state(vm.is_running())
print("====> Set switch to", vm.is_running())
if not vm.is_running() and vm.process.proc.exitcode != 0: exitc = vm.process.proc.exitcode
print("VM exited with error. Exitcode:", vm.process.proc.exitcode) if not vm.is_running() and exitc != 0 and exitc != -15:
# print(vm.read_log()) print("VM exited with error. Exitcode:", exitc)
# self.show_error_dialog(vm.read_log()) print(vm.read_log())
self.show_error_dialog(vm.read_log())

21
pkgs/clan-vm-manager/demo.sh Executable file
View File

@@ -0,0 +1,21 @@
#!/usr/bin/env bash
rm -r ~/.config/clan
clan history add "clan://~/Projects/democlan#syncthing-peer1"
clan history add "clan://~/Projects/democlan#syncthing-peer2"
clan history add "clan://~/Projects/democlan#moonlight-peer1"
clan history add "clan://~/Projects/democlan#moonlight-peer2"
clear
cat << EOF
Open up this link in a browser:
"clan://~/Projects/democlan#syncthing-introducer"
EOF
cat << EOF
Execute this command to show waypipe windows:
$ clan --flake ~/Projects/democlan/ vms run --wayland wayland
EOF