From 89361ef693f1c4ea1d36d8876fccee7a51827639 Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Sun, 1 Mar 2009 12:34:23 +0000 Subject: [PATCH] If the notification system doesn't support actions, download anyway This is required on Ubuntu/Jaunty, since they have removed support for the actions part of the specification. --- zeroinstall/injector/background.py | 19 ++++++++++++++----- zeroinstall/injector/cli.py | 3 +++ 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/zeroinstall/injector/background.py b/zeroinstall/injector/background.py index 6f8d75a..4041e6d 100644 --- a/zeroinstall/injector/background.py +++ b/zeroinstall/injector/background.py @@ -10,7 +10,7 @@ import sys, os from logging import info, warn from zeroinstall.support import tasks from zeroinstall.injector.iface_cache import iface_cache -from zeroinstall.injector import handler +from zeroinstall.injector import handler, namespaces # Copyright (C) 2009, Thomas Leonard # See the README file for details, or visit http://0install.net. @@ -35,6 +35,7 @@ class BackgroundHandler(handler.Handler): self.title = title self.notification_service = None self.network_manager = None + self.notification_service_caps = [] try: import dbus @@ -58,7 +59,8 @@ class BackgroundHandler(handler.Handler): old_stderr = sys.stderr sys.stderr = None try: - self.notification_service.GetCapabilities() + self.notification_service_caps = [str(s) for s in + self.notification_service.GetCapabilities()] finally: sys.stderr = old_stderr except Exception, ex: @@ -118,6 +120,9 @@ class BackgroundHandler(handler.Handler): hints, timeout * 1000) + def have_actions_support(self): + return 'actions' in self.notification_service_caps + def _detach(): """Fork a detached grandchild. @return: True if we are the original.""" @@ -174,10 +179,14 @@ def _check_for_updates(policy, verbose): policy.handler.notify("Zero Install", "No updates to download.", timeout = 1) sys.exit(0) - if not policy.handler.notification_service: + if not policy.handler.have_actions_support(): # Can't ask the user to choose, so just notify them - policy.handler.notify("Zero Install", "Updates ready to download for '%s'." % root_iface) - sys.exit(0) + # In particular, Ubuntu/Jaunty doesn't support actions + policy.handler.notify("Zero Install", + "Updates ready to download for '%s'." % root_iface, + timeout = 1) + _exec_gui(policy.root, '--refresh', '--download-only', '--systray') + sys.exit(1) notification_closed = tasks.Blocker("wait for notification response") diff --git a/zeroinstall/injector/cli.py b/zeroinstall/injector/cli.py index 67c0298..59f0534 100644 --- a/zeroinstall/injector/cli.py +++ b/zeroinstall/injector/cli.py @@ -218,6 +218,8 @@ def _normal_mode(options, args): gui_args.append('--download-only') if options.refresh: gui_args.append('--refresh') + if options.systray: + gui_args.append('--systray') if options.not_before: gui_args.insert(0, options.not_before) gui_args.insert(0, '--not-before') @@ -322,6 +324,7 @@ def main(command_args): parser.add_option("-r", "--refresh", help="refresh all used interfaces", action='store_true') parser.add_option("", "--set-selections", help="run versions specified in XML file", metavar='FILE') parser.add_option("-s", "--source", help="select source code", action='store_true') + parser.add_option("", "--systray", help="download in the background", action='store_true') parser.add_option("-v", "--verbose", help="more verbose output", action='count') parser.add_option("-V", "--version", help="display version information", action='store_true') parser.add_option("-w", "--wrapper", help="execute program using a debugger, etc", metavar='COMMAND') -- 2.11.4.GIT