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

Proposed by Guillermo Gonzalez
Status: Superseded
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) Abstain
Review via email: mp+6553@code.launchpad.net

This proposal has been superseded by a proposal from 2009-05-14.

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

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

Revision history for this message
dobey (dobey) wrote :

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 :

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 :

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?

11. By Guillermo Gonzalez

 quit syncdaemon with the applet, and turn off autoconnect

Unmerged revisions

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 'canonical/ubuntuone/storage/syncdaemon/dbus_interface.py'
57--- canonical/ubuntuone/storage/syncdaemon/dbus_interface.py 2009-05-13 13:38:20 +0000
58+++ canonical/ubuntuone/storage/syncdaemon/dbus_interface.py 2009-05-13 19:58:44 +0000
59@@ -369,6 +369,15 @@
60 items = [(mdobj.share_id, mdobj.node_id, "")]
61 self.dbus_iface.action_queue.query(items)
62
63+ @dbus.service.method(DBUS_IFACE_SYNC_NAME,
64+ in_signature='', out_signature='',
65+ async_callbacks=('reply_handler', 'error_handler'))
66+ def quit(self, reply_handler=None, error_handler=None):
67+ """ shutdown the syncdaemon. """
68+ self.dbus_iface.log.debug('Quit requested')
69+ if reply_handler:
70+ reply_handler()
71+ self.dbus_iface.quit()
72
73 class FileSystem(DBusExposedObject):
74 """ A dbus interface to the FileSystem Manager. """
75@@ -645,3 +654,7 @@
76 """ Push the SYS_DISCONNECT event. """
77 self.event_queue.push('SYS_DISCONNECT')
78
79+ def quit(self):
80+ """ calls Main.quit. """
81+ self.log.debug('Calling Main.quit')
82+ self.main.quit()
83
84=== modified file 'docs/man/u1sdtool.1'
85--- docs/man/u1sdtool.1 2009-05-13 15:33:22 +0000
86+++ docs/man/u1sdtool.1 2009-05-13 19:58:44 +0000
87@@ -34,6 +34,9 @@
88 .br
89 .B u1sdtool
90 \-\-current-transfers
91+.br
92+.B u1sdtool
93+\-\-quit
94
95 .SH DESCRIPTION
96 u1sdtool is a command line command line utility for controlling
97@@ -46,7 +49,7 @@
98 .SH OPTIONS
99 .TP
100 \fB\-\-wait\fR
101-Wait until SyncDaemon reaches nirvana (no more events, uploads and/or downloads)
102+Wait until ubuntuone-syncdaemon reachs nirvana
103 .TP
104 \fB\-\-accept-share\fR=\fISHARE_ID\fR
105 accept the share with the specified id
106@@ -108,6 +111,10 @@
107 .TP
108 \fB\-\-current-transfers\fR
109 Show the current uploads and downloads
110+.TP
111+\fB\-\-quit
112+shutdown ubuntuone-syncdaemon
113+
114 .SH AUTHOR
115 This manual page was written by Guillermo Gonzalez <guillermo.gonzalez@canonical.com>.
116
117
118=== modified file 'tests/syncdaemon/test_dbus.py'
119--- tests/syncdaemon/test_dbus.py 2009-05-13 13:38:20 +0000
120+++ tests/syncdaemon/test_dbus.py 2009-05-13 19:58:44 +0000
121@@ -512,6 +512,23 @@
122 error_handler=self.error_handler)
123 return d
124
125+ def test_quit(self):
126+ """ test the quit exposed method. """
127+ client = DBusClient(self.bus, '/', DBUS_IFACE_SYNC_NAME)
128+ d = defer.Deferred()
129+ # helper functions, we need to call quit but don't quit
130+ # pylint: disable-msg=C0111,W0601,W0602
131+ def fake_quit():
132+ pass
133+ self.main.quit = fake_quit
134+ def handler(result):
135+ d.callback(True)
136+ d.addCallback(lambda result: self.assertTrue(result))
137+ client.call_method('quit',
138+ reply_handler=handler,
139+ error_handler=self.error_handler)
140+ return d
141+
142
143 class DBusInterfaceUnicodeTests(DBusTwistedTestCase):
144 """ Unicode variant of basic tests to the objects exposed with D-Bus"""

Subscribers

People subscribed via source and target branches