From 05a9127d49e4e53bc67670ad6f621e43cf90ff7e Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Mon, 31 Aug 2009 17:10:53 +0100 Subject: [PATCH] Always run the built-in copy of the GUI Originally, the GUI was a separate program that 0launch downloaded when needed. Later, a copy of the GUI was bundled to improve the experience for first-time use, but updates were downloaded. In recent years, the only purpose of this has been to add new GPG keys to the hints database. Having the GUI as a separate program added unnecessary complexity, made it harder to change the API and caused problems with translations. Now that we contact a key information server to get the hints, there is no longer any need to update the GUI on its own, so this code has been removed. "0launch -g" now just opens the preferences dialog box. --- ZeroInstall.xml | 1 - setup.py | 1 - tests/basetest.py | 16 +++++++++++++--- tests/test-gui.xml | 11 ----------- zeroinstall/0launch-gui/0launch-gui | 8 +++++++- zeroinstall/0launch-gui/ZeroInstall-GUI.xml | 15 --------------- zeroinstall/0launch-gui/gui.py | 3 +-- zeroinstall/0launch-gui/main.py | 16 +++++++++++++--- zeroinstall/0launch-gui/preferences.py | 1 + zeroinstall/helpers.py | 26 +++++++------------------- zeroinstall/injector/autopolicy.py | 2 +- zeroinstall/injector/background.py | 2 +- zeroinstall/injector/cli.py | 8 +++----- zeroinstall/injector/namespaces.py | 4 ---- zeroinstall/injector/policy.py | 6 +----- zeroinstall/injector/reader.py | 8 +------- zeroinstall/zerostore/manifest.py | 2 +- 17 files changed, 50 insertions(+), 80 deletions(-) delete mode 100644 tests/test-gui.xml delete mode 100644 zeroinstall/0launch-gui/ZeroInstall-GUI.xml diff --git a/ZeroInstall.xml b/ZeroInstall.xml index 50acb0b..600bd42 100644 --- a/ZeroInstall.xml +++ b/ZeroInstall.xml @@ -31,7 +31,6 @@ requires first uninstalling another. sed -i "s/^version = '.*'$/version = '$RELEASE_VERSION'/" zeroinstall/__init__.py sed -i "s/^version = '.*'$/version = '$RELEASE_VERSION'/" zeroinstall/0launch-gui/gui.py - 0launch http://0install.net/2006/interfaces/0publish --set-released=today --set-version="$RELEASE_VERSION" zeroinstall/0launch-gui/ZeroInstall-GUI.xml make translations diff --git a/setup.py b/setup.py index da3d64a..39d2d0b 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,6 @@ class build_with_data(build_py): package_data_files = [ "zeroinstall/0launch-gui/README", "zeroinstall/0launch-gui/0launch-gui", - "zeroinstall/0launch-gui/ZeroInstall-GUI.xml", "zeroinstall/0launch-gui/zero-install.ui", "zeroinstall/gtkui/desktop.ui", "zeroinstall/gtkui/cache.ui", diff --git a/tests/basetest.py b/tests/basetest.py index ecfc199..663a466 100755 --- a/tests/basetest.py +++ b/tests/basetest.py @@ -11,10 +11,10 @@ warnings.filterwarnings("ignore", category = DeprecationWarning) os.environ['HOME'] = '/home/idontexist' sys.path.insert(0, '..') -from zeroinstall.injector import namespaces, qdom +from zeroinstall.injector import qdom from zeroinstall.injector import iface_cache, download, distro from zeroinstall.zerostore import Store; Store._add_with_helper = lambda *unused: False -from zeroinstall import support +from zeroinstall import support, helpers from zeroinstall.support import basedir dpkgdir = os.path.join(os.path.dirname(__file__), 'dpkg') @@ -24,6 +24,17 @@ empty_feed = qdom.parse(StringIO.StringIO(""" - - ZeroInstall-Test-GUI - dummy GUI interface for testing - - Just for the unit tests! - - - - - diff --git a/zeroinstall/0launch-gui/0launch-gui b/zeroinstall/0launch-gui/0launch-gui index c48e100..8901a24 100755 --- a/zeroinstall/0launch-gui/0launch-gui +++ b/zeroinstall/0launch-gui/0launch-gui @@ -2,6 +2,7 @@ # Copyright (C) 2009, Thomas Leonard # See the README file for details, or visit http://0install.net. import os, sys +from os.path import dirname import gettext import locale @@ -17,7 +18,12 @@ gettext.install('zero-install', unicode=True, names=['ngettext']) # before adding the containing directory to sys.path, which means we don't see # the .pyc files. If run as root, this also causes .pyc files to be created in # the source directory, leaving a mess when the package is removed. -sys.path.insert(0, os.path.dirname(__file__)) +_mydir = dirname(__file__) +sys.path.insert(0, _mydir) + +# Make sure we're using our bundled copy of Zero Install, not the system version +# (if different) +sys.path.insert(0, dirname(dirname(_mydir))) import pygtk; pygtk.require('2.0') from gtk import glade diff --git a/zeroinstall/0launch-gui/ZeroInstall-GUI.xml b/zeroinstall/0launch-gui/ZeroInstall-GUI.xml deleted file mode 100644 index 03e4e60..0000000 --- a/zeroinstall/0launch-gui/ZeroInstall-GUI.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - ZeroInstall-GUI - graphical interface for the Zero Install injector - - The Zero Install GUI displays a window showing which versions of various components will be used when running a program, and allows you to alter various policy settings to affect the selection process. You can use this to mark particular versions of libraries as preferred, bugggy, etc. - - http://0install.net/injector.html - - - - - - diff --git a/zeroinstall/0launch-gui/gui.py b/zeroinstall/0launch-gui/gui.py index 15397f8..75999cc 100644 --- a/zeroinstall/0launch-gui/gui.py +++ b/zeroinstall/0launch-gui/gui.py @@ -1,11 +1,10 @@ # Copyright (C) 2009, Thomas Leonard # See the README file for details, or visit http://0install.net. -import gobject, sys +import gobject from zeroinstall.support import tasks from zeroinstall.injector import handler, download -import dialog version = '0.41' diff --git a/zeroinstall/0launch-gui/main.py b/zeroinstall/0launch-gui/main.py index 64586e4..c8d60cf 100644 --- a/zeroinstall/0launch-gui/main.py +++ b/zeroinstall/0launch-gui/main.py @@ -81,9 +81,20 @@ def run_gui(args): gtk.main() sys.exit(0) + handler = gui.GUIHandler() + if len(args) < 1: - parser.print_help() - sys.exit(1) + import preferences + # Once we separate configuration from Policy, this hack can go away + class DummyPolicy(Policy): + def recalculate(fetch_stale_interfaces = True): + pass + def solve_with_downloads(force = False): + pass + box = preferences.show_preferences(DummyPolicy('http://localhost/dummy', handler)) + box.connect('destroy', gtk.main_quit) + gtk.main() + sys.exit(0) interface_uri = args[0] @@ -100,7 +111,6 @@ def run_gui(args): widgets = dialog.Template('main') - handler = gui.GUIHandler() policy = Policy(interface_uri, handler, src = bool(options.source)) policy.target_arch = arch.get_architecture(options.os, options.cpu) root_iface = iface_cache.get_interface(interface_uri) diff --git a/zeroinstall/0launch-gui/preferences.py b/zeroinstall/0launch-gui/preferences.py index d8c92bd..0cee9a3 100644 --- a/zeroinstall/0launch-gui/preferences.py +++ b/zeroinstall/0launch-gui/preferences.py @@ -153,6 +153,7 @@ def show_preferences(policy): preferences_box.destroy() preferences_box = Preferences(policy) preferences_box.window.show() + return preferences_box.window gui_help = help_box.HelpBox(_("Zero Install Preferences Help"), (_('Overview'), '\n\n' + diff --git a/zeroinstall/helpers.py b/zeroinstall/helpers.py index d500dea..c96ccc3 100644 --- a/zeroinstall/helpers.py +++ b/zeroinstall/helpers.py @@ -12,11 +12,10 @@ from zeroinstall import _ def get_selections_gui(iface_uri, gui_args, test_callback = None): """Run the GUI to choose and download a set of implementations. - If the GUI itself is due for a check, refresh it first. The user may ask the GUI to submit a bug report about the program. In that case, the GUI may ask us to test it. test_callback is called in that case with the implementations to be tested; the callback will typically call L{zeroinstall.injector.run.test_selections} and return the result of that. - @param iface_uri: the required program + @param iface_uri: the required program, or None to show just the preferences dialog @type iface_uri: str @param gui_args: any additional arguments for the GUI itself @type gui_args: [str] @@ -26,24 +25,11 @@ def get_selections_gui(iface_uri, gui_args, test_callback = None): @rtype: L{zeroinstall.injector.selections.Selections} @since: 0.28 """ - from zeroinstall.injector import selections, autopolicy, namespaces, model, run, qdom + from zeroinstall.injector import selections, qdom from StringIO import StringIO - gui_policy = autopolicy.AutoPolicy(namespaces.injector_gui_uri) - if iface_uri != namespaces.injector_gui_uri and (gui_policy.need_download() or gui_policy.stale_feeds): - # The GUI itself needs updating. Do that first. - logging.info("The GUI could do with updating first.") - gui_sel = get_selections_gui(namespaces.injector_gui_uri, ['--refresh']) - if gui_sel is None: - logging.info("Aborted at user request") - return None # Aborted by user - else: - # Try to start the GUI without using the network. - gui_policy.freshness = 0 - gui_policy.network_use = model.network_offline - gui_policy.recalculate() - assert gui_policy.ready # Should always be some version available - gui_sel = selections.Selections(gui_policy) + from os.path import join, dirname + gui_exe = join(dirname(__file__), '0launch-gui', '0launch-gui') import socket cli, gui = socket.socketpair() @@ -58,7 +44,9 @@ def get_selections_gui(iface_uri, gui_args, test_callback = None): # We used to use pipes to support Python2.3... os.dup2(gui.fileno(), 1) os.dup2(gui.fileno(), 0) - run.execute_selections(gui_sel, gui_args + ['--', iface_uri]) + if iface_uri is not None: + gui_args = gui_args + ['--', iface_uri] + os.execvp(gui_exe, [gui_exe] + gui_args) except: import traceback traceback.print_exc(file = sys.stderr) diff --git a/zeroinstall/injector/autopolicy.py b/zeroinstall/injector/autopolicy.py index 6bfac79..4954e0c 100644 --- a/zeroinstall/injector/autopolicy.py +++ b/zeroinstall/injector/autopolicy.py @@ -14,7 +14,7 @@ is also the policy used to run the injector's GUI. from zeroinstall import _ from logging import info -from zeroinstall.injector import model, policy, run +from zeroinstall.injector import policy, run from zeroinstall.injector.handler import Handler class AutoPolicy(policy.Policy): diff --git a/zeroinstall/injector/background.py b/zeroinstall/injector/background.py index 01a097b..a18dc24 100644 --- a/zeroinstall/injector/background.py +++ b/zeroinstall/injector/background.py @@ -14,7 +14,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, namespaces +from zeroinstall.injector import handler def _escape_xml(s): return s.replace('&', '&').replace('<', '<') diff --git a/zeroinstall/injector/cli.py b/zeroinstall/injector/cli.py index fc2fd21..e8c1737 100644 --- a/zeroinstall/injector/cli.py +++ b/zeroinstall/injector/cli.py @@ -11,7 +11,7 @@ from optparse import OptionParser import logging from zeroinstall import SafeException, NeedDownload -from zeroinstall.injector import model, autopolicy, namespaces, selections +from zeroinstall.injector import model, autopolicy, selections from zeroinstall.injector.iface_cache import iface_cache #def program_log(msg): os.access('MARK: 0launch: ' + msg, os.F_OK) @@ -133,11 +133,9 @@ def _manage_feeds(options, args): def _normal_mode(options, args): if len(args) < 1: - # You can use -g on its own to edit the GUI's own policy - # Otherwise, failing to give an interface is an error if options.gui: - args = [namespaces.injector_gui_uri] - options.download_only = True + from zeroinstall import helpers + return helpers.get_selections_gui(None, []) else: raise UsageError() diff --git a/zeroinstall/injector/namespaces.py b/zeroinstall/injector/namespaces.py index 4abbc5c..4b9455a 100644 --- a/zeroinstall/injector/namespaces.py +++ b/zeroinstall/injector/namespaces.py @@ -4,8 +4,6 @@ @var config_site: Where our configuration settings are stored @var config_prog: Where our configuration settings are stored - -@var injector_gui_uri: The URI of the graphical interface for the injector """ # Copyright (C) 2009, Thomas Leonard @@ -16,5 +14,3 @@ XMLNS_TRUST = 'http://zero-install.sourceforge.net/2007/injector/trust' config_site = '0install.net' config_prog = 'injector' - -injector_gui_uri = 'http://0install.net/2008/interfaces/ZeroInstall-GUI.xml' diff --git a/zeroinstall/injector/policy.py b/zeroinstall/injector/policy.py index 155c99e..73180da 100644 --- a/zeroinstall/injector/policy.py +++ b/zeroinstall/injector/policy.py @@ -16,7 +16,7 @@ import ConfigParser from zeroinstall import SafeException from zeroinstall.injector import arch from zeroinstall.injector.model import Interface, Implementation, network_levels, network_offline, DistributionImplementation, network_full -from zeroinstall.injector.namespaces import config_site, config_prog, injector_gui_uri +from zeroinstall.injector.namespaces import config_site, config_prog from zeroinstall.support import tasks, basedir from zeroinstall.injector.iface_cache import iface_cache @@ -212,10 +212,6 @@ class Policy(object): else: if self._warned_offline: debug(_("Not downloading feed '%s' because we are off-line."), feed_url) - elif feed_url == injector_gui_uri: - # Don't print a warning, because we always switch to off-line mode to - # run the GUI the first time. - info(_("Not downloading GUI feed '%s' because we are in off-line mode."), feed_url) else: warn(_("Not downloading feed '%s' because we are in off-line mode."), feed_url) self._warned_offline = True diff --git a/zeroinstall/injector/reader.py b/zeroinstall/injector/reader.py index d17f7e3..9608c39 100644 --- a/zeroinstall/injector/reader.py +++ b/zeroinstall/injector/reader.py @@ -8,11 +8,10 @@ Parses an XML interface into a Python representation. from zeroinstall import _ import os from logging import debug, info, warn -from os.path import dirname from zeroinstall.support import basedir from zeroinstall.injector import qdom, distro -from zeroinstall.injector.namespaces import config_site, config_prog, XMLNS_IFACE, injector_gui_uri +from zeroinstall.injector.namespaces import config_site, config_prog, XMLNS_IFACE from zeroinstall.injector.model import Interface, InvalidInterface, ZeroInstallFeed, escape, Feed, stability_levels from zeroinstall.injector import model @@ -46,11 +45,6 @@ def update_from_cache(interface): update_user_overrides(interface, main_feed) - # Special case: add our fall-back local copy of the injector as a feed - if interface.uri == injector_gui_uri: - local_gui = os.path.join(os.path.abspath(dirname(dirname(__file__))), '0launch-gui', 'ZeroInstall-GUI.xml') - interface.extra_feeds.append(Feed(local_gui, None, False)) - return bool(cached) def update_user_overrides(interface, main_feed = None): diff --git a/zeroinstall/zerostore/manifest.py b/zeroinstall/zerostore/manifest.py index 15bd776..4343b19 100644 --- a/zeroinstall/zerostore/manifest.py +++ b/zeroinstall/zerostore/manifest.py @@ -257,7 +257,7 @@ def copy_tree_with_verify(source, target, manifest_data, required_digest): The copy is first done to a temporary directory in target, then renamed to the final name only if correct. Therefore, an invalid 'target/required_digest' will never exist. A successful return means than target/required_digest now exists (whether we created it or not).""" - import tempfile, shutil + import tempfile from logging import info alg, digest_value = splitID(required_digest) -- 2.11.4.GIT