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

Subscribers

People subscribed via source and target branches