Merge lp:~nataliabidart/ubuntuone-control-panel/more-logging-and-ids into lp:ubuntuone-control-panel

Proposed by Natalia Bidart
Status: Merged
Approved by: Natalia Bidart
Approved revision: 36
Merged at revision: 35
Proposed branch: lp:~nataliabidart/ubuntuone-control-panel/more-logging-and-ids
Merge into: lp:ubuntuone-control-panel
Diff against target: 330 lines (+69/-24)
5 files modified
bin/ubuntuone-control-panel-backend (+2/-0)
bin/ubuntuone-control-panel-gtk (+4/-3)
ubuntuone/controlpanel/backend.py (+9/-1)
ubuntuone/controlpanel/dbus_service.py (+47/-19)
ubuntuone/controlpanel/integrationtests/test_dbus_service.py (+7/-1)
To merge this branch: bzr merge lp:~nataliabidart/ubuntuone-control-panel/more-logging-and-ids
Reviewer Review Type Date Requested Status
Roman Yepishev (community) code Approve
Martin Albisetti (community) Approve
Review via email: mp+43974@code.launchpad.net

Commit message

* Added logging to dbus_service and backend.
* Error signals now sent the object id when available (LP: #691292).

Description of the change

Run the tests with:

./run-tests

To post a comment you must log in.
Revision history for this message
Martin Albisetti (beuno) :
review: Approve
Revision history for this message
Roman Yepishev (rye) wrote :

Looks ok. Tested by running it and finding nothing broken.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/ubuntuone-control-panel-backend'
2--- bin/ubuntuone-control-panel-backend 2010-09-25 06:20:41 +0000
3+++ bin/ubuntuone-control-panel-backend 2010-12-16 21:10:31 +0000
4@@ -18,6 +18,8 @@
5 # with this program. If not, see <http://www.gnu.org/licenses/>.
6 """Execute the DBus backend for the Ubuntu One control panel."""
7
8+# Invalid name "ubuntuone-control-panel-backend", pylint: disable=C0103
9+
10
11 from ubuntuone.controlpanel import dbus_service
12
13
14=== modified file 'bin/ubuntuone-control-panel-gtk'
15--- bin/ubuntuone-control-panel-gtk 2010-11-10 15:55:33 +0000
16+++ bin/ubuntuone-control-panel-gtk 2010-12-16 21:10:31 +0000
17@@ -18,7 +18,7 @@
18 # with this program. If not, see <http://www.gnu.org/licenses/>.
19 """Execute the graphical interface for the Ubuntu One control panel."""
20
21-import gtk
22+# Invalid name "ubuntuone-control-panel-gtk", pylint: disable=C0103
23
24 import dbus.mainloop.glib
25
26@@ -26,6 +26,7 @@
27
28 dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
29
30+
31 if __name__ == "__main__":
32- ui = ubuntuone.controlpanel.gtk.gui.ControlPanelWindow()
33- ui.main()
34+ gui = ubuntuone.controlpanel.gtk.gui.ControlPanelWindow()
35+ gui.main()
36
37=== modified file 'ubuntuone/controlpanel/backend.py'
38--- ubuntuone/controlpanel/backend.py 2010-12-13 22:13:05 +0000
39+++ ubuntuone/controlpanel/backend.py 2010-12-16 21:10:31 +0000
40@@ -124,6 +124,7 @@
41 credentials = yield dbus_client.get_credentials()
42 returnValue(credentials["token"])
43
44+ @log_call(logger.debug)
45 @inlineCallbacks
46 def account_info(self):
47 """Get the user account info."""
48@@ -140,6 +141,7 @@
49
50 returnValue(result)
51
52+ @log_call(logger.debug)
53 @inlineCallbacks
54 def devices_info(self):
55 """Get the user devices info."""
56@@ -184,6 +186,7 @@
57 return DEVICE_TYPE_PHONE, device_id[5:]
58 return "No device", device_id
59
60+ @log_call(logger.info)
61 @inlineCallbacks
62 def change_device_settings(self, device_id, settings):
63 """Change the settings for the given device."""
64@@ -214,6 +217,7 @@
65 # still pending: more work on the settings dict (LP: #673674)
66 returnValue(device_id)
67
68+ @log_call(logger.warning)
69 @inlineCallbacks
70 def remove_device(self, device_id):
71 """Remove a device's tokens from the sso server."""
72@@ -222,7 +226,7 @@
73 yield self.wc.call_api(api)
74 returnValue(device_id)
75
76- @log_call(logger.info)
77+ @log_call(logger.debug)
78 @inlineCallbacks
79 def file_sync_status(self):
80 """Return the status of the file sync service."""
81@@ -233,6 +237,7 @@
82 status = {}
83 returnValue(self._process_file_sync_status(status))
84
85+ @log_call(logger.debug)
86 @inlineCallbacks
87 def volumes_info(self):
88 """Get the volumes info."""
89@@ -240,6 +245,7 @@
90 # later, we may request shares info as well
91 returnValue(result)
92
93+ @log_call(logger.debug)
94 @inlineCallbacks
95 def change_volume_settings(self, volume_id, settings):
96 """Change settings for 'volume_id'.
97@@ -268,11 +274,13 @@
98 # is a folder or a share
99 yield dbus_client.unsubscribe_folder(volume_id)
100
101+ @log_call(logger.debug)
102 def query_bookmark_extension(self):
103 """True if the bookmark extension has been installed."""
104 # still pending (LP: #673672)
105 returnValue(False)
106
107+ @log_call(logger.debug)
108 def install_bookmarks_extension(self):
109 """Install the extension to sync bookmarks."""
110 # still pending (LP: #673673)
111
112=== modified file 'ubuntuone/controlpanel/dbus_service.py'
113--- ubuntuone/controlpanel/dbus_service.py 2010-12-13 20:20:51 +0000
114+++ ubuntuone/controlpanel/dbus_service.py 2010-12-16 21:10:31 +0000
115@@ -80,10 +80,14 @@
116 With this call, a Failure is transformed into a string-string dict.
117
118 """
119- def inner(error, *a):
120+ def inner(error, _=None):
121 """Do the Failure transformation."""
122 error_dict = error_handler(error)
123- return f(error_dict)
124+ if _ is not None:
125+ result = f(_, error_dict)
126+ else:
127+ result = f(error_dict)
128+ return result
129
130 return inner
131
132@@ -102,6 +106,7 @@
133
134 # pylint: disable=C0103
135
136+ @log_call(logger.debug)
137 @method(dbus_interface=DBUS_PREFERENCES_IFACE, in_signature="")
138 def account_info(self):
139 """Find out the account info for the current logged in user."""
140@@ -109,16 +114,19 @@
141 d.addCallback(self.AccountInfoReady)
142 d.addErrback(transform_failure(self.AccountInfoError))
143
144+ @log_call(logger.debug)
145 @signal(dbus_interface=DBUS_PREFERENCES_IFACE, signature="a{ss}")
146 def AccountInfoReady(self, info):
147 """The info for the current user is available right now."""
148
149+ @log_call(logger.error)
150 @signal(dbus_interface=DBUS_PREFERENCES_IFACE, signature="a{ss}")
151 def AccountInfoError(self, error):
152 """The info for the current user is currently unavailable."""
153
154 #---
155
156+ @log_call(logger.debug)
157 @method(dbus_interface=DBUS_PREFERENCES_IFACE, in_signature="")
158 def devices_info(self):
159 """Find out the devices info for the logged in user."""
160@@ -126,46 +134,55 @@
161 d.addCallback(self.DevicesInfoReady)
162 d.addErrback(transform_failure(self.DevicesInfoError))
163
164+ @log_call(logger.debug)
165 @signal(dbus_interface=DBUS_PREFERENCES_IFACE, signature="aa{ss}")
166 def DevicesInfoReady(self, info):
167 """The info for the devices is available right now."""
168
169+ @log_call(logger.error)
170 @signal(dbus_interface=DBUS_PREFERENCES_IFACE, signature="a{ss}")
171 def DevicesInfoError(self, error):
172 """The info for the devices is currently unavailable."""
173
174 #---
175
176+ @log_call(logger.info)
177 @method(dbus_interface=DBUS_PREFERENCES_IFACE, in_signature="sa{ss}")
178- def change_device_settings(self, token, settings):
179+ def change_device_settings(self, device_id, settings):
180 """Configure a given device."""
181- d = self.backend.change_device_settings(token, settings)
182+ d = self.backend.change_device_settings(device_id, settings)
183 d.addCallback(self.DeviceSettingsChanged)
184- d.addErrback(transform_failure(self.DeviceSettingsChangeError))
185+ d.addErrback(transform_failure(self.DeviceSettingsChangeError),
186+ device_id)
187
188+ @log_call(logger.info)
189 @signal(dbus_interface=DBUS_PREFERENCES_IFACE, signature="s")
190- def DeviceSettingsChanged(self, token):
191+ def DeviceSettingsChanged(self, device_id):
192 """The settings for the device were changed."""
193
194- @signal(dbus_interface=DBUS_PREFERENCES_IFACE, signature="a{ss}")
195- def DeviceSettingsChangeError(self, error):
196+ @log_call(logger.error)
197+ @signal(dbus_interface=DBUS_PREFERENCES_IFACE, signature="sa{ss}")
198+ def DeviceSettingsChangeError(self, device_id, error):
199 """Problem changing settings for the device."""
200
201 #---
202
203+ @log_call(logger.warning)
204 @method(dbus_interface=DBUS_PREFERENCES_IFACE, in_signature="s")
205- def remove_device(self, token):
206+ def remove_device(self, device_id):
207 """Remove a given device."""
208- d = self.backend.remove_device(token)
209+ d = self.backend.remove_device(device_id)
210 d.addCallback(self.DeviceRemoved)
211- d.addErrback(transform_failure(self.DeviceRemovalError))
212+ d.addErrback(transform_failure(self.DeviceRemovalError), device_id)
213
214+ @log_call(logger.warning)
215 @signal(dbus_interface=DBUS_PREFERENCES_IFACE, signature="s")
216- def DeviceRemoved(self, token):
217+ def DeviceRemoved(self, device_id):
218 """The removal for the device was completed."""
219
220- @signal(dbus_interface=DBUS_PREFERENCES_IFACE, signature="a{ss}")
221- def DeviceRemovalError(self, error):
222+ @log_call(logger.error)
223+ @signal(dbus_interface=DBUS_PREFERENCES_IFACE, signature="sa{ss}")
224+ def DeviceRemovalError(self, device_id, error):
225 """Problem removing the device."""
226
227 #---
228@@ -192,7 +209,7 @@
229 else:
230 self.FileSyncStatusError(error_handler(status_dict))
231
232- @log_call(logger.info)
233+ @log_call(logger.debug)
234 @method(dbus_interface=DBUS_PREFERENCES_IFACE, in_signature="")
235 def file_sync_status(self):
236 """Get the status of the file sync service."""
237@@ -232,6 +249,7 @@
238
239 #---
240
241+ @log_call(logger.debug)
242 @method(dbus_interface=DBUS_PREFERENCES_IFACE, in_signature="")
243 def volumes_info(self):
244 """Find out the volumes info for the logged in user."""
245@@ -251,23 +269,28 @@
246
247 #---
248
249+ @log_call(logger.info)
250 @method(dbus_interface=DBUS_PREFERENCES_IFACE, in_signature="sa{ss}")
251 def change_volume_settings(self, volume_id, settings):
252 """Configure a given volume."""
253 d = self.backend.change_volume_settings(volume_id, settings)
254 d.addCallback(self.VolumeSettingsChanged)
255- d.addErrback(transform_failure(self.VolumeSettingsChangeError))
256+ d.addErrback(transform_failure(self.VolumeSettingsChangeError),
257+ volume_id)
258
259+ @log_call(logger.info)
260 @signal(dbus_interface=DBUS_PREFERENCES_IFACE, signature="s")
261- def VolumeSettingsChanged(self, token):
262+ def VolumeSettingsChanged(self, volume_id):
263 """The settings for the volume were changed."""
264
265- @signal(dbus_interface=DBUS_PREFERENCES_IFACE, signature="a{ss}")
266- def VolumeSettingsChangeError(self, error):
267+ @log_call(logger.error)
268+ @signal(dbus_interface=DBUS_PREFERENCES_IFACE, signature="sa{ss}")
269+ def VolumeSettingsChangeError(self, volume_id, error):
270 """Problem changing settings for the volume."""
271
272 #---
273
274+ @log_call(logger.debug)
275 @method(dbus_interface=DBUS_PREFERENCES_IFACE, in_signature="")
276 def query_bookmark_extension(self):
277 """Check if the extension to sync bookmarks is installed."""
278@@ -275,16 +298,19 @@
279 d.addCallback(self.QueryBookmarksResult)
280 d.addErrback(transform_failure(self.QueryBookmarksError))
281
282+ @log_call(logger.debug)
283 @signal(dbus_interface=DBUS_PREFERENCES_IFACE, signature="b")
284 def QueryBookmarksResult(self, enabled):
285 """The bookmark extension is or is not installed."""
286
287+ @log_call(logger.error)
288 @signal(dbus_interface=DBUS_PREFERENCES_IFACE, signature="a{ss}")
289 def QueryBookmarksError(self, error):
290 """Problem getting the status of the extension."""
291
292 #---
293
294+ @log_call(logger.info)
295 @method(dbus_interface=DBUS_PREFERENCES_IFACE, in_signature="")
296 def install_bookmarks_extension(self):
297 """Install the extension to sync bookmarks."""
298@@ -292,10 +318,12 @@
299 d.addCallback(lambda _: self.InstallBookmarksSuccess())
300 d.addErrback(transform_failure(self.InstallBookmarksError))
301
302+ @log_call(logger.info)
303 @signal(dbus_interface=DBUS_PREFERENCES_IFACE, signature="")
304 def InstallBookmarksSuccess(self):
305 """The extension to sync bookmarks has been installed."""
306
307+ @log_call(logger.error)
308 @signal(dbus_interface=DBUS_PREFERENCES_IFACE, signature="a{ss}")
309 def InstallBookmarksError(self, error):
310 """Problem installing the extension to sync bookmarks."""
311
312=== modified file 'ubuntuone/controlpanel/integrationtests/test_dbus_service.py'
313--- ubuntuone/controlpanel/integrationtests/test_dbus_service.py 2010-12-13 22:13:05 +0000
314+++ ubuntuone/controlpanel/integrationtests/test_dbus_service.py 2010-12-16 21:10:31 +0000
315@@ -449,8 +449,14 @@
316
317 """
318
319- def got_error_signal(error_dict):
320+ def got_error_signal(*a):
321 """The error signal was received."""
322+ if len(a) == 1:
323+ error_dict = a[0]
324+ else:
325+ an_id, error_dict = a
326+ self.assertEqual(an_id, args[0])
327+
328 self.assertEqual(error_dict[dbus_service.ERROR_TYPE],
329 'AssertionError')
330 self.deferred.callback("success")

Subscribers

People subscribed via source and target branches