Merge lp:~chipaca/ubuntuone-client/fix-u1launch into lp:ubuntuone-client

Proposed by John Lenton
Status: Merged
Approved by: Rodrigo Moya
Approved revision: 687
Merged at revision: 684
Proposed branch: lp:~chipaca/ubuntuone-client/fix-u1launch
Merge into: lp:ubuntuone-client
Diff against target: 123 lines (+64/-19)
1 file modified
bin/ubuntuone-launch (+64/-19)
To merge this branch: bzr merge lp:~chipaca/ubuntuone-client/fix-u1launch
Reviewer Review Type Date Requested Status
Rodrigo Moya (community) Approve
Roman Yepishev (community) fieldtest Approve
Review via email: mp+34924@code.launchpad.net

Commit message

makes ubuntuone-launch work with the new sso (fixes LP:631822). Also, waits for READY before asking for connection (meliorates LP:525743 and LP:518027).

Description of the change

makes ubuntuone-launch work with the new sso (fixes LP:631822). Also, waits for READY before asking for connection (meliorates LP:525743 and LP:518027).

To post a comment you must log in.
Revision history for this message
John Lenton (chipaca) wrote :

oh, forgot to mention, it also does not try to start syncdaemon if file sync is disabled (rather than trying and having syncdaemon come back with "nope")

Revision history for this message
Roman Yepishev (rye) wrote :

Traceback (most recent call last):
  File "/usr/bin/ubuntuone-launch", line 38, in <module>
    from ubuntuone.syncdaemon.clientdefs import APP_NAME as SD_APP_NAME
ImportError: No module named clientdefs

Boo!

review: Needs Fixing (fieldtest)
686. By John Lenton

clientdefs is not usually in ubuntuone.syncdaemon :)

Revision history for this message
Roman Yepishev (rye) wrote :

I have something in my system that calls syncdaemon early on login - will find it later since that does not look like ubuntuone-launch.

review: Approve (fieldtest)
687. By John Lenton

added a module docstring summarizing what ubuntuone-launch does

Revision history for this message
Rodrigo Moya (rodrigo-moya) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/ubuntuone-launch'
2--- bin/ubuntuone-launch 2010-03-31 16:12:39 +0000
3+++ bin/ubuntuone-launch 2010-09-09 01:41:11 +0000
4@@ -17,11 +17,30 @@
5 #
6 # You should have received a copy of the GNU General Public License along
7 # with this program. If not, see <http://www.gnu.org/licenses/>.
8-
9+"""
10+Ubuntu One storage synchronization daemon (syncdaemon) startup helper.
11+
12+This script decides whether to start and connect syncdaemon.
13+
14+ * If you've never used Ubuntu One file sync, or if you've disabled
15+ file sync via ubuntuone-preferences (or equivalently via setting
16+ files_sync_enabled to False in the syncdaemon configuration file),
17+ syncdaemon is not started, and nothing happens as a result of this
18+ script being run.
19+
20+ * otherwise if syncdaemon is not already running it is started, and
21+ local rescan is allowed to finish.
22+
23+ * if syncdaemon has never synced to the server, or if there are no
24+ credentials for Ubuntu One in the keyring, nothing further happens.
25+
26+ * otherwise, syncdaemon is asked to connect.
27+
28+"""
29 import sys
30 import os
31
32-U1ROOT=os.path.expanduser('~/Ubuntu One/')
33+U1ROOT = os.path.expanduser('~/Ubuntu One/')
34
35 if __name__ == '__main__':
36 # this check is done early to speed up startup on people who are not
37@@ -33,23 +52,40 @@
38 import dbus
39 import glib
40 import gobject
41-import gnomekeyring
42 from dbus.mainloop.glib import DBusGMainLoop
43 from ubuntuone.syncdaemon.tools import SyncDaemonTool, is_running
44+from ubuntuone.clientdefs import APP_NAME as SD_APP_NAME
45+from ubuntu_sso.main import SSOCredentials
46 from twisted.internet import defer
47
48+
49 def stage_two(node, sync_daemon_tool):
50- """do the last few checks and ask for a connect if all is ok"""
51- d = None
52- if node['node_id'] is not None:
53- items = gnomekeyring.find_items_sync(
54- gnomekeyring.ITEM_GENERIC_SECRET,
55- {'ubuntuone-realm': 'https://ubuntuone.com'})
56- if items:
57+ """Do the last few checks and ask for a connect if all is ok."""
58+ # if the node_id of the root node is None, the user has never
59+ # connected. Do not connect in that case.
60+ if node.get('node_id', '') is None:
61+ d = defer.fail(RuntimeError("never connected?"))
62+ else:
63+ # one last check: avoid having sso pop up asking for creds if
64+ # the user deleted them
65+
66+ # XXX: that this works with None is probably excessive
67+ # chumminess with the implementation
68+ creds = SSOCredentials(None)
69+ if creds.find_credentials(SD_APP_NAME):
70 d = sync_daemon_tool.connect()
71- if d is None:
72- d = defer.fail(RuntimeError("bad node"))
73- return d
74+ else:
75+ d = defer.fail(RuntimeError("no creds"))
76+ return d
77+
78+
79+def wait_for_ready(_, sync_daemon_tool):
80+ """Wait for syncdaemon to be READY."""
81+ d = sync_daemon_tool.wait_for_signal(
82+ 'StatusChanged',
83+ lambda a: a.get('name', '') == 'READY')
84+ return d
85+
86
87 def main():
88 """Start syncdaemon and ask it to connect, if possible."""
89@@ -58,13 +94,21 @@
90 bus = dbus.SessionBus(mainloop=loop)
91 sync_daemon_tool = SyncDaemonTool(bus)
92
93- if not is_running():
94- try:
95- d = sync_daemon_tool.start()
96- except dbus.exception.DBusException, e:
97- d = defer.fail(e)
98+ if sync_daemon_tool.is_files_sync_enabled():
99+ if not is_running():
100+ try:
101+ # have SD start
102+ d = sync_daemon_tool.start()
103+ d.addCallback(wait_for_ready, sync_daemon_tool)
104+ except dbus.exception.DBusException, e:
105+ # some dbus error, shouldn't happen, bail out
106+ d = defer.fail(e)
107+ else:
108+ # SD is already running
109+ d = defer.succeed(True)
110 else:
111- d = defer.succeed(True)
112+ # SD will not start (has been disabled by user)
113+ d = defer.fail(RuntimeError("File sync is disabled"))
114
115 d.addCallback(lambda _: sync_daemon_tool.get_metadata(U1ROOT))
116 d.addCallback(stage_two, sync_daemon_tool)
117@@ -74,5 +118,6 @@
118 mainloop = glib.MainLoop()
119 mainloop.run()
120
121+
122 if __name__ == '__main__':
123 main()

Subscribers

People subscribed via source and target branches