dom0/qvm-tools: add GUI (tray balloon) error reporing to qvm-start and extend it in qvm-run (#534)
This commit is contained in:
parent
c5cc6620d3
commit
9927244670
@ -87,6 +87,8 @@ def vm_run_cmd(vm, cmd, options):
|
||||
notify_function = tray_notify_generic if options.tray else None,
|
||||
passio = options.passio, localcmd = options.localcmd)
|
||||
except QubesException as err:
|
||||
if options.tray:
|
||||
tray_notify_error(str(err))
|
||||
print >> sys.stderr, "ERROR: %s" % str(err)
|
||||
exit(1)
|
||||
|
||||
|
@ -26,13 +26,24 @@ from optparse import OptionParser
|
||||
import subprocess
|
||||
import os
|
||||
import sys
|
||||
import dbus
|
||||
|
||||
qubes_guid_path = "/usr/bin/qubes_guid"
|
||||
|
||||
notify_object = None
|
||||
|
||||
def tray_notify(str, label, timeout = 3000):
|
||||
notify_object.Notify("Qubes", 0, label.icon, "Qubes", str, [], [], timeout, dbus_interface="org.freedesktop.Notifications")
|
||||
|
||||
def tray_notify_error(str, timeout = 3000):
|
||||
notify_object.Notify("Qubes", 0, "dialog-error", "Qubes", str, [], [], timeout, dbus_interface="org.freedesktop.Notifications")
|
||||
|
||||
def main():
|
||||
usage = "usage: %prog [options] <vm-name>"
|
||||
parser = OptionParser (usage)
|
||||
parser.add_option ("-q", "--quiet", action="store_false", dest="verbose", default=True)
|
||||
parser.add_option ("--tray", action="store_true", dest="tray", default=False,
|
||||
help="Use tray notifications instead of stdout" )
|
||||
parser.add_option ("--no-guid", action="store_true", dest="noguid", default=False,
|
||||
help="Do not start the GUId (ignored)")
|
||||
parser.add_option ("--drive", dest="drive", default=None,
|
||||
@ -53,6 +64,10 @@ def main():
|
||||
parser.error ("You must specify VM name!")
|
||||
vmname = args[0]
|
||||
|
||||
if options.tray:
|
||||
global notify_object
|
||||
notify_object = dbus.SessionBus().get_object("org.freedesktop.Notifications", "/org/freedesktop/Notifications")
|
||||
|
||||
qvm_collection = QubesVmCollection()
|
||||
qvm_collection.lock_db_for_reading()
|
||||
qvm_collection.load()
|
||||
@ -72,8 +87,11 @@ def main():
|
||||
try:
|
||||
vm.verify_files()
|
||||
xid = vm.start(verbose=options.verbose, preparing_dvm=options.preparing_dvm, start_guid=not options.noguid)
|
||||
except (IOError, OSError, QubesException) as err:
|
||||
print >> sys.stderr, "ERROR: {0}".format(err)
|
||||
except (IOError, OSError, QubesException, MemoryError) as err:
|
||||
if options.tray:
|
||||
tray_notify_error(str(err))
|
||||
else:
|
||||
print >> sys.stderr, "ERROR: {0}".format(err)
|
||||
exit (1)
|
||||
|
||||
if options.debug:
|
||||
|
Loading…
Reference in New Issue
Block a user