clan-vm-manager: Fixed vm-manager start
This commit is contained in:
parent
f183e759d3
commit
af441e71d2
@ -1,37 +1,39 @@
|
||||
import argparse
|
||||
import sys
|
||||
|
||||
import gi
|
||||
|
||||
from .app import Application
|
||||
|
||||
gi.require_version("Gtk", "3.0")
|
||||
|
||||
|
||||
|
||||
def join_command(args: argparse.Namespace) -> None:
|
||||
print("Joining the flake")
|
||||
print(args.clan_uri)
|
||||
|
||||
app = Application()
|
||||
return app.run()
|
||||
|
||||
def register_join_parser(parser: argparse.ArgumentParser) -> None:
|
||||
parser.add_argument("clan_uri", type=str, help="machine in the flake to run")
|
||||
parser.add_argument("clan_uri", type=str, help="clan URI to join")
|
||||
parser.set_defaults(func=join_command)
|
||||
|
||||
|
||||
def start_app(args: argparse.Namespace) -> None:
|
||||
app = Application(args)
|
||||
return app.run(sys.argv)
|
||||
app = Application()
|
||||
return app.run()
|
||||
|
||||
|
||||
def main() -> None:
|
||||
parser = argparse.ArgumentParser(description="clan-vm-manager")
|
||||
|
||||
# Add join subcommand
|
||||
subparser = parser.add_subparsers(
|
||||
title="command",
|
||||
description="command to execute",
|
||||
help="the command to execute",
|
||||
required=True,
|
||||
)
|
||||
register_join_parser(subparser.add_parser("join", help="join a clan"))
|
||||
|
||||
# Executed when no command is given
|
||||
parser.set_defaults(func=start_app)
|
||||
args = parser.parse_args()
|
||||
args.func(args)
|
||||
|
@ -91,7 +91,7 @@ class MainWindow(Gtk.ApplicationWindow):
|
||||
|
||||
|
||||
class Application(Gtk.Application):
|
||||
def __init__(self, args: argparse.Namespace) -> None:
|
||||
def __init__(self) -> None:
|
||||
super().__init__(
|
||||
application_id=constants["APPID"], flags=Gio.ApplicationFlags.FLAGS_NONE
|
||||
)
|
||||
|
@ -60,13 +60,15 @@ class VMBase:
|
||||
|
||||
def run(self) -> None:
|
||||
print(f"Running VM {self.name}")
|
||||
from clan_cli import vms
|
||||
import asyncio
|
||||
# raise Exception("Cannot run VMs yet")
|
||||
# vm = asyncio.run(
|
||||
# vms.run.inspect_vm(flake_url=self._path, flake_attr="defaultVM")
|
||||
# )
|
||||
# task = vms.run.run_vm(vm)
|
||||
# for line in task.log_lines():
|
||||
# print(line, end="")
|
||||
vm = asyncio.run(
|
||||
vms.run.inspect_vm(flake_url=self._path, flake_attr="defaultVM")
|
||||
)
|
||||
task = vms.run.run_vm(vm)
|
||||
for line in task.log_lines():
|
||||
print(line, end="")
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
|
@ -13,6 +13,8 @@ mkShell {
|
||||
# prepend clan-cli for development
|
||||
export PYTHONPATH=../clan-cli:$PYTHONPATH
|
||||
|
||||
ln -sf ${clan-vm-manager} result
|
||||
|
||||
set -euox
|
||||
# install desktop file
|
||||
cp -f ${clan-vm-manager}/share/applications/clan-vm-manager.desktop ~/.local/share/applications/clan-vm-manager.desktop
|
||||
|
Loading…
Reference in New Issue
Block a user