core/tools: use gui notification for qvm-start
dom0/qvm-core: propagated notify_function to qrexec
This commit is contained in:
parent
6d6c744f2c
commit
4fa76a5f79
@ -1347,7 +1347,7 @@ class QubesVm(object):
|
|||||||
notify_function ("info", "Starting the '{0}' VM...".format(self.name))
|
notify_function ("info", "Starting the '{0}' VM...".format(self.name))
|
||||||
elif verbose:
|
elif verbose:
|
||||||
print >> sys.stderr, "Starting the VM '{0}'...".format(self.name)
|
print >> sys.stderr, "Starting the VM '{0}'...".format(self.name)
|
||||||
xid = self.start(verbose=verbose)
|
xid = self.start(verbose=verbose, notify_function=notify_function)
|
||||||
|
|
||||||
except (IOError, OSError, QubesException) as err:
|
except (IOError, OSError, QubesException) as err:
|
||||||
raise QubesException("Error while starting the '{0}' VM: {1}".format(self.name, err))
|
raise QubesException("Error while starting the '{0}' VM: {1}".format(self.name, err))
|
||||||
@ -1449,7 +1449,7 @@ class QubesVm(object):
|
|||||||
if notify_function is not None:
|
if notify_function is not None:
|
||||||
notify_function("error", "ERROR: Cannot start the Qubes Clipboard Notifier!")
|
notify_function("error", "ERROR: Cannot start the Qubes Clipboard Notifier!")
|
||||||
|
|
||||||
def start_qrexec_daemon(self, verbose = False):
|
def start_qrexec_daemon(self, verbose = False, notify_function = None):
|
||||||
if verbose:
|
if verbose:
|
||||||
print >> sys.stderr, "--> Starting the qrexec daemon..."
|
print >> sys.stderr, "--> Starting the qrexec daemon..."
|
||||||
xid = self.get_xid()
|
xid = self.get_xid()
|
||||||
@ -1460,7 +1460,7 @@ class QubesVm(object):
|
|||||||
self.force_shutdown()
|
self.force_shutdown()
|
||||||
raise OSError ("ERROR: Cannot execute qrexec_daemon!")
|
raise OSError ("ERROR: Cannot execute qrexec_daemon!")
|
||||||
|
|
||||||
def start(self, debug_console = False, verbose = False, preparing_dvm = False, start_guid = True):
|
def start(self, debug_console = False, verbose = False, preparing_dvm = False, start_guid = True, notify_function = None):
|
||||||
if dry_run:
|
if dry_run:
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -1540,13 +1540,13 @@ class QubesVm(object):
|
|||||||
qmemman_client.close()
|
qmemman_client.close()
|
||||||
|
|
||||||
if self._start_guid_first and start_guid and not preparing_dvm and os.path.exists('/var/run/shm.id'):
|
if self._start_guid_first and start_guid and not preparing_dvm and os.path.exists('/var/run/shm.id'):
|
||||||
self.start_guid(verbose=verbose)
|
self.start_guid(verbose=verbose,notify_function=notify_function)
|
||||||
|
|
||||||
if not preparing_dvm:
|
if not preparing_dvm:
|
||||||
self.start_qrexec_daemon(verbose=verbose)
|
self.start_qrexec_daemon(verbose=verbose,notify_function=notify_function)
|
||||||
|
|
||||||
if not self._start_guid_first and start_guid and not preparing_dvm and os.path.exists('/var/run/shm.id'):
|
if not self._start_guid_first and start_guid and not preparing_dvm and os.path.exists('/var/run/shm.id'):
|
||||||
self.start_guid(verbose=verbose)
|
self.start_guid(verbose=verbose,notify_function=notify_function)
|
||||||
|
|
||||||
if preparing_dvm:
|
if preparing_dvm:
|
||||||
if verbose:
|
if verbose:
|
||||||
|
@ -38,6 +38,12 @@ def tray_notify(str, label, timeout = 3000):
|
|||||||
def tray_notify_error(str, timeout = 3000):
|
def tray_notify_error(str, timeout = 3000):
|
||||||
notify_object.Notify("Qubes", 0, "dialog-error", "Qubes", str, [], [], timeout, dbus_interface="org.freedesktop.Notifications")
|
notify_object.Notify("Qubes", 0, "dialog-error", "Qubes", str, [], [], timeout, dbus_interface="org.freedesktop.Notifications")
|
||||||
|
|
||||||
|
def tray_notify_generic(level, str):
|
||||||
|
if level == "info":
|
||||||
|
tray_notify(str, label=vm.label)
|
||||||
|
elif level == "error":
|
||||||
|
tray_notify_error(str)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
usage = "usage: %prog [options] <vm-name>"
|
usage = "usage: %prog [options] <vm-name>"
|
||||||
parser = OptionParser (usage)
|
parser = OptionParser (usage)
|
||||||
@ -103,7 +109,7 @@ def main():
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
vm.verify_files()
|
vm.verify_files()
|
||||||
xid = vm.start(verbose=options.verbose, preparing_dvm=options.preparing_dvm, start_guid=not options.noguid)
|
xid = vm.start(verbose=options.verbose, preparing_dvm=options.preparing_dvm, start_guid=not options.noguid, notify_function=tray_notify_generic if options.tray else None)
|
||||||
except (IOError, OSError, QubesException, MemoryError) as err:
|
except (IOError, OSError, QubesException, MemoryError) as err:
|
||||||
if options.tray:
|
if options.tray:
|
||||||
tray_notify_error(str(err))
|
tray_notify_error(str(err))
|
||||||
|
Loading…
Reference in New Issue
Block a user