core/tools: use gui notification for qvm-start

dom0/qvm-core: propagated notify_function to qrexec
This commit is contained in:
Olivier Medoc 2013-01-10 19:19:15 +01:00 committed by Marek Marczykowski
parent 6d6c744f2c
commit 4fa76a5f79
2 changed files with 13 additions and 7 deletions

View File

@ -1347,7 +1347,7 @@ class QubesVm(object):
notify_function ("info", "Starting the '{0}' VM...".format(self.name))
elif verbose:
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:
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:
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:
print >> sys.stderr, "--> Starting the qrexec daemon..."
xid = self.get_xid()
@ -1460,7 +1460,7 @@ class QubesVm(object):
self.force_shutdown()
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:
return
@ -1540,13 +1540,13 @@ class QubesVm(object):
qmemman_client.close()
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:
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'):
self.start_guid(verbose=verbose)
self.start_guid(verbose=verbose,notify_function=notify_function)
if preparing_dvm:
if verbose:

View File

@ -38,6 +38,12 @@ def tray_notify(str, label, timeout = 3000):
def tray_notify_error(str, timeout = 3000):
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():
usage = "usage: %prog [options] <vm-name>"
parser = OptionParser (usage)
@ -103,7 +109,7 @@ def main():
try:
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:
if options.tray:
tray_notify_error(str(err))