Merge lp:~nataliabidart/ubuntuone-client/not-autoconnect-if-no-tokens into lp:ubuntuone-client
- not-autoconnect-if-no-tokens
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Natalia Bidart |
Approved revision: | 807 |
Merged at revision: | 806 |
Proposed branch: | lp:~nataliabidart/ubuntuone-client/not-autoconnect-if-no-tokens |
Merge into: | lp:ubuntuone-client |
Diff against target: |
469 lines (+99/-112) 6 files modified
contrib/testing/testcase.py (+1/-1) tests/platform/linux/test_dbus.py (+66/-78) tests/syncdaemon/test_main.py (+5/-4) ubuntuone/platform/linux/__init__.py (+2/-2) ubuntuone/platform/linux/dbus_interface.py (+22/-25) ubuntuone/syncdaemon/main.py (+3/-2) |
To merge this branch: | bzr merge lp:~nataliabidart/ubuntuone-client/not-autoconnect-if-no-tokens |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Lucio Torre (community) | Approve | ||
Roberto Alsina (community) | Approve | ||
dobey (community) | Needs Information | ||
Review via email: mp+46196@code.launchpad.net |
Commit message
Syncdaemon should get credentials using find_credentials, not calling register which may raise a GUI our of nowhere (LP: #701588).
Description of the change
Natalia Bidart (nataliabidart) wrote : | # |
This will make syncdaemon to continue autoconnecting if the token is already in the keyring.
If not, it will do nothing, since the point of entry to the service should be some other (usually) UI app.
dobey (dobey) wrote : | # |
That's what I thought. It doesn't solve the bug, but works around it. I think the correct fix wold be to make ubuntuone-launch not start ubuntuone-
Roberto Alsina (ralsina) wrote : | # |
+1 as discussed on IRC
Natalia Bidart (nataliabidart) wrote : | # |
The bug to track down why syncdaemon is started if the user doesn't have a U1 account is located at:
Natalia Bidart (nataliabidart) wrote : | # |
The attempt to merge lp:~nataliabidart/ubuntuone-client/not-autoconnect-if-no-tokens into lp:ubuntuone-client failed. Below is the output from the failed tests.
/usr/bin/
[1mchecking for autoconf >= 2.53...
(B[m testing autoconf2.50... not found.
testing autoconf... found 2.67
[1mchecking for automake >= 1.10...
(B[m testing automake-1.11... found 1.11.1
[1mchecking for libtool >= 1.5...
(B[m testing libtoolize... found 2.2.6b
[1mchecking for intltool >= 0.30...
(B[m testing intltoolize... found 0.41.1
[1mchecking for pkg-config >= 0.14.0...
(B[m testing pkg-config... found 0.25
[1mchecking for gtk-doc >= 1.0...
(B[m testing gtkdocize... found 1.15
[1mChecking for required M4 macros...
(B[m[1mChecking for forbidden M4 macros...
(B[m
(B[m[1mRunning libtoolize...
(B[mlibtoolize: putting auxiliary files in `.'.
libtoolize: copying file `./ltmain.sh'
libtoolize: putting macros in AC_CONFIG_
libtoolize: copying file `m4/libtool.m4'
libtoolize: copying file `m4/ltoptions.m4'
libtoolize: copying file `m4/ltsugar.m4'
libtoolize: copying file `m4/ltversion.m4'
libtoolize: copying file `m4/lt~obsolete.m4'
[1mRunning intltoolize...
(B[m[1mRunning gtkdocize...
(B[m[1mRunning aclocal-1.11...
(B[m[1mRunning autoconf...
(B[m[1mRunning autoheader...
(B[m[1mRunning automake-1.11...
(B[m[1mRunning ./configure --enable-gtk-doc --enable-debug --with-
(B[mchecking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for style of include used by make... GNU
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking dependency style of gcc... gcc3
checking for library containing strerror... none required
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking dependency style of gcc... (cached) gcc3
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking for a sed that does not truncate output... /bin/sed
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for fgrep... /bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864...
- 806. By Natalia Bidart
-
Merged trunk in.
- 807. By Natalia Bidart
-
Making tests pass.
Preview Diff
1 | === modified file 'contrib/testing/testcase.py' |
2 | --- contrib/testing/testcase.py 2010-12-16 14:35:23 +0000 |
3 | +++ contrib/testing/testcase.py 2011-01-14 20:00:42 +0000 |
4 | @@ -96,7 +96,7 @@ |
5 | def shutdown(self, with_restart=False): |
6 | """...that only knows how to go away""" |
7 | |
8 | - def _request_token(self): |
9 | + def _request_token(self, *args, **kwargs): |
10 | """Return a token which is a fixed set of credentials.""" |
11 | return FAKED_CREDENTIALS |
12 | |
13 | |
14 | === modified file 'tests/platform/linux/test_dbus.py' |
15 | --- tests/platform/linux/test_dbus.py 2011-01-07 17:24:11 +0000 |
16 | +++ tests/platform/linux/test_dbus.py 2011-01-14 20:00:42 +0000 |
17 | @@ -34,7 +34,6 @@ |
18 | BaseTwistedTestCase, FakeMain, FAKED_CREDENTIALS, |
19 | MementoHandler) |
20 | |
21 | -from ubuntuone.clientdefs import APP_NAME |
22 | from ubuntuone.storageprotocol.sharersp import NotifyShareHolder |
23 | from ubuntuone.syncdaemon import states, config |
24 | from ubuntuone.platform.linux.dbus_interface import ( |
25 | @@ -97,13 +96,14 @@ |
26 | """ |
27 | self.next_login_cb = (callback, args) |
28 | |
29 | + |
30 | class FakeDBusInterface(object): |
31 | """A fake DBusInterface...""" |
32 | |
33 | def shutdown(self, with_restart=False): |
34 | """...that only knows how to go away""" |
35 | |
36 | - def _request_token(self): |
37 | + def _request_token(self, *args, **kwargs): |
38 | """Return a token which is a fixed set of credentials.""" |
39 | return FAKED_CREDENTIALS |
40 | |
41 | @@ -136,7 +136,7 @@ |
42 | self.dbus_iface = DBusInterface(self.bus, self.main, |
43 | system_bus=self.bus) |
44 | # token is a fixed set of credentials |
45 | - self.dbus_iface._request_token = lambda: FAKED_CREDENTIALS |
46 | + self.dbus_iface._request_token = lambda *a, **kw: FAKED_CREDENTIALS |
47 | |
48 | self.main.external = ExternalInterface(self.main, False, False, |
49 | dbus_iface=self.dbus_iface) |
50 | @@ -317,6 +317,10 @@ |
51 | """Fake register.""" |
52 | self._called['register'] = (args, kwargs) |
53 | |
54 | + def find_credentials(self, *args, **kwargs): |
55 | + """Fake find_credentials.""" |
56 | + self._called['find_credentials'] = (args, kwargs) |
57 | + |
58 | |
59 | class FakedBusName(object): |
60 | """Fake a dbus name.""" |
61 | @@ -2493,9 +2497,15 @@ |
62 | |
63 | |
64 | class DBusOAuthTestCase(BaseTwistedTestCase): |
65 | - """Tests the interaction between dbus_interface and ubuntu-sso-client.""" |
66 | + """Tests the interaction between dbus_interface and credentials. |
67 | + |
68 | + Check conditions when autconnecting is False. |
69 | + |
70 | + """ |
71 | |
72 | timeout = 2 |
73 | + method = 'register' |
74 | + autoconnecting = False |
75 | |
76 | def setUp(self): |
77 | """Init.""" |
78 | @@ -2539,8 +2549,8 @@ |
79 | self.assertEqual(self.dbus_iface._signal_handler, cb) |
80 | self.dbus_iface._deferred.callback(None) |
81 | |
82 | - self.patch(FakedSSOBackend, 'register', f) |
83 | - yield self.dbus_iface.connect() |
84 | + self.patch(FakedSSOBackend, self.method, f) |
85 | + yield self.dbus_iface.connect(autoconnecting=self.autoconnecting) |
86 | |
87 | @defer.inlineCallbacks |
88 | def test_signals_are_removed_after_connection(self): |
89 | @@ -2550,8 +2560,8 @@ |
90 | """Just succeed.""" |
91 | self.dbus_iface._deferred.callback(None) |
92 | |
93 | - self.patch(FakedSSOBackend, 'register', f) |
94 | - yield self.dbus_iface.connect() |
95 | + self.patch(FakedSSOBackend, self.method, f) |
96 | + yield self.dbus_iface.connect(autoconnecting=self.autoconnecting) |
97 | self.assertNotIn((DBUS_CREDENTIALS_IFACE, None), self.bus.callbacks) |
98 | |
99 | @defer.inlineCallbacks |
100 | @@ -2560,11 +2570,11 @@ |
101 | |
102 | def f(*a, **kw): |
103 | """Receive credentials.""" |
104 | - self.dbus_iface._signal_handler(APP_NAME, FAKED_CREDENTIALS, |
105 | + self.dbus_iface._signal_handler(FAKED_CREDENTIALS, |
106 | member='CredentialsFound') |
107 | |
108 | - self.patch(FakedSSOBackend, 'register', f) |
109 | - yield self.dbus_iface.connect() |
110 | + self.patch(FakedSSOBackend, self.method, f) |
111 | + yield self.dbus_iface.connect(autoconnecting=self.autoconnecting) |
112 | self.assertEqual(self.events, [('SYS_USER_CONNECT', |
113 | {'access_token': FAKED_CREDENTIALS})]) |
114 | |
115 | @@ -2574,12 +2584,12 @@ |
116 | |
117 | def f(*a, **kw): |
118 | """Receive error signal.""" |
119 | - self.dbus_iface._signal_handler(APP_NAME, 'Error description', |
120 | - 'Detailed error', |
121 | + self.dbus_iface._signal_handler({'error_type': 'Error description', |
122 | + 'error_detail': 'Detailed error'}, |
123 | member='CredentialsError') |
124 | |
125 | - self.patch(FakedSSOBackend, 'register', f) |
126 | - d = self.dbus_iface.connect() |
127 | + self.patch(FakedSSOBackend, self.method, f) |
128 | + d = self.dbus_iface.connect(autoconnecting=self.autoconnecting) |
129 | d.addErrback(lambda failure: self.assertEqual(NoAccessToken, |
130 | failure.type)) |
131 | yield d |
132 | @@ -2590,11 +2600,24 @@ |
133 | |
134 | def f(*a, **kw): |
135 | """Receive error signal.""" |
136 | - self.dbus_iface._signal_handler(APP_NAME, |
137 | - member='AuthorizationDenied') |
138 | - |
139 | - self.patch(FakedSSOBackend, 'register', f) |
140 | - d = self.dbus_iface.connect() |
141 | + self.dbus_iface._signal_handler(member='AuthorizationDenied') |
142 | + |
143 | + self.patch(FakedSSOBackend, self.method, f) |
144 | + d = self.dbus_iface.connect(autoconnecting=self.autoconnecting) |
145 | + d.addErrback(lambda failure: self.assertEqual(NoAccessToken, |
146 | + failure.type)) |
147 | + yield d |
148 | + |
149 | + @defer.inlineCallbacks |
150 | + def test_connect_raises_NoAccessToken_if_no_creds(self): |
151 | + """If no credentials, NoAccessToken if no credentials.""" |
152 | + |
153 | + def f(*a, **kw): |
154 | + """Receive error signal.""" |
155 | + self.dbus_iface._signal_handler(member='CredentialsNotFound') |
156 | + |
157 | + self.patch(FakedSSOBackend, self.method, f) |
158 | + d = self.dbus_iface.connect(autoconnecting=self.autoconnecting) |
159 | d.addErrback(lambda failure: self.assertEqual(NoAccessToken, |
160 | failure.type)) |
161 | yield d |
162 | @@ -2608,8 +2631,8 @@ |
163 | """Just fail.""" |
164 | raise expected |
165 | |
166 | - self.patch(FakedSSOBackend, 'register', f) |
167 | - d = self.dbus_iface.connect() |
168 | + self.patch(FakedSSOBackend, self.method, f) |
169 | + d = self.dbus_iface.connect(autoconnecting=self.autoconnecting) |
170 | d.addErrback(lambda failure: self.assertEqual(expected, failure.value)) |
171 | yield d |
172 | |
173 | @@ -2622,14 +2645,15 @@ |
174 | """Just fail.""" |
175 | raise expected |
176 | |
177 | - self.patch(FakedSSOBackend, 'register', f) |
178 | - d = self.dbus_iface.connect() |
179 | + self.patch(FakedSSOBackend, self.method, f) |
180 | + d = self.dbus_iface.connect(autoconnecting=self.autoconnecting) |
181 | d.addErrback(lambda failure: self.assertEqual(expected, failure.value)) |
182 | yield d |
183 | self.assertTrue(len(self.memento.records) > 0) |
184 | - msg = self.memento.records[0].message |
185 | + record = self.memento.records[1] |
186 | + msg = record.message |
187 | self.assertIn('connect failed while getting the token', msg) |
188 | - self.assertIn(expected, self.memento.records[0].exc_info) |
189 | + self.assertIn(expected, record.exc_info) |
190 | |
191 | def test_oauth_credentials_are_none_at_startup(self): |
192 | """If the oauth_credentials are not passed as param, they are None.""" |
193 | @@ -2644,7 +2668,7 @@ |
194 | 'token_secret': 'faked_token_secret'} |
195 | self.dbus_iface.oauth_credentials = (expected['token'], |
196 | expected['token_secret']) |
197 | - yield self.dbus_iface.connect() |
198 | + yield self.dbus_iface.connect(autoconnecting=self.autoconnecting) |
199 | self.assertEqual(self.events, [('SYS_USER_CONNECT', |
200 | {'access_token': expected})]) |
201 | |
202 | @@ -2659,7 +2683,7 @@ |
203 | expected['consumer_secret'], |
204 | expected['token'], |
205 | expected['token_secret']) |
206 | - yield self.dbus_iface.connect() |
207 | + yield self.dbus_iface.connect(autoconnecting=self.autoconnecting) |
208 | self.assertEqual(self.events, [('SYS_USER_CONNECT', |
209 | {'access_token': expected})]) |
210 | |
211 | @@ -2669,67 +2693,31 @@ |
212 | self.dbus_iface.oauth_credentials = ('consumer_key', |
213 | 'consumer_secret', |
214 | 'token_secret') |
215 | - yield self.dbus_iface.connect() |
216 | + yield self.dbus_iface.connect(autoconnecting=self.autoconnecting) |
217 | self.assertEqual(self.events, []) |
218 | msgs = (str(self.dbus_iface.oauth_credentials), 'useless') |
219 | self.assertTrue(self.memento.check_warning(*msgs)) |
220 | |
221 | - def test_only_log_if_app_name_is_not_correct_when_credentials_found(self): |
222 | - """If the app_name is not ours, just log an INFO message.""" |
223 | - |
224 | - def f(*a, **kw): |
225 | - """Receive wrong app_name.""" |
226 | - self.dbus_iface._signal_handler(APP_NAME * 2, |
227 | - member='CredentialsFound') |
228 | - |
229 | - self.patch(FakedSSOBackend, 'register', f) |
230 | - self.dbus_iface._request_token() |
231 | - |
232 | - self.assertFalse(self.dbus_iface._deferred.called) |
233 | - self.assertTrue(self.memento.check_info('CredentialsFound', |
234 | - APP_NAME * 2)) |
235 | - |
236 | - def test_only_log_if_app_name_is_not_correct_when_credentials_error(self): |
237 | - """If the app_name is not ours, just log an INFO message.""" |
238 | - |
239 | - def f(*a, **kw): |
240 | - """Receive a wrong app_name.""" |
241 | - self.dbus_iface._signal_handler(APP_NAME * 2, |
242 | - member='CredentialsError') |
243 | - |
244 | - self.patch(FakedSSOBackend, 'register', f) |
245 | - self.dbus_iface._request_token() |
246 | - |
247 | - self.assertFalse(self.dbus_iface._deferred.called) |
248 | - self.assertTrue(self.memento.check_info('CredentialsError', |
249 | - APP_NAME * 2)) |
250 | - |
251 | - def test_only_log_if_app_name_is_not_correct_when_authorization_denied(self): |
252 | - """If the app_name is not ours, just log an INFO message.""" |
253 | - |
254 | - def f(*a, **kw): |
255 | - """Receive a wrong app_name.""" |
256 | - self.dbus_iface._signal_handler(APP_NAME * 2, |
257 | - member='AuthorizationDenied') |
258 | - |
259 | - self.patch(FakedSSOBackend, 'register', f) |
260 | - self.dbus_iface._request_token() |
261 | - |
262 | - self.assertFalse(self.dbus_iface._deferred.called) |
263 | - self.assertTrue(self.memento.check_info('AuthorizationDenied', |
264 | - APP_NAME * 2)) |
265 | - |
266 | def test_signal_handler_remains_generic(self): |
267 | """The signal handler function should be generic.""" |
268 | self.dbus_iface._signal_handler() |
269 | # no failure |
270 | - self.assertTrue(self.memento.check_debug('member: None', |
271 | - 'app_name: None')) |
272 | + self.assertTrue(self.memento.check_debug('member: None')) |
273 | |
274 | self.dbus_iface._signal_handler(no_member_kwarg='Test') |
275 | # no failure |
276 | - self.assertTrue(self.memento.check_debug('member: None', |
277 | - 'app_name: None')) |
278 | + self.assertTrue(self.memento.check_debug('member: None')) |
279 | + |
280 | + |
281 | +class DBusOAuthTestCaseRegister(DBusOAuthTestCase): |
282 | + """Tests the interaction between dbus_interface and credentials. |
283 | + |
284 | + Check conditions when autconnecting is True. |
285 | + |
286 | + """ |
287 | + |
288 | + method = 'find_credentials' |
289 | + autoconnecting = True |
290 | |
291 | |
292 | class FolderTests(DBusTwistedTestCase): |
293 | |
294 | === modified file 'tests/syncdaemon/test_main.py' |
295 | --- tests/syncdaemon/test_main.py 2010-12-17 18:19:41 +0000 |
296 | +++ tests/syncdaemon/test_main.py 2011-01-14 20:00:42 +0000 |
297 | @@ -101,7 +101,7 @@ |
298 | """Pass the test when we get this event.""" |
299 | reactor.callLater(0, d0.callback, None) |
300 | |
301 | - main = self.build_main(handshake_timeout=.5) |
302 | + main = self.build_main(handshake_timeout=0) |
303 | |
304 | def fake_connect(*a): |
305 | """Only connect when States told so.""" |
306 | @@ -183,12 +183,13 @@ |
307 | |
308 | self.connect_called = False |
309 | self.patch(main_mod.ubuntuone.platform.ExternalInterface, 'connect', |
310 | - lambda *a: setattr(self, 'connect_called', True)) |
311 | + lambda *a, **kw: setattr(self, 'connect_called', (a, kw))) |
312 | |
313 | main = self.build_main() |
314 | self.addCleanup(lambda: main.shutdown()) |
315 | |
316 | - self.assertTrue(self.connect_called) |
317 | + self.assertEqual(self.connect_called, ((main.external,), |
318 | + {'autoconnecting': True})) |
319 | |
320 | def test_dont_connect_if_autoconnect_is_disabled(self): |
321 | """If autoconnect option is disabled, do not connect the syncdaemon.""" |
322 | @@ -199,7 +200,7 @@ |
323 | |
324 | self.connect_called = False |
325 | self.patch(main_mod.ubuntuone.platform.ExternalInterface, 'connect', |
326 | - lambda *a: setattr(self, 'connect_called', True)) |
327 | + lambda *a, **kw: setattr(self, 'connect_called', True)) |
328 | |
329 | main = self.build_main() |
330 | self.addCleanup(lambda: main.shutdown()) |
331 | |
332 | === modified file 'ubuntuone/platform/linux/__init__.py' |
333 | --- ubuntuone/platform/linux/__init__.py 2010-12-20 12:28:01 +0000 |
334 | +++ ubuntuone/platform/linux/__init__.py 2011-01-14 20:00:42 +0000 |
335 | @@ -83,5 +83,5 @@ |
336 | def shutdown(self, with_restart): |
337 | self.dbus_iface.shutdown(with_restart) |
338 | |
339 | - def connect(self): |
340 | - self.dbus_iface.connect() |
341 | + def connect(self, *args, **kwargs): |
342 | + self.dbus_iface.connect(*args, **kwargs) |
343 | |
344 | === modified file 'ubuntuone/platform/linux/dbus_interface.py' |
345 | --- ubuntuone/platform/linux/dbus_interface.py 2011-01-06 13:54:21 +0000 |
346 | +++ ubuntuone/platform/linux/dbus_interface.py 2011-01-14 20:00:42 +0000 |
347 | @@ -27,10 +27,8 @@ |
348 | |
349 | from twisted.internet import defer |
350 | from twisted.python.failure import Failure |
351 | -from ubuntu_sso import (DBUS_BUS_NAME, DBUS_CREDENTIALS_PATH, |
352 | +from ubuntuone.credentials import (DBUS_BUS_NAME, DBUS_CREDENTIALS_PATH, |
353 | DBUS_CREDENTIALS_IFACE) |
354 | -from ubuntu_sso.credentials import (HELP_TEXT_KEY, PING_URL_KEY, TC_URL_KEY, |
355 | - WINDOW_ID_KEY) |
356 | from ubuntuone.syncdaemon.interfaces import IMarker |
357 | from ubuntuone.syncdaemon import config |
358 | |
359 | @@ -1847,12 +1845,16 @@ |
360 | self.event_queue.push(event) |
361 | |
362 | @defer.inlineCallbacks |
363 | - def connect(self): |
364 | + def connect(self, autoconnecting=False): |
365 | """Push the SYS_USER_CONNECT event with the token. |
366 | |
367 | - The token is requested via ubuntu-sso-client. |
368 | + The token is requested via com.ubuntuone.credentials service. If |
369 | + 'autoconnecting' is True, no UI window will be raised to promt the user |
370 | + for login/registration, only already existent credentials will be used. |
371 | |
372 | """ |
373 | + logger.info('connect was requested. Are we autoconnecting? %r.', |
374 | + autoconnecting) |
375 | if self.oauth_credentials is not None: |
376 | logger.debug('connect: oauth credentials were given by parameter.') |
377 | ckey = csecret = key = secret = None |
378 | @@ -1868,7 +1870,7 @@ |
379 | token = {'consumer_key': ckey, 'consumer_secret': csecret, |
380 | 'token': key, 'token_secret': secret} |
381 | else: |
382 | - token = yield self._request_token() |
383 | + token = yield self._request_token(autoconnecting=autoconnecting) |
384 | |
385 | logger.info('connect: credential request was successful, ' |
386 | 'pushing SYS_USER_CONNECT.') |
387 | @@ -1877,17 +1879,11 @@ |
388 | def _signal_handler(self, *args, **kwargs): |
389 | """Generic signal handler.""" |
390 | member = kwargs.get('member', None) |
391 | - app_name = args[0] if len(args) > 0 else None |
392 | d = self._deferred |
393 | - logger.debug('Handling DBus signal for member: %r, app_name: %r.', |
394 | - member, app_name) |
395 | - |
396 | - if app_name != APP_NAME: |
397 | - logger.info('Received %s but app_name %s does not match %s, ' \ |
398 | - 'exiting.', member, app_name, APP_NAME) |
399 | - return |
400 | - |
401 | - if member in ('CredentialsError', 'AuthorizationDenied'): |
402 | + logger.debug('Handling DBus signal for member: %r.', member) |
403 | + |
404 | + if member in ('CredentialsError', 'AuthorizationDenied', |
405 | + 'CredentialsNotFound'): |
406 | logger.warning('%r: %r %r', member, args, kwargs) |
407 | if not args: |
408 | d.errback(Failure(NoAccessToken(member))) |
409 | @@ -1895,14 +1891,14 @@ |
410 | d.errback(Failure(NoAccessToken("%s: %s %s" % |
411 | (member, args, kwargs)))) |
412 | elif member == 'CredentialsFound' and not d.called: |
413 | - credentials = args[1] |
414 | + credentials = args[0] |
415 | logger.info('%r: callbacking with credentials.', member) |
416 | d.callback(credentials) |
417 | else: |
418 | logger.debug('_signal_handler: member %r not used or deferred ' |
419 | - 'already called? %r.', member, d.called) |
420 | + 'already called? %r.', member, d) |
421 | |
422 | - def _request_token(self): |
423 | + def _request_token(self, autoconnecting): |
424 | """Request to SSO auth service to fetch the token.""" |
425 | self._deferred = d = defer.Deferred() |
426 | |
427 | @@ -1921,12 +1917,13 @@ |
428 | client = self.bus.get_object(DBUS_BUS_NAME, DBUS_CREDENTIALS_PATH, |
429 | follow_name_owner_changes=True) |
430 | iface = dbus.Interface(client, DBUS_CREDENTIALS_IFACE) |
431 | - params = {HELP_TEXT_KEY: DESCRIPTION, TC_URL_KEY: TC_URL, |
432 | - PING_URL_KEY: PING_URL, WINDOW_ID_KEY: '0'} |
433 | - iface.register(APP_NAME, params, |
434 | - # ignore the reply, we get the result via signals |
435 | - reply_handler=lambda: None, |
436 | - error_handler=error_handler) |
437 | + # ignore the reply, we get the result via signals |
438 | + if autoconnecting: |
439 | + iface.find_credentials(reply_handler=lambda: None, |
440 | + error_handler=error_handler) |
441 | + else: |
442 | + iface.register(reply_handler=lambda: None, |
443 | + error_handler=error_handler) |
444 | except DBusException, e: |
445 | error_handler(e) |
446 | except: |
447 | |
448 | === modified file 'ubuntuone/syncdaemon/main.py' |
449 | --- ubuntuone/syncdaemon/main.py 2011-01-07 18:51:45 +0000 |
450 | +++ ubuntuone/syncdaemon/main.py 2011-01-14 20:00:42 +0000 |
451 | @@ -74,7 +74,8 @@ |
452 | def __init__(self, root_dir, shares_dir, data_dir, partials_dir, |
453 | host='fs-1.one.ubuntu.com', port=443, dns_srv=None, ssl=True, |
454 | disable_ssl_verify=False, glib_loop=False, |
455 | - mark_interval=120, broadcast_events=False, handshake_timeout=30, |
456 | + mark_interval=120, broadcast_events=False, |
457 | + handshake_timeout=30, |
458 | shares_symlink_name='Shared With Me', |
459 | read_limit=None, write_limit=None, throttling_enabled=False, |
460 | ignore_files=None, oauth_credentials=None): |
461 | @@ -125,7 +126,7 @@ |
462 | self, glib_loop, broadcast_events) |
463 | self.external.oauth_credentials = oauth_credentials |
464 | if user_config.get_autoconnect(): |
465 | - self.external.connect() |
466 | + self.external.connect(autoconnecting=True) |
467 | |
468 | self.action_q.content_queue.set_change_notification_cb( |
469 | self.external.change_notification) |
So does this stop autoconnecting when there are no tokens, or does it just change it so that if you don't have a token, you won't be able to register when it connects. This seems like the wrong fix to the bug to me.