Merge lp:~verterok/ubuntuone-client/dbus-quit into lp:ubuntuone-client

Proposed by Guillermo Gonzalez
Status: Merged
Approved by: dobey
Approved revision: 11
Merged at revision: not available
Proposed branch: lp:~verterok/ubuntuone-client/dbus-quit
Merge into: lp:ubuntuone-client
Diff against target: None lines
To merge this branch: bzr merge lp:~verterok/ubuntuone-client/dbus-quit
Reviewer Review Type Date Requested Status
dobey (community) Approve
John Lenton (community) Approve
Review via email: mp+6583@code.launchpad.net

This proposal supersedes a proposal from 2009-05-13.

Commit message

[r=chipaca, r=dobey] Expose quit via DBus, add --quit option to u1sdtool and quit syncdaemon when the applet quit menu option is clicked

To post a comment you must log in.
Revision history for this message
Guillermo Gonzalez (verterok) wrote : Posted in a previous version of this proposal

 Expose quit via Dbus and add --quit option to u1sdtool

Revision history for this message
dobey (dobey) wrote : Posted in a previous version of this proposal

If you could update the applet to call quit instead of disconnect for the quit menu item callback as well, this would also fix bug #365103.

review: Abstain
Revision history for this message
Guillermo Gonzalez (verterok) wrote : Posted in a previous version of this proposal

sure, I'll do that

On Wed, May 13, 2009 at 7:17 PM, Rodney Dawes
<email address hidden> wrote:
> Review: Abstain
> If you could update the applet to call quit instead of disconnect for the quit menu item callback as well, this would also fix bug #365103.
> --
> https://code.edge.launchpad.net/~verterok/ubuntuone-client/dbus-quit/+merge/6553
> You are the owner of lp:~verterok/ubuntuone-client/dbus-quit.
>

Revision history for this message
Guillermo Gonzalez (verterok) wrote : Posted in a previous version of this proposal

After testing this a bit, if I click quit on applet, and the daemon is stopped, it'll started again by nautilus as soon the user open it (via the dbus call).
Maybe the nautilus plugin should support an "stooped" daemon?

Revision history for this message
Guillermo Gonzalez (verterok) wrote :

 Expose quit via Dbus and add --quit option to u1sdtool and quit syncdaemon when the applet quit menu option is clicked.

Revision history for this message
John Lenton (chipaca) wrote :

excellent.

review: Approve
Revision history for this message
dobey (dobey) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/u1sdtool'
2--- bin/u1sdtool 2009-05-13 15:33:22 +0000
3+++ bin/u1sdtool 2009-05-13 19:58:44 +0000
4@@ -26,6 +26,7 @@
5 import warnings
6
7 from canonical.ubuntuone.storage.syncdaemon.tools import SyncDaemonTool
8+from canonical.ubuntuone.storage.syncdaemon.dbus_interface import DBUS_IFACE_NAME
9 from dbus.mainloop.glib import DBusGMainLoop
10 from optparse import OptionParser
11 from twisted.internet import reactor
12@@ -35,7 +36,7 @@
13 usage = "Usage: %prog [option]"
14 parser = OptionParser(usage=usage)
15 parser.add_option("-w", "--wait", dest="wait", action="store_true",
16- help="Wait until SyncDaemon reachs nirvana")
17+ help="Wait until ubuntuone-syncdaemon reachs nirvana")
18 parser.add_option("", "--accept-share", dest="accept_share",
19 metavar="SHARE_ID",
20 help="accept the share with the specified id")
21@@ -62,6 +63,8 @@
22 parser.add_option("", "--current-transfers", dest="current_transfers",
23 action="store_true",
24 help=" show the current uploads and downloads")
25+ parser.add_option("-q", "--quit", dest="quit", action='store_true',
26+ help="shutdown the syncdaemon")
27
28 (options, args) = parser.parse_args(argv)
29
30@@ -72,7 +75,7 @@
31 if options.wait:
32 def callback(result):
33 """ wait_for_nirvana callback (stop the reactor and exit)"""
34- print "\nSyncDaemon became a fully enlightened Buddha!"
35+ print "\nubuntuone-syncdaemon became a fully enlightened Buddha!"
36
37 d = sync_daemon_tool.wait_for_nirvana(verbose=True)
38 d.addCallbacks(callback)
39@@ -154,6 +157,15 @@
40 d.addCallback(show_uploads)
41 d.addCallback(lambda _: sync_daemon_tool.get_current_downloads())
42 d.addCallback(show_downloads)
43+ elif options.quit:
44+ d = sync_daemon_tool.quit()
45+ def shutdown_check(result):
46+ if result is None and \
47+ DBUS_IFACE_NAME in bus.list_names():
48+ print "ubuntuone-syncdaemon stopped"
49+ else:
50+ print "ubuntuone-syncdaemon still running."
51+ d.addBoth(shutdown_check)
52 else:
53 parser.print_help()
54 sys.exit(0)
55
56=== modified file 'bin/ubuntuone-client-applet'
57--- bin/ubuntuone-client-applet 2009-05-13 18:57:52 +0000
58+++ bin/ubuntuone-client-applet 2009-05-14 15:04:58 +0000
59@@ -479,7 +479,7 @@
60 button, timestamp, icon)
61
62 def __quit_applet(self, menuitem, data=None):
63- """Disconnects the daemon and closes the applet."""
64+ """Quit the daemon and closes the applet."""
65 def handler():
66 """Simple handler to make dbus do stuff async."""
67 pass
68@@ -487,7 +487,7 @@
69 try:
70 client = self.__bus.get_object(DBUS_IFACE_NAME, "/")
71 iface = dbus.Interface(client, DBUS_IFACE_SYNC_NAME)
72- iface.disconnect(reply_handler=handler, error_handler=handler)
73+ iface.quit(reply_handler=handler, error_handler=handler)
74 except DBusException:
75 pass
76
77
78=== modified file 'bin/ubuntuone-syncdaemon'
79--- bin/ubuntuone-syncdaemon 2009-05-12 13:36:05 +0000
80+++ bin/ubuntuone-syncdaemon 2009-05-14 15:04:58 +0000
81@@ -140,9 +140,6 @@
82 signal.signal(signal.SIGINT, handler)
83
84 reactor.callWhenRunning(install_handlers)
85- # manually call connect(), this call is going to executed via DBus
86- # by the applet
87- reactor.callLater(1, main.dbus_iface.sync.connect)
88 # set the application name
89 gobject.set_application_name('ubuntuone-syncdaemon')
90 reactor.run()
91
92=== modified file 'canonical/ubuntuone/storage/syncdaemon/dbus_interface.py'
93--- canonical/ubuntuone/storage/syncdaemon/dbus_interface.py 2009-05-13 13:38:20 +0000
94+++ canonical/ubuntuone/storage/syncdaemon/dbus_interface.py 2009-05-13 19:58:44 +0000
95@@ -369,6 +369,15 @@
96 items = [(mdobj.share_id, mdobj.node_id, "")]
97 self.dbus_iface.action_queue.query(items)
98
99+ @dbus.service.method(DBUS_IFACE_SYNC_NAME,
100+ in_signature='', out_signature='',
101+ async_callbacks=('reply_handler', 'error_handler'))
102+ def quit(self, reply_handler=None, error_handler=None):
103+ """ shutdown the syncdaemon. """
104+ self.dbus_iface.log.debug('Quit requested')
105+ if reply_handler:
106+ reply_handler()
107+ self.dbus_iface.quit()
108
109 class FileSystem(DBusExposedObject):
110 """ A dbus interface to the FileSystem Manager. """
111@@ -645,3 +654,7 @@
112 """ Push the SYS_DISCONNECT event. """
113 self.event_queue.push('SYS_DISCONNECT')
114
115+ def quit(self):
116+ """ calls Main.quit. """
117+ self.log.debug('Calling Main.quit')
118+ self.main.quit()
119
120=== modified file 'docs/man/u1sdtool.1'
121--- docs/man/u1sdtool.1 2009-05-13 15:33:22 +0000
122+++ docs/man/u1sdtool.1 2009-05-13 19:58:44 +0000
123@@ -34,6 +34,9 @@
124 .br
125 .B u1sdtool
126 \-\-current-transfers
127+.br
128+.B u1sdtool
129+\-\-quit
130
131 .SH DESCRIPTION
132 u1sdtool is a command line command line utility for controlling
133@@ -46,7 +49,7 @@
134 .SH OPTIONS
135 .TP
136 \fB\-\-wait\fR
137-Wait until SyncDaemon reaches nirvana (no more events, uploads and/or downloads)
138+Wait until ubuntuone-syncdaemon reachs nirvana
139 .TP
140 \fB\-\-accept-share\fR=\fISHARE_ID\fR
141 accept the share with the specified id
142@@ -108,6 +111,10 @@
143 .TP
144 \fB\-\-current-transfers\fR
145 Show the current uploads and downloads
146+.TP
147+\fB\-\-quit
148+shutdown ubuntuone-syncdaemon
149+
150 .SH AUTHOR
151 This manual page was written by Guillermo Gonzalez <guillermo.gonzalez@canonical.com>.
152
153
154=== modified file 'tests/syncdaemon/test_dbus.py'
155--- tests/syncdaemon/test_dbus.py 2009-05-13 13:38:20 +0000
156+++ tests/syncdaemon/test_dbus.py 2009-05-13 19:58:44 +0000
157@@ -512,6 +512,23 @@
158 error_handler=self.error_handler)
159 return d
160
161+ def test_quit(self):
162+ """ test the quit exposed method. """
163+ client = DBusClient(self.bus, '/', DBUS_IFACE_SYNC_NAME)
164+ d = defer.Deferred()
165+ # helper functions, we need to call quit but don't quit
166+ # pylint: disable-msg=C0111,W0601,W0602
167+ def fake_quit():
168+ pass
169+ self.main.quit = fake_quit
170+ def handler(result):
171+ d.callback(True)
172+ d.addCallback(lambda result: self.assertTrue(result))
173+ client.call_method('quit',
174+ reply_handler=handler,
175+ error_handler=self.error_handler)
176+ return d
177+
178
179 class DBusInterfaceUnicodeTests(DBusTwistedTestCase):
180 """ Unicode variant of basic tests to the objects exposed with D-Bus"""

Subscribers

People subscribed via source and target branches