Merge lp://qastaging/~verterok/ubuntuone-client/full-status-info into lp://qastaging/ubuntuone-client

Proposed by Guillermo Gonzalez
Status: Merged
Approved by: Rick McBride
Approved revision: 14
Merged at revision: not available
Proposed branch: lp://qastaging/~verterok/ubuntuone-client/full-status-info
Merge into: lp://qastaging/ubuntuone-client
Diff against target: None lines
To merge this branch: bzr merge lp://qastaging/~verterok/ubuntuone-client/full-status-info
Reviewer Review Type Date Requested Status
Rick McBride (community) Approve
dobey (community) Approve
Review via email: mp+6556@code.qastaging.launchpad.net

Commit message

[r=rmcbride, r=dobey] send full status info instead of just the name

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

 This branch change the returned value of current_status and SignalChanged to be a dict with all the attributes of the status. Also updates the applet and the nautilus plugin to use the dict.

12. By Guillermo Gonzalez

merge with trunk

13. By Guillermo Gonzalez

remove elif check

Revision history for this message
dobey (dobey) wrote :

Looks good. Thanks for updating the UI too!

review: Approve
14. By Guillermo Gonzalez

fix default state

Revision history for this message
Rick McBride (rmcbride) wrote :

Awesome!

review: Approve
15. By Guillermo Gonzalez

 fix handle_SYS_STATE_CHANGED in dbus iface to send the full status info

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/ubuntuone-client-applet'
2--- bin/ubuntuone-client-applet 2009-05-13 18:57:52 +0000
3+++ bin/ubuntuone-client-applet 2009-05-13 20:36:47 +0000
4@@ -245,18 +245,19 @@
5 """The sync daemon status changed."""
6 if self.__managed_dir is None:
7 gobject.idle_add(self.__get_root)
8- if str(status) == "OFFLINE" or str(status).startswith("INIT") or \
9- str(status).startswith("READY"):
10+ if status['name'] == "OFFLINE" or \
11+ status['name'].startswith("INIT") or \
12+ status['name'].startswith("READY"):
13 self.set_busy(False)
14 self.set_from_icon_name("ubuntuone-client-offline")
15 self.set_tooltip(TOOLTIP_TITLE + _("Disconnected"))
16 self.__connected = False
17- elif str(status).startswith("IDLE"):
18+ elif status['name'].startswith("IDLE"):
19 self.set_busy(False)
20 self.set_from_icon_name("ubuntuone-client")
21 self.set_tooltip(TOOLTIP_TITLE + _("Idle"))
22 self.__connected = True
23- elif str(status) == "BAD_VERSION":
24+ elif status['name'] == "BAD_VERSION":
25 self.set_busy(False)
26 self.set_from_icon_name("ubuntuone-client-offline")
27 self.set_tooltip(TOOLTIP_TITLE + _("Update Required"))
28@@ -272,7 +273,7 @@
29 n.set_urgency(pynotify.URGENCY_CRITICAL)
30 n.show()
31 logger.debug("Invalid protocol version. Update needed.")
32- elif str(status) == "AUTH_FAILED":
33+ elif status['name'] == "AUTH_FAILED":
34 self.set_busy(False)
35 self.set_from_icon_name("ubuntuone-client-offline")
36 self.set_tooltip(TOOLTIP_TITLE + "Authentication failed")
37@@ -299,16 +300,16 @@
38 else:
39 self.set_busy()
40 self.__connected = True
41- if str(status).startswith("CONNECTING") or \
42- str(status).startswith("AUTHENTICATING") or \
43- str(status).startswith("CONNECTED"):
44+ if status['name'].startswith("CONNECTING") or \
45+ status['name'].startswith("AUTHENTICATING") or \
46+ status['name'].startswith("CONNECTED"):
47 self.set_tooltip(TOOLTIP_TITLE + _("Connecting"))
48- elif str(status).startswith("SCANNING") or \
49- str(status).startswith("READING"):
50+ elif status['name'].startswith("SCANNING") or \
51+ status['name'].startswith("READING"):
52 self.set_tooltip(TOOLTIP_TITLE + _("Scanning"))
53- elif str(status).startswith("WORKING"):
54+ elif status['name'].startswith("WORKING"):
55 self.set_tooltip(TOOLTIP_TITLE + _("Synchronizing"))
56- elif str(status).startswith("UNKNOWN_ERROR"):
57+ elif status['name'].startswith("UNKNOWN_ERROR"):
58 pass
59 else:
60 self.set_tooltip(TOOLTIP_TITLE + _("Working"))
61
62=== modified file 'canonical/ubuntuone/nautilus/storage.py'
63--- canonical/ubuntuone/nautilus/storage.py 2009-05-13 14:15:28 +0000
64+++ canonical/ubuntuone/nautilus/storage.py 2009-05-13 21:08:34 +0000
65@@ -39,6 +39,7 @@
66 from canonical.ubuntuone.storage.syncdaemon.dbus_interface import (
67 DBUS_IFACE_NAME, DBUS_IFACE_SYNC_NAME, DBUS_IFACE_STATUS_NAME,
68 DBUS_IFACE_SHARES_NAME, DBUS_IFACE_FS_NAME)
69+from canonical.ubuntuone.storage.syncdaemon import states
70
71 DBusGMainLoop(set_as_default=True)
72
73@@ -60,7 +61,7 @@
74 self.__path = path
75 self.__connected = False
76 self.__bus = dbus.SessionBus()
77- self.__update_status("OFFLINE")
78+ self.__update_status(states.INIT)
79
80 self.__bus.add_signal_receiver(
81 handler_function=self.__update_status,
82@@ -100,11 +101,15 @@
83
84 def __update_status(self, status):
85 """Update the label, and button when connection status changes."""
86- if str(status) == "OFFLINE" or str(status).startswith("INIT") or \
87- str(status).startswith("READY"):
88+ if not status.get('is_online', False) or \
89+ not status.get('is_connected', False) or \
90+ status['name'].startswith("INIT") or \
91+ status['name'].startswith("READY"):
92 self.__button.set_label(_("Connect"))
93 self.__connected = False
94- elif str(status).startswith("IDLE"):
95+ elif status['name'].startswith("IDLE") or \
96+ status.get('is_connected', False) or \
97+ status.get('is_online', False):
98 self.__button.set_label(_("Disconnect"))
99 self.__connected = True
100
101
102=== modified file 'canonical/ubuntuone/storage/syncdaemon/dbus_interface.py'
103--- canonical/ubuntuone/storage/syncdaemon/dbus_interface.py 2009-05-13 13:38:20 +0000
104+++ canonical/ubuntuone/storage/syncdaemon/dbus_interface.py 2009-05-13 20:36:47 +0000
105@@ -50,6 +50,10 @@
106 dbus.service.Object.__init__(self, bus_name=bus_name,
107 object_path=self.path)
108
109+ def bool_str(self, value):
110+ """ return a string value that can be converted back to bool. """
111+ return 'True' if value else ''
112+
113 @dbus.service.signal(DBUS_IFACE_SYNC_NAME, signature='sa{ss}')
114 def SignalError(self, signal, extra_args):
115 """ An error ocurred while trying to emit a signal. """
116@@ -76,12 +80,18 @@
117 path=self.path)
118
119 @dbus.service.method(DBUS_IFACE_STATUS_NAME,
120- in_signature='', out_signature='s')
121+ in_signature='', out_signature='a{ss}')
122 def current_status(self):
123 """ return the current status of the system, one of: local_rescan,
124 offline, trying_to_connect, server_rescan or online.
125 """
126- return self.dbus_iface.main.state.name
127+ state = self.dbus_iface.main.state.state
128+ state_dict = {'name':state.name,
129+ 'description':state.description,
130+ 'is_error':self.bool_str(state.is_error),
131+ 'is_connected':self.bool_str(state.is_connected),
132+ 'is_online':self.bool_str(state.is_online)}
133+ return state_dict
134
135 @dbus.service.method(DBUS_IFACE_STATUS_NAME, out_signature='aa{ss}')
136 def current_downloads(self):
137@@ -146,9 +156,14 @@
138 """
139 pass
140
141- def emit_status_changed(self, status):
142+ def emit_status_changed(self, state):
143 """ Emits the signal """
144- self.StatusChanged(status)
145+ state_dict = {'name':state.name,
146+ 'description':self.bool_str(state.description),
147+ 'is_error':self.bool_str(state.is_error),
148+ 'is_connected':self.bool_str(state.is_connected),
149+ 'is_online':self.bool_str(state.is_online)}
150+ self.StatusChanged(state_dict)
151
152 def emit_download_started(self, download):
153 """ Emits the signal """
154
155=== modified file 'tests/syncdaemon/test_dbus.py'
156--- tests/syncdaemon/test_dbus.py 2009-05-13 13:38:20 +0000
157+++ tests/syncdaemon/test_dbus.py 2009-05-13 20:36:47 +0000
158@@ -32,6 +32,7 @@
159 from canonical.ubuntuone.storage.syncdaemon.volume_manager import Share
160 from canonical.ubuntuone.storage.syncdaemon.tools import DBusClient
161 from canonical.ubuntuone.storage.syncdaemon import event_queue
162+from canonical.ubuntuone.storage.syncdaemon import states
163 from contrib.testing.testcase import (
164 DBusTwistedTestCase,
165 )
166@@ -50,7 +51,12 @@
167 d = defer.Deferred()
168 def status_handler(result):
169 """ reply handler """
170- self.assertEquals('IDLE', str(result))
171+ state = states.IDLE
172+ self.assertEquals(state.name, result['name'])
173+ self.assertEquals(state.description, result['description'])
174+ self.assertEquals(state.is_error, bool(result['is_error']))
175+ self.assertEquals(state.is_connected, bool(result['is_connected']))
176+ self.assertEquals(state.is_online, bool(result['is_online']))
177 d.callback(True)
178
179 def downloads_handler(result):
180@@ -717,15 +723,28 @@
181 match = self.bus.add_signal_receiver(status_handler,
182 signal_name='StatusChanged')
183 self.signal_receivers.add(match)
184- client.send_signal('StatusChanged', 'IDLE')
185+ bool_str = self.dbus_iface.status.bool_str
186+ state = states.IDLE
187+ state_dict = {'name':state.name,
188+ 'description':state.description,
189+ 'is_error':bool_str(state.is_error),
190+ 'is_connected':bool_str(state.is_connected),
191+ 'is_online':bool_str(state.is_online)}
192+ client.send_signal('StatusChanged', state_dict)
193 ready = self.main.wait_for_nirvana()
194 ready.addCallback(start)
195 d = defer.Deferred()
196- def status_handler(status):
197+ def status_handler(result):
198 """ handler for StatusChanged signal. """
199- self.log.debug('status_handler, received: %r' % status)
200- self.assertEquals('IDLE', status)
201+ self.log.debug('status_handler, received: %r' % result)
202+ state = states.IDLE
203+ self.assertEquals(state.name, result['name'])
204+ self.assertEquals(state.description, result['description'])
205+ self.assertEquals(state.is_error, bool(result['is_error']))
206+ self.assertEquals(state.is_connected, bool(result['is_connected']))
207+ self.assertEquals(state.is_online, bool(result['is_online']))
208 d.callback(True)
209+
210 return d
211
212 def test_all_events_signal(self):
213@@ -873,9 +892,8 @@
214 self.main.event_q.push('AQ_CREATE_SHARE_ERROR', marker, error_msg)
215 return d
216
217- def test_singal_error(self):
218+ def test_signal_error(self):
219 """ test sending SignalError. """
220- client = DBusClient(self.bus, '/status', DBUS_IFACE_STATUS_NAME)
221 d = defer.Deferred()
222 def error_handler(type, args):
223 """ Error signal handler. """

Subscribers

People subscribed via source and target branches