clan-vm-manager: Fix ClanUrl not pickable

This commit is contained in:
Qubasa
2024-03-08 23:23:18 +07:00
parent 1e7f63fb05
commit f4f3176374
6 changed files with 65 additions and 60 deletions

View File

@@ -13,7 +13,7 @@ from typing import IO, ClassVar
import gi
from clan_cli import vms
from clan_cli.clan_uri import ClanURI, ClanUrl
from clan_cli.clan_uri import ClanURI
from clan_cli.history.add import HistoryEntry
from clan_cli.machines.machines import Machine
@@ -115,17 +115,16 @@ class VMObject(GObject.Object):
uri = ClanURI.from_str(
url=self.data.flake.flake_url, machine_name=self.data.flake.flake_attr
)
match uri.url:
case ClanUrl.LOCAL.value(path):
self.machine = Machine(
name=self.data.flake.flake_attr,
flake=path, # type: ignore
)
case ClanUrl.REMOTE.value(url):
self.machine = Machine(
name=self.data.flake.flake_attr,
flake=url, # type: ignore
)
if uri.url.is_local():
self.machine = Machine(
name=self.data.flake.flake_attr,
flake=Path(str(uri.url)),
)
if uri.url.is_remote():
self.machine = Machine(
name=self.data.flake.flake_attr,
flake=str(uri.url),
)
yield self.machine
self.machine = None