diff options
author | Aleksey Lim <alsroot@sugarlabs.org> | 2013-04-20 09:00:01 (GMT) |
---|---|---|
committer | Aleksey Lim <alsroot@sugarlabs.org> | 2013-04-20 09:00:01 (GMT) |
commit | aec18d89b9cee4ba91904a9efaef8d0382d9e302 (patch) | |
tree | b2b9c40456dd4f067c3f198af3c8b3f28ab95eb9 | |
parent | 0d7b7fa1b21dee3a1b1e452d76282338866ad317 (diff) |
Do not subscribe to server events for one-command-call in sugar-network utility
-rwxr-xr-x | sugar-network | 3 | ||||
-rw-r--r-- | sugar_network/client/commands.py | 6 | ||||
-rwxr-xr-x | tests/units/client/injector.py | 8 |
3 files changed, 13 insertions, 4 deletions
diff --git a/sugar-network b/sugar-network index cbde4c8..5eb95a9 100755 --- a/sugar-network +++ b/sugar-network @@ -155,7 +155,8 @@ class Application(application.Application): if not client.anonymous.value: util.ensure_key(client.key_path()) home = Volume(client.path('db')) - cp = ClientCommands(home, offline=offline.value) + cp = ClientCommands(home, offline=offline.value, + no_subscription=True) if not offline.value: for __ in cp.subscribe(event='inline', state='online'): break diff --git a/sugar_network/client/commands.py b/sugar_network/client/commands.py index 8290e4b..3f89481 100644 --- a/sugar_network/client/commands.py +++ b/sugar_network/client/commands.py @@ -41,7 +41,8 @@ _logger = logging.getLogger('client.commands') class ClientCommands(db.CommandsProcessor, Commands, journal.Commands): - def __init__(self, home_volume, server_mode=False, offline=False): + def __init__(self, home_volume, server_mode=False, offline=False, + no_subscription=False): db.CommandsProcessor.__init__(self) Commands.__init__(self) if not client.no_dbus.value: @@ -55,6 +56,7 @@ class ClientCommands(db.CommandsProcessor, Commands, journal.Commands): self._jobs = coroutine.Pool() self._static_prefix = 'http://localhost:%s' % client.ipc_port.value self._offline = offline + self._no_subscription = no_subscription self._server_mode = server_mode home_volume.connect(self._home_event_cb) @@ -361,6 +363,8 @@ class ClientCommands(db.CommandsProcessor, Commands, journal.Commands): injector.invalidate_solutions(impl_info['mtime']) _logger.info('Connected to %r node', url) self._got_online() + if self._no_subscription: + break listen_for_events() except Exception: exception(_logger, 'Connection to %r failed', url) diff --git a/tests/units/client/injector.py b/tests/units/client/injector.py index 8a91a05..f53074d 100755 --- a/tests/units/client/injector.py +++ b/tests/units/client/injector.py @@ -413,9 +413,13 @@ class InjectorTest(tests.Test): pipe = injector.launch(context) self.assertEqual('exit', [i for i in pipe][-1].get('state')) with file('resolve') as f: - self.assertEqual(['dep1.bin'], pickle.load(f)) - self.assertEqual(['dep2.bin'], pickle.load(f)) + deps = [pickle.load(f), + pickle.load(f), + ] self.assertRaises(EOFError, pickle.load, f) + self.assertEqual( + sorted([['dep1.bin'], ['dep2.bin']]), + sorted(deps)) with file('install') as f: self.assertEqual(['dep2.bin'], pickle.load(f)) self.assertRaises(EOFError, pickle.load, f) |