From 45b8e2aa8d955f932510b2be7b95daa6092e2f8c Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Sat, 4 Feb 2006 13:47:38 +0000 Subject: [PATCH] When switching to GUI mode, don't even try to download the GUI interface; just run the local copy. When logging that nothing is known about an interface, only make it a warning if there are also no feeds. Updated unit-tests for this behaviour. git-svn-id: file:///home/talex/Backups/sf.net/Subversion/zero-install/trunk/0launch@663 9f8c893c-44ee-0310-b757-c8ca8341c71e --- 0launch | 2 +- tests/testlaunch.py | 9 +++++---- zeroinstall/injector/policy.py | 11 +++++++---- zeroinstall/injector/reader.py | 2 +- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/0launch b/0launch index 51949d7..da942a6 100755 --- a/0launch +++ b/0launch @@ -177,7 +177,7 @@ if options.gui: # Try to start the GUI without using the network. # The GUI can refresh itself if it wants to. policy.freshness = 0 - policy.network_use = model.network_minimal + policy.network_use = model.network_offline prog_args = [iface_uri] + args[1:] # Options apply to actual program, not GUI diff --git a/tests/testlaunch.py b/tests/testlaunch.py index 09085ec..2f9ad52 100755 --- a/tests/testlaunch.py +++ b/tests/testlaunch.py @@ -107,16 +107,17 @@ class TestLaunch(unittest.TestCase): def testDisplay(self): os.environ['DISPLAY'] = ':foo' out, err = self.run_0launch(['--dry-run', 'http://foo']) - self.assertEquals("Would download 'http://0install.net/2005/interfaces/injector-gui'\n", - out) + # Uses local copy of GUI + assert out.startswith("Would execute: ") + assert '0launch-gui' in out self.assertEquals("", err) def testRefreshDisplay(self): os.environ['DISPLAY'] = ':foo' out, err = self.run_0launch(['--dry-run', '--download-only', '--refresh', 'http://foo']) - self.assertEquals("Would download 'http://0install.net/2005/interfaces/injector-gui'\n", - out) + assert out.startswith("Would execute: ") + assert '0launch-gui' in out self.assertEquals("", err) def testNeedDownload(self): diff --git a/zeroinstall/injector/policy.py b/zeroinstall/injector/policy.py index 47860b4..3140af6 100644 --- a/zeroinstall/injector/policy.py +++ b/zeroinstall/injector/policy.py @@ -224,9 +224,12 @@ class Policy(object): if self.warned_offline: debug("Nothing known about interface, but we are off-line.") else: - warn("Nothing known about interface '%s', but we are in off-line mode " - "(so not fetching)." % uri) - self.warned_offline = True + if iface.feeds: + info("Nothing known about interface '%s' and off-line. Trying feeds only.") + else: + warn("Nothing known about interface '%s', but we are in off-line mode " + "(so not fetching)." % uri) + self.warned_offline = True elif not uri.startswith('/'): staleness = time.time() - (iface.last_checked or 0) debug("Staleness for %s is %.2f hours", iface, staleness / 3600.0) @@ -261,7 +264,7 @@ class Policy(object): def get_implementation(self, interface): assert isinstance(interface, Interface) - if not interface.name: + if not interface.name and not interface.feeds: raise SafeException("We don't have enough information to " "run this program yet. " "Need to download:\n%s" % interface.uri) diff --git a/zeroinstall/injector/reader.py b/zeroinstall/injector/reader.py index 0305fde..eda0faf 100644 --- a/zeroinstall/injector/reader.py +++ b/zeroinstall/injector/reader.py @@ -75,7 +75,7 @@ def update_from_cache(interface): # 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(dirname(dirname(__file__)), '0launch-gui', 'injector-gui.xml') + local_gui = os.path.join(os.path.abspath(dirname(dirname(__file__))), '0launch-gui', 'injector-gui.xml') interface.feeds.append(Feed(local_gui, None, False)) return bool(cached) -- 2.11.4.GIT