Merge lp:~dobey/ubuntuone-client/update-from-trunk into lp:ubuntuone-client/stable-3-0

Proposed by dobey on 2012-03-06
Status: Merged
Approved by: dobey on 2012-03-06
Approved revision: no longer in the source branch.
Merged at revision: 1175
Proposed branch: lp:~dobey/ubuntuone-client/update-from-trunk
Merge into: lp:ubuntuone-client/stable-3-0
Diff against target: 514 lines (+100/-96)
12 files modified
bin/ubuntuone-login (+1/-1)
data/syncdaemon.conf (+2/-2)
tests/platform/linux/test_credentials.py (+3/-10)
tests/platform/linux/test_messaging.py (+12/-11)
tests/platform/test_credentials.py (+22/-1)
tests/syncdaemon/test_interaction_interfaces.py (+4/-4)
ubuntuone/platform/credentials/__init__.py (+18/-0)
ubuntuone/platform/credentials/linux.py (+5/-14)
ubuntuone/platform/credentials/windows.py (+4/-13)
ubuntuone/platform/linux/messaging.py (+27/-38)
ubuntuone/syncdaemon/interaction_interfaces.py (+1/-1)
ubuntuone/syncdaemon/logger.py (+1/-1)
To merge this branch: bzr merge lp:~dobey/ubuntuone-client/update-from-trunk
Reviewer Review Type Date Requested Status
Roberto Alsina (community) 2012-03-06 Approve on 2012-03-06
Review via email: mp+96237@code.launchpad.net

Commit Message

[Roberto Alsina]

    - Made indicate import optional (LP: #939509).

[Natalia Bidart]

    - Made default for MARK logging to be every 15 minutes (LP: #906462).
    - Call CredentialsManagementTool.login when prompt to connect (LP: #944230).
    - Prefer the Qt SSO UI when doing credentials management (LP: #930716).
    - Use consistently the U1_DEBUG env var to have DEUBG output.

[Rodney Dawes]

    Update the messaging indicator integration to launch ubuntuone-installer
    Avoid passing time() to the Indicator API which expects GTimeVal now
    Update the tests for the changes

To post a comment you must log in.
Roberto Alsina (ralsina) wrote :

+1

review: Approve
1175. By Roberto Alsina on 2012-03-06

[Roberto Alsina]

    - Made indicate import optional (LP: #939509).

[Natalia Bidart]

    - Made default for MARK logging to be every 15 minutes (LP: #906462).
    - Call CredentialsManagementTool.login when prompt to connect (LP: #944230).
    - Prefer the Qt SSO UI when doing credentials management (LP: #930716).
    - Use consistently the U1_DEBUG env var to have DEUBG output.

[Rodney Dawes]

    Update the messaging indicator integration to launch ubuntuone-installer
    Avoid passing time() to the Indicator API which expects GTimeVal now
    Update the tests for the changes

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/ubuntuone-login'
2--- bin/ubuntuone-login 2012-01-03 12:52:20 +0000
3+++ bin/ubuntuone-login 2012-03-06 20:42:25 +0000
4@@ -49,7 +49,7 @@
5 logger.error("Ubuntu One login manager already running, quitting.")
6 sys.exit(0)
7
8- if os.environ.get('U1_CREDENTIALS_DEBUG'):
9+ if os.environ.get('U1_DEBUG'):
10 debug_handler = logging.StreamHandler(sys.stderr)
11 debug_handler.setFormatter(basic_formatter)
12 debug_handler.setLevel(logging.DEBUG)
13
14=== modified file 'data/syncdaemon.conf'
15--- data/syncdaemon.conf 2012-02-07 22:35:49 +0000
16+++ data/syncdaemon.conf 2012-03-06 20:42:25 +0000
17@@ -39,9 +39,9 @@
18 debug.parser = bool
19 debug.help = output the log to stdout
20
21-mark_interval.default = 120
22+mark_interval.default = 900
23 mark_interval.parser = int
24-mark_interval.help = log a "mark" every N seconds
25+mark_interval.help = log a "mark" every N seconds, defaults to 15 minutes
26
27 im_ok_with_being_root_pretty_please_let_me_be_root.default = False
28 im_ok_with_being_root_pretty_please_let_me_be_root.parser = bool
29
30=== modified file 'tests/platform/linux/test_credentials.py'
31--- tests/platform/linux/test_credentials.py 2011-11-30 19:30:00 +0000
32+++ tests/platform/linux/test_credentials.py 2012-03-06 20:42:25 +0000
33@@ -32,6 +32,7 @@
34 CredentialsError,
35 CredentialsManagementTool,
36 logger,
37+ UI_PARAMS,
38 )
39 from ubuntuone.platform.credentials.linux import (
40 APP_NAME,
41@@ -40,12 +41,6 @@
42 DBUS_BUS_NAME,
43 DBUS_CREDENTIALS_IFACE,
44 DBUS_CREDENTIALS_PATH,
45- DESCRIPTION,
46- HELP_TEXT_KEY,
47- PING_URL,
48- PING_URL_KEY,
49- TC_URL_KEY,
50- TC_URL,
51 TIMEOUT_INTERVAL,
52 ubuntu_sso,
53 )
54@@ -377,8 +372,7 @@
55 yield d
56
57 self.assertEqual(self.sso_server._app_name, APP_NAME)
58- params = {HELP_TEXT_KEY: DESCRIPTION, TC_URL_KEY: TC_URL,
59- PING_URL_KEY: PING_URL}
60+ params = dict(UI_PARAMS)
61 params.update(self.args)
62 self.assertEqual(self.sso_server._args, params)
63
64@@ -391,8 +385,7 @@
65 yield d
66
67 self.assertEqual(self.sso_server._app_name, APP_NAME)
68- params = {HELP_TEXT_KEY: DESCRIPTION, TC_URL_KEY: TC_URL,
69- PING_URL_KEY: PING_URL}
70+ params = dict(UI_PARAMS)
71 params.update(self.args)
72 self.assertEqual(self.sso_server._args, params)
73
74
75=== modified file 'tests/platform/linux/test_messaging.py'
76--- tests/platform/linux/test_messaging.py 2012-01-25 22:42:17 +0000
77+++ tests/platform/linux/test_messaging.py 2012-03-06 20:42:25 +0000
78@@ -25,8 +25,13 @@
79 from mocker import Mocker, ANY
80 from twisted.internet import defer
81 from twisted.trial.unittest import TestCase
82+from ubuntuone.devtools.testcases import skipIf
83
84-from ubuntuone.platform.linux.messaging import Messaging, _server_callback
85+from ubuntuone.platform.linux.messaging import (
86+ Messaging,
87+ _server_callback,
88+ indicate,
89+)
90
91 FAKE_TIME = 123
92 FAKE_TIME2 = 456
93@@ -40,6 +45,7 @@
94 pass
95
96
97+@skipIf(indicate is None, "No valid Indicate found.")
98 class MessagingTestCase(TestCase):
99 """Test the Messaging API."""
100
101@@ -83,12 +89,7 @@
102 if message_count is not None:
103 mock_indicator.set_property("count", str(message_count))
104 else:
105- if message_time is None:
106- mock_time = self.mocker.replace("time.time")
107- mock_time()
108- self.mocker.result(FAKE_TIME2)
109- mock_indicator.set_property_time("time", FAKE_TIME2)
110- else:
111+ if message_time is not None:
112 mock_indicator.set_property_time("time", message_time)
113 mock_indicator.set_property("draw-attention", "true")
114 if update_count:
115@@ -133,16 +134,16 @@
116 """On message count update, libnotify receives the proper calls."""
117 self._show_message_setup(message_count='1200', update_count='1300')
118 messaging = Messaging()
119- indicator = messaging.show_message(
120+ messaging.show_message(
121 FAKE_SENDER, callback, message_count=1200)
122- messaging.update_count(indicator, 1300)
123+ messaging.update_count(messaging.indicators[-1], 1300)
124
125 def test_callback(self):
126 """When the callback fires, libnotify receives the proper calls."""
127 self._show_message_setup(real_callback=True)
128 messaging = Messaging()
129- mock_indicator = messaging.show_message(FAKE_SENDER)
130+ messaging.show_message(FAKE_SENDER)
131 self.assertEquals(1, len(messaging.indicators))
132 actual_callback = messaging.create_callback()
133- actual_callback(mock_indicator)
134+ actual_callback(messaging.indicators[-1])
135 self.assertEquals(0, len(messaging.indicators))
136
137=== modified file 'tests/platform/test_credentials.py'
138--- tests/platform/test_credentials.py 2011-08-30 14:27:51 +0000
139+++ tests/platform/test_credentials.py 2012-03-06 20:42:25 +0000
140@@ -28,16 +28,26 @@
141 from twisted.internet import defer
142 from twisted.trial.unittest import TestCase
143
144+from contrib.testing.testcase import FAKED_CREDENTIALS
145 from ubuntuone import clientdefs
146 from ubuntuone.platform.credentials import (
147 BASE_PING_URL,
148 CredentialsError,
149 CredentialsManagementTool,
150+ DESCRIPTION,
151+ HELP_TEXT_KEY,
152 NO_OP,
153 PING_URL,
154+ PING_URL_KEY,
155 platform_data,
156+ POLICY_URL,
157+ POLICY_URL_KEY,
158+ TC_URL,
159+ TC_URL_KEY,
160+ UI_EXECUTABLE_KEY,
161+ UI_EXECUTABLE_QT,
162+ UI_PARAMS,
163 )
164-from contrib.testing.testcase import FAKED_CREDENTIALS
165
166
167 class FakedSignal(object):
168@@ -227,6 +237,17 @@
169 proxy2 = yield self.cred_tool.get_creds_proxy()
170 self.assertTrue(proxy1 is proxy2)
171
172+ def test_ui_params(self):
173+ """The UI_PARAMS dict is correct."""
174+ expected = {
175+ HELP_TEXT_KEY: DESCRIPTION,
176+ PING_URL_KEY: PING_URL,
177+ POLICY_URL_KEY: POLICY_URL,
178+ TC_URL_KEY: TC_URL,
179+ UI_EXECUTABLE_KEY: UI_EXECUTABLE_QT,
180+ }
181+ self.assertEqual(expected, UI_PARAMS)
182+
183
184 class ArgsTestCase(CredentialsManagementToolTestCase):
185 """Test case to check that proper arguments are passed to SSO backend."""
186
187=== modified file 'tests/syncdaemon/test_interaction_interfaces.py'
188--- tests/syncdaemon/test_interaction_interfaces.py 2012-02-18 16:13:04 +0000
189+++ tests/syncdaemon/test_interaction_interfaces.py 2012-03-06 20:42:25 +0000
190@@ -84,11 +84,11 @@
191 self._kwargs = kwargs
192 self._called = {}
193
194- def register(self, *args, **kwargs):
195- """Fake register."""
196+ def login(self, *args, **kwargs):
197+ """Fake login."""
198 if self.should_fail:
199 return defer.fail(self.should_fail)
200- self._called['register'] = (args, kwargs)
201+ self._called['login'] = (args, kwargs)
202 return defer.succeed(self.credentials)
203
204 def find_credentials(self, *args, **kwargs):
205@@ -2291,7 +2291,7 @@
206 """
207
208 sd_class = SyncdaemonService
209- method = 'register'
210+ method = 'login'
211 autoconnecting = False
212
213 @defer.inlineCallbacks
214
215=== modified file 'ubuntuone/platform/credentials/__init__.py'
216--- ubuntuone/platform/credentials/__init__.py 2011-10-14 20:02:23 +0000
217+++ ubuntuone/platform/credentials/__init__.py 2012-03-06 20:42:25 +0000
218@@ -29,6 +29,15 @@
219
220 from twisted.internet import defer
221
222+from ubuntu_sso import UI_EXECUTABLE_QT
223+from ubuntu_sso.credentials import (
224+ HELP_TEXT_KEY,
225+ PING_URL_KEY,
226+ POLICY_URL_KEY,
227+ UI_EXECUTABLE_KEY,
228+ TC_URL_KEY,
229+)
230+
231 from ubuntuone import clientdefs
232 from ubuntuone.logger import (
233 basic_formatter,
234@@ -51,6 +60,7 @@
235 Q_ = lambda string: gettext.dgettext(clientdefs.GETTEXT_PACKAGE, string)
236 APP_NAME = u"Ubuntu One"
237 TC_URL = u"https://one.ubuntu.com/terms/"
238+POLICY_URL = u"https://one.ubuntu.com/privacy/"
239
240
241 def platform_data():
242@@ -62,6 +72,7 @@
243 result = urllib.urlencode(result)
244 return result
245
246+
247 BASE_PING_URL = \
248 u"https://one.ubuntu.com/oauth/sso-finished-so-get-tokens/{email}"
249 # the result of platform_data is given by urlencode, encoded with ascii
250@@ -69,6 +80,13 @@
251 DESCRIPTION = Q_('Ubuntu One requires an Ubuntu Single Sign On (SSO) account. '
252 'This process will allow you to create a new account, '
253 'if you do not yet have one.')
254+UI_PARAMS = {
255+ HELP_TEXT_KEY: DESCRIPTION,
256+ PING_URL_KEY: PING_URL,
257+ POLICY_URL_KEY: POLICY_URL,
258+ TC_URL_KEY: TC_URL,
259+ UI_EXECUTABLE_KEY: UI_EXECUTABLE_QT,
260+}
261
262
263 class CredentialsError(Exception):
264
265=== modified file 'ubuntuone/platform/credentials/linux.py'
266--- ubuntuone/platform/credentials/linux.py 2011-10-14 20:02:23 +0000
267+++ ubuntuone/platform/credentials/linux.py 2012-03-06 20:42:25 +0000
268@@ -20,18 +20,11 @@
269 import dbus.service
270 import ubuntu_sso
271
272-from ubuntu_sso.credentials import (
273- HELP_TEXT_KEY,
274- PING_URL_KEY,
275- TC_URL_KEY,
276-)
277 from ubuntuone.platform.credentials import (
278 APP_NAME,
279- DESCRIPTION,
280 logger,
281 NO_OP,
282- PING_URL,
283- TC_URL,
284+ UI_PARAMS,
285 )
286
287
288@@ -227,8 +220,7 @@
289 def register(self, args, reply_handler=NO_OP, error_handler=NO_OP):
290 """Get credentials if found else prompt to register to Ubuntu One."""
291 self.ref_count += 1
292- params = {HELP_TEXT_KEY: DESCRIPTION, TC_URL_KEY: TC_URL,
293- PING_URL_KEY: PING_URL}
294+ params = dict(UI_PARAMS)
295 params.update(args)
296 self.sso_proxy.register(APP_NAME, params,
297 reply_handler=reply_handler, error_handler=error_handler)
298@@ -239,8 +231,7 @@
299 def login(self, args, reply_handler=NO_OP, error_handler=NO_OP):
300 """Get credentials if found else prompt to login to Ubuntu One."""
301 self.ref_count += 1
302- params = {HELP_TEXT_KEY: DESCRIPTION, TC_URL_KEY: TC_URL,
303- PING_URL_KEY: PING_URL}
304+ params = dict(UI_PARAMS)
305 params.update(args)
306 self.sso_proxy.login(APP_NAME, params,
307 reply_handler=reply_handler, error_handler=error_handler)
308@@ -249,10 +240,10 @@
309 in_signature='a{ss}',
310 async_callbacks=("reply_handler", "error_handler"))
311 def login_email_password(self, args, reply_handler=NO_OP,
312- error_handler=NO_OP):
313+ error_handler=NO_OP):
314 """Get credentials if found else prompt to login to Ubuntu One."""
315 self.ref_count += 1
316- params = {PING_URL_KEY: PING_URL}
317+ params = dict(UI_PARAMS)
318 params.update(args)
319 self.sso_proxy.login_email_password(APP_NAME, params,
320 reply_handler=reply_handler, error_handler=error_handler)
321
322=== modified file 'ubuntuone/platform/credentials/windows.py'
323--- ubuntuone/platform/credentials/windows.py 2012-01-06 14:42:46 +0000
324+++ ubuntuone/platform/credentials/windows.py 2012-03-06 20:42:25 +0000
325@@ -19,18 +19,11 @@
326 from ubuntu_sso.main import get_sso_client
327 from twisted.internet import defer
328
329-from ubuntu_sso.credentials import (
330- HELP_TEXT_KEY,
331- PING_URL_KEY,
332- TC_URL_KEY,
333-)
334 from ubuntuone.platform.credentials import (
335 APP_NAME,
336- DESCRIPTION,
337 logger,
338 NO_OP,
339- PING_URL,
340- TC_URL,
341+ UI_PARAMS,
342 )
343
344
345@@ -109,16 +102,14 @@
346
347 def register(self, args, reply_handler=NO_OP, error_handler=NO_OP):
348 """Get credentials if found else prompt to register to Ubuntu One."""
349- params = {HELP_TEXT_KEY: DESCRIPTION, TC_URL_KEY: TC_URL,
350- PING_URL_KEY: PING_URL}
351+ params = dict(UI_PARAMS)
352 params.update(args)
353 d = self.sso_proxy.register(APP_NAME, params)
354 d.addCallbacks(lambda _: reply_handler(), error_handler)
355
356 def login(self, args, reply_handler=NO_OP, error_handler=NO_OP):
357 """Get credentials if found else prompt to login to Ubuntu One."""
358- params = {HELP_TEXT_KEY: DESCRIPTION, TC_URL_KEY: TC_URL,
359- PING_URL_KEY: PING_URL}
360+ params = dict(UI_PARAMS)
361 params.update(args)
362 d = self.sso_proxy.login(APP_NAME, params)
363 d.addCallbacks(lambda _: reply_handler(), error_handler)
364@@ -126,7 +117,7 @@
365 def login_email_password(self, args,
366 reply_handler=NO_OP, error_handler=NO_OP):
367 """Get credentials if found else login to Ubuntu One."""
368- params = {PING_URL_KEY: PING_URL}
369+ params = dict(UI_PARAMS)
370 params.update(args)
371 d = self.sso_proxy.login_email_password(APP_NAME, params)
372 d.addCallbacks(lambda _: reply_handler(), error_handler)
373
374=== modified file 'ubuntuone/platform/linux/messaging.py'
375--- ubuntuone/platform/linux/messaging.py 2012-01-26 18:09:46 +0000
376+++ ubuntuone/platform/linux/messaging.py 2012-03-06 20:42:25 +0000
377@@ -21,21 +21,25 @@
378 # of them are available, we should fall back to silently discarding
379 # messages.
380
381-import dbus
382-import subprocess
383 import sys
384
385-from time import time
386-
387 indicate = None
388-if 'gobject' in sys.modules and sys.modules['gobject'] is not None:
389- import indicate as pyindicate
390- indicate = pyindicate
391- using_gi = False
392-else:
393- from gi.repository import Indicate
394- indicate = Indicate
395- using_gi = True
396+glib = None
397+try:
398+ if 'gobject' in sys.modules and sys.modules['gobject'] is not None:
399+ import indicate as pyindicate
400+ import glib as GLib
401+ indicate = pyindicate
402+ glib = GLib
403+ using_gi = False
404+ else:
405+ from gi.repository import GLib
406+ glib = GLib
407+ from gi.repository import Indicate
408+ indicate = Indicate
409+ using_gi = True
410+except ImportError:
411+ pass
412
413 DBUS_BUS_NAME = 'com.ubuntuone.controlpanel.gui'
414 DBUS_PATH = '/gui'
415@@ -43,34 +47,16 @@
416 TRANSLATION_DOMAIN = 'ubuntuone-control-panel'
417
418 from ubuntuone.status.messaging import AbstractMessaging
419-from ubuntuone.status.logger import logger
420-
421-
422-# pylint: disable=W0613
423+
424+
425 def open_volumes():
426 """Open the control panel to the shares tab."""
427- bus = dbus.SessionBus()
428- obj = bus.get_object(DBUS_BUS_NAME, DBUS_PATH)
429- service = dbus.Interface(obj, dbus_interface=DBUS_IFACE_GUI)
430-
431- def error_handler(*args, **kwargs):
432- """Log errors when calling D-Bus methods in a async way."""
433- logger.error(
434- 'Dbus call to com.ubuntuone.controlpanel.gui failed: %r %r', args,
435- kwargs)
436-
437- def reply_handler(*args, **kwargs):
438- """Exit when done."""
439- pass
440-
441- service.switch_to_alert(
442- 'volumes', True, reply_handler=reply_handler,
443- error_handler=error_handler)
444+ _server_callback(None)
445
446
447 def _server_callback(the_indicator, message_time=None):
448 """Open the control panel to the shares tab."""
449- subprocess.Popen(['ubuntuone-control-panel-gtk'])
450+ glib.spawn_command_line_async('ubuntuone-installer')
451 # pylint: enable=W0613
452
453
454@@ -78,7 +64,10 @@
455 """Notification of the end user."""
456
457 def __init__(self, server_callback=_server_callback):
458+ self.server_callback = server_callback
459 self.indicators = []
460+ if indicate is None:
461+ return
462 if using_gi:
463 self.server = indicate.Server.ref_default()
464 else:
465@@ -93,6 +82,8 @@
466 def show_message(self, sender, callback=None, message_time=None,
467 message_count=None, icon=None):
468 """Show a message in the messaging menu."""
469+ if indicate is None:
470+ return
471 indicator = indicate.Indicator()
472 indicator.set_property("subtype", "u1")
473 indicator.set_property("name", sender)
474@@ -107,13 +98,11 @@
475 if message_count is not None:
476 indicator.set_property("count", str(message_count))
477 else:
478- if message_time is None:
479- message_time = time()
480- indicator.set_property_time("time", message_time)
481+ if message_time is not None:
482+ indicator.set_property_time("time", message_time)
483 indicator.set_property("draw-attention", "true")
484 indicator.show()
485 self.indicators.append(indicator)
486- return indicator
487 # pylint: enable=R0913
488
489 def create_callback(self):
490
491=== modified file 'ubuntuone/syncdaemon/interaction_interfaces.py'
492--- ubuntuone/syncdaemon/interaction_interfaces.py 2012-02-18 16:13:04 +0000
493+++ ubuntuone/syncdaemon/interaction_interfaces.py 2012-03-06 20:42:25 +0000
494@@ -1245,7 +1245,7 @@
495 if autoconnecting:
496 return management.find_credentials()
497 else:
498- return management.register(window_id=0) # no window ID
499+ return management.login(window_id=0) # no window ID
500
501 @log_call(logger.debug)
502 def disconnect(self):
503
504=== modified file 'ubuntuone/syncdaemon/logger.py'
505--- ubuntuone/syncdaemon/logger.py 2011-10-14 20:02:23 +0000
506+++ ubuntuone/syncdaemon/logger.py 2012-03-06 20:42:25 +0000
507@@ -279,7 +279,7 @@
508
509
510 # if we are in debug mode, replace/add the handlers
511-DEBUG = os.environ.get("DEBUG", None)
512+DEBUG = os.environ.get("U1_DEBUG", None)
513 if DEBUG:
514 set_debug(DEBUG)
515

Subscribers

People subscribed via source and target branches

to all changes: