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
=== modified file 'bin/ubuntuone-control-panel-backend'
--- bin/ubuntuone-control-panel-backend 2010-09-25 06:20:41 +0000
+++ bin/ubuntuone-control-panel-backend 2010-12-16 21:10:31 +0000
@@ -18,6 +18,8 @@
18# with this program. If not, see <http://www.gnu.org/licenses/>.18# with this program. If not, see <http://www.gnu.org/licenses/>.
19"""Execute the DBus backend for the Ubuntu One control panel."""19"""Execute the DBus backend for the Ubuntu One control panel."""
2020
21# Invalid name "ubuntuone-control-panel-backend", pylint: disable=C0103
22
2123
22from ubuntuone.controlpanel import dbus_service24from ubuntuone.controlpanel import dbus_service
2325
2426
=== modified file 'bin/ubuntuone-control-panel-gtk'
--- bin/ubuntuone-control-panel-gtk 2010-11-10 15:55:33 +0000
+++ bin/ubuntuone-control-panel-gtk 2010-12-16 21:10:31 +0000
@@ -18,7 +18,7 @@
18# with this program. If not, see <http://www.gnu.org/licenses/>.18# with this program. If not, see <http://www.gnu.org/licenses/>.
19"""Execute the graphical interface for the Ubuntu One control panel."""19"""Execute the graphical interface for the Ubuntu One control panel."""
2020
21import gtk21# Invalid name "ubuntuone-control-panel-gtk", pylint: disable=C0103
2222
23import dbus.mainloop.glib23import dbus.mainloop.glib
2424
@@ -26,6 +26,7 @@
2626
27dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)27dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
2828
29
29if __name__ == "__main__":30if __name__ == "__main__":
30 ui = ubuntuone.controlpanel.gtk.gui.ControlPanelWindow()31 gui = ubuntuone.controlpanel.gtk.gui.ControlPanelWindow()
31 ui.main()32 gui.main()
3233
=== modified file 'ubuntuone/controlpanel/backend.py'
--- ubuntuone/controlpanel/backend.py 2010-12-13 22:13:05 +0000
+++ ubuntuone/controlpanel/backend.py 2010-12-16 21:10:31 +0000
@@ -124,6 +124,7 @@
124 credentials = yield dbus_client.get_credentials()124 credentials = yield dbus_client.get_credentials()
125 returnValue(credentials["token"])125 returnValue(credentials["token"])
126126
127 @log_call(logger.debug)
127 @inlineCallbacks128 @inlineCallbacks
128 def account_info(self):129 def account_info(self):
129 """Get the user account info."""130 """Get the user account info."""
@@ -140,6 +141,7 @@
140141
141 returnValue(result)142 returnValue(result)
142143
144 @log_call(logger.debug)
143 @inlineCallbacks145 @inlineCallbacks
144 def devices_info(self):146 def devices_info(self):
145 """Get the user devices info."""147 """Get the user devices info."""
@@ -184,6 +186,7 @@
184 return DEVICE_TYPE_PHONE, device_id[5:]186 return DEVICE_TYPE_PHONE, device_id[5:]
185 return "No device", device_id187 return "No device", device_id
186188
189 @log_call(logger.info)
187 @inlineCallbacks190 @inlineCallbacks
188 def change_device_settings(self, device_id, settings):191 def change_device_settings(self, device_id, settings):
189 """Change the settings for the given device."""192 """Change the settings for the given device."""
@@ -214,6 +217,7 @@
214 # still pending: more work on the settings dict (LP: #673674)217 # still pending: more work on the settings dict (LP: #673674)
215 returnValue(device_id)218 returnValue(device_id)
216219
220 @log_call(logger.warning)
217 @inlineCallbacks221 @inlineCallbacks
218 def remove_device(self, device_id):222 def remove_device(self, device_id):
219 """Remove a device's tokens from the sso server."""223 """Remove a device's tokens from the sso server."""
@@ -222,7 +226,7 @@
222 yield self.wc.call_api(api)226 yield self.wc.call_api(api)
223 returnValue(device_id)227 returnValue(device_id)
224228
225 @log_call(logger.info)229 @log_call(logger.debug)
226 @inlineCallbacks230 @inlineCallbacks
227 def file_sync_status(self):231 def file_sync_status(self):
228 """Return the status of the file sync service."""232 """Return the status of the file sync service."""
@@ -233,6 +237,7 @@
233 status = {}237 status = {}
234 returnValue(self._process_file_sync_status(status))238 returnValue(self._process_file_sync_status(status))
235239
240 @log_call(logger.debug)
236 @inlineCallbacks241 @inlineCallbacks
237 def volumes_info(self):242 def volumes_info(self):
238 """Get the volumes info."""243 """Get the volumes info."""
@@ -240,6 +245,7 @@
240 # later, we may request shares info as well245 # later, we may request shares info as well
241 returnValue(result)246 returnValue(result)
242247
248 @log_call(logger.debug)
243 @inlineCallbacks249 @inlineCallbacks
244 def change_volume_settings(self, volume_id, settings):250 def change_volume_settings(self, volume_id, settings):
245 """Change settings for 'volume_id'.251 """Change settings for 'volume_id'.
@@ -268,11 +274,13 @@
268 # is a folder or a share274 # is a folder or a share
269 yield dbus_client.unsubscribe_folder(volume_id)275 yield dbus_client.unsubscribe_folder(volume_id)
270276
277 @log_call(logger.debug)
271 def query_bookmark_extension(self):278 def query_bookmark_extension(self):
272 """True if the bookmark extension has been installed."""279 """True if the bookmark extension has been installed."""
273 # still pending (LP: #673672)280 # still pending (LP: #673672)
274 returnValue(False)281 returnValue(False)
275282
283 @log_call(logger.debug)
276 def install_bookmarks_extension(self):284 def install_bookmarks_extension(self):
277 """Install the extension to sync bookmarks."""285 """Install the extension to sync bookmarks."""
278 # still pending (LP: #673673)286 # still pending (LP: #673673)
279287
=== modified file 'ubuntuone/controlpanel/dbus_service.py'
--- ubuntuone/controlpanel/dbus_service.py 2010-12-13 20:20:51 +0000
+++ ubuntuone/controlpanel/dbus_service.py 2010-12-16 21:10:31 +0000
@@ -80,10 +80,14 @@
80 With this call, a Failure is transformed into a string-string dict.80 With this call, a Failure is transformed into a string-string dict.
8181
82 """82 """
83 def inner(error, *a):83 def inner(error, _=None):
84 """Do the Failure transformation."""84 """Do the Failure transformation."""
85 error_dict = error_handler(error)85 error_dict = error_handler(error)
86 return f(error_dict)86 if _ is not None:
87 result = f(_, error_dict)
88 else:
89 result = f(error_dict)
90 return result
8791
88 return inner92 return inner
8993
@@ -102,6 +106,7 @@
102106
103 # pylint: disable=C0103107 # pylint: disable=C0103
104108
109 @log_call(logger.debug)
105 @method(dbus_interface=DBUS_PREFERENCES_IFACE, in_signature="")110 @method(dbus_interface=DBUS_PREFERENCES_IFACE, in_signature="")
106 def account_info(self):111 def account_info(self):
107 """Find out the account info for the current logged in user."""112 """Find out the account info for the current logged in user."""
@@ -109,16 +114,19 @@
109 d.addCallback(self.AccountInfoReady)114 d.addCallback(self.AccountInfoReady)
110 d.addErrback(transform_failure(self.AccountInfoError))115 d.addErrback(transform_failure(self.AccountInfoError))
111116
117 @log_call(logger.debug)
112 @signal(dbus_interface=DBUS_PREFERENCES_IFACE, signature="a{ss}")118 @signal(dbus_interface=DBUS_PREFERENCES_IFACE, signature="a{ss}")
113 def AccountInfoReady(self, info):119 def AccountInfoReady(self, info):
114 """The info for the current user is available right now."""120 """The info for the current user is available right now."""
115121
122 @log_call(logger.error)
116 @signal(dbus_interface=DBUS_PREFERENCES_IFACE, signature="a{ss}")123 @signal(dbus_interface=DBUS_PREFERENCES_IFACE, signature="a{ss}")
117 def AccountInfoError(self, error):124 def AccountInfoError(self, error):
118 """The info for the current user is currently unavailable."""125 """The info for the current user is currently unavailable."""
119126
120 #---127 #---
121128
129 @log_call(logger.debug)
122 @method(dbus_interface=DBUS_PREFERENCES_IFACE, in_signature="")130 @method(dbus_interface=DBUS_PREFERENCES_IFACE, in_signature="")
123 def devices_info(self):131 def devices_info(self):
124 """Find out the devices info for the logged in user."""132 """Find out the devices info for the logged in user."""
@@ -126,46 +134,55 @@
126 d.addCallback(self.DevicesInfoReady)134 d.addCallback(self.DevicesInfoReady)
127 d.addErrback(transform_failure(self.DevicesInfoError))135 d.addErrback(transform_failure(self.DevicesInfoError))
128136
137 @log_call(logger.debug)
129 @signal(dbus_interface=DBUS_PREFERENCES_IFACE, signature="aa{ss}")138 @signal(dbus_interface=DBUS_PREFERENCES_IFACE, signature="aa{ss}")
130 def DevicesInfoReady(self, info):139 def DevicesInfoReady(self, info):
131 """The info for the devices is available right now."""140 """The info for the devices is available right now."""
132141
142 @log_call(logger.error)
133 @signal(dbus_interface=DBUS_PREFERENCES_IFACE, signature="a{ss}")143 @signal(dbus_interface=DBUS_PREFERENCES_IFACE, signature="a{ss}")
134 def DevicesInfoError(self, error):144 def DevicesInfoError(self, error):
135 """The info for the devices is currently unavailable."""145 """The info for the devices is currently unavailable."""
136146
137 #---147 #---
138148
149 @log_call(logger.info)
139 @method(dbus_interface=DBUS_PREFERENCES_IFACE, in_signature="sa{ss}")150 @method(dbus_interface=DBUS_PREFERENCES_IFACE, in_signature="sa{ss}")
140 def change_device_settings(self, token, settings):151 def change_device_settings(self, device_id, settings):
141 """Configure a given device."""152 """Configure a given device."""
142 d = self.backend.change_device_settings(token, settings)153 d = self.backend.change_device_settings(device_id, settings)
143 d.addCallback(self.DeviceSettingsChanged)154 d.addCallback(self.DeviceSettingsChanged)
144 d.addErrback(transform_failure(self.DeviceSettingsChangeError))155 d.addErrback(transform_failure(self.DeviceSettingsChangeError),
156 device_id)
145157
158 @log_call(logger.info)
146 @signal(dbus_interface=DBUS_PREFERENCES_IFACE, signature="s")159 @signal(dbus_interface=DBUS_PREFERENCES_IFACE, signature="s")
147 def DeviceSettingsChanged(self, token):160 def DeviceSettingsChanged(self, device_id):
148 """The settings for the device were changed."""161 """The settings for the device were changed."""
149162
150 @signal(dbus_interface=DBUS_PREFERENCES_IFACE, signature="a{ss}")163 @log_call(logger.error)
151 def DeviceSettingsChangeError(self, error):164 @signal(dbus_interface=DBUS_PREFERENCES_IFACE, signature="sa{ss}")
165 def DeviceSettingsChangeError(self, device_id, error):
152 """Problem changing settings for the device."""166 """Problem changing settings for the device."""
153167
154 #---168 #---
155169
170 @log_call(logger.warning)
156 @method(dbus_interface=DBUS_PREFERENCES_IFACE, in_signature="s")171 @method(dbus_interface=DBUS_PREFERENCES_IFACE, in_signature="s")
157 def remove_device(self, token):172 def remove_device(self, device_id):
158 """Remove a given device."""173 """Remove a given device."""
159 d = self.backend.remove_device(token)174 d = self.backend.remove_device(device_id)
160 d.addCallback(self.DeviceRemoved)175 d.addCallback(self.DeviceRemoved)
161 d.addErrback(transform_failure(self.DeviceRemovalError))176 d.addErrback(transform_failure(self.DeviceRemovalError), device_id)
162177
178 @log_call(logger.warning)
163 @signal(dbus_interface=DBUS_PREFERENCES_IFACE, signature="s")179 @signal(dbus_interface=DBUS_PREFERENCES_IFACE, signature="s")
164 def DeviceRemoved(self, token):180 def DeviceRemoved(self, device_id):
165 """The removal for the device was completed."""181 """The removal for the device was completed."""
166182
167 @signal(dbus_interface=DBUS_PREFERENCES_IFACE, signature="a{ss}")183 @log_call(logger.error)
168 def DeviceRemovalError(self, error):184 @signal(dbus_interface=DBUS_PREFERENCES_IFACE, signature="sa{ss}")
185 def DeviceRemovalError(self, device_id, error):
169 """Problem removing the device."""186 """Problem removing the device."""
170187
171 #---188 #---
@@ -192,7 +209,7 @@
192 else:209 else:
193 self.FileSyncStatusError(error_handler(status_dict))210 self.FileSyncStatusError(error_handler(status_dict))
194211
195 @log_call(logger.info)212 @log_call(logger.debug)
196 @method(dbus_interface=DBUS_PREFERENCES_IFACE, in_signature="")213 @method(dbus_interface=DBUS_PREFERENCES_IFACE, in_signature="")
197 def file_sync_status(self):214 def file_sync_status(self):
198 """Get the status of the file sync service."""215 """Get the status of the file sync service."""
@@ -232,6 +249,7 @@
232249
233 #---250 #---
234251
252 @log_call(logger.debug)
235 @method(dbus_interface=DBUS_PREFERENCES_IFACE, in_signature="")253 @method(dbus_interface=DBUS_PREFERENCES_IFACE, in_signature="")
236 def volumes_info(self):254 def volumes_info(self):
237 """Find out the volumes info for the logged in user."""255 """Find out the volumes info for the logged in user."""
@@ -251,23 +269,28 @@
251269
252 #---270 #---
253271
272 @log_call(logger.info)
254 @method(dbus_interface=DBUS_PREFERENCES_IFACE, in_signature="sa{ss}")273 @method(dbus_interface=DBUS_PREFERENCES_IFACE, in_signature="sa{ss}")
255 def change_volume_settings(self, volume_id, settings):274 def change_volume_settings(self, volume_id, settings):
256 """Configure a given volume."""275 """Configure a given volume."""
257 d = self.backend.change_volume_settings(volume_id, settings)276 d = self.backend.change_volume_settings(volume_id, settings)
258 d.addCallback(self.VolumeSettingsChanged)277 d.addCallback(self.VolumeSettingsChanged)
259 d.addErrback(transform_failure(self.VolumeSettingsChangeError))278 d.addErrback(transform_failure(self.VolumeSettingsChangeError),
279 volume_id)
260280
281 @log_call(logger.info)
261 @signal(dbus_interface=DBUS_PREFERENCES_IFACE, signature="s")282 @signal(dbus_interface=DBUS_PREFERENCES_IFACE, signature="s")
262 def VolumeSettingsChanged(self, token):283 def VolumeSettingsChanged(self, volume_id):
263 """The settings for the volume were changed."""284 """The settings for the volume were changed."""
264285
265 @signal(dbus_interface=DBUS_PREFERENCES_IFACE, signature="a{ss}")286 @log_call(logger.error)
266 def VolumeSettingsChangeError(self, error):287 @signal(dbus_interface=DBUS_PREFERENCES_IFACE, signature="sa{ss}")
288 def VolumeSettingsChangeError(self, volume_id, error):
267 """Problem changing settings for the volume."""289 """Problem changing settings for the volume."""
268290
269 #---291 #---
270292
293 @log_call(logger.debug)
271 @method(dbus_interface=DBUS_PREFERENCES_IFACE, in_signature="")294 @method(dbus_interface=DBUS_PREFERENCES_IFACE, in_signature="")
272 def query_bookmark_extension(self):295 def query_bookmark_extension(self):
273 """Check if the extension to sync bookmarks is installed."""296 """Check if the extension to sync bookmarks is installed."""
@@ -275,16 +298,19 @@
275 d.addCallback(self.QueryBookmarksResult)298 d.addCallback(self.QueryBookmarksResult)
276 d.addErrback(transform_failure(self.QueryBookmarksError))299 d.addErrback(transform_failure(self.QueryBookmarksError))
277300
301 @log_call(logger.debug)
278 @signal(dbus_interface=DBUS_PREFERENCES_IFACE, signature="b")302 @signal(dbus_interface=DBUS_PREFERENCES_IFACE, signature="b")
279 def QueryBookmarksResult(self, enabled):303 def QueryBookmarksResult(self, enabled):
280 """The bookmark extension is or is not installed."""304 """The bookmark extension is or is not installed."""
281305
306 @log_call(logger.error)
282 @signal(dbus_interface=DBUS_PREFERENCES_IFACE, signature="a{ss}")307 @signal(dbus_interface=DBUS_PREFERENCES_IFACE, signature="a{ss}")
283 def QueryBookmarksError(self, error):308 def QueryBookmarksError(self, error):
284 """Problem getting the status of the extension."""309 """Problem getting the status of the extension."""
285310
286 #---311 #---
287312
313 @log_call(logger.info)
288 @method(dbus_interface=DBUS_PREFERENCES_IFACE, in_signature="")314 @method(dbus_interface=DBUS_PREFERENCES_IFACE, in_signature="")
289 def install_bookmarks_extension(self):315 def install_bookmarks_extension(self):
290 """Install the extension to sync bookmarks."""316 """Install the extension to sync bookmarks."""
@@ -292,10 +318,12 @@
292 d.addCallback(lambda _: self.InstallBookmarksSuccess())318 d.addCallback(lambda _: self.InstallBookmarksSuccess())
293 d.addErrback(transform_failure(self.InstallBookmarksError))319 d.addErrback(transform_failure(self.InstallBookmarksError))
294320
321 @log_call(logger.info)
295 @signal(dbus_interface=DBUS_PREFERENCES_IFACE, signature="")322 @signal(dbus_interface=DBUS_PREFERENCES_IFACE, signature="")
296 def InstallBookmarksSuccess(self):323 def InstallBookmarksSuccess(self):
297 """The extension to sync bookmarks has been installed."""324 """The extension to sync bookmarks has been installed."""
298325
326 @log_call(logger.error)
299 @signal(dbus_interface=DBUS_PREFERENCES_IFACE, signature="a{ss}")327 @signal(dbus_interface=DBUS_PREFERENCES_IFACE, signature="a{ss}")
300 def InstallBookmarksError(self, error):328 def InstallBookmarksError(self, error):
301 """Problem installing the extension to sync bookmarks."""329 """Problem installing the extension to sync bookmarks."""
302330
=== modified file 'ubuntuone/controlpanel/integrationtests/test_dbus_service.py'
--- ubuntuone/controlpanel/integrationtests/test_dbus_service.py 2010-12-13 22:13:05 +0000
+++ ubuntuone/controlpanel/integrationtests/test_dbus_service.py 2010-12-16 21:10:31 +0000
@@ -449,8 +449,14 @@
449449
450 """450 """
451451
452 def got_error_signal(error_dict):452 def got_error_signal(*a):
453 """The error signal was received."""453 """The error signal was received."""
454 if len(a) == 1:
455 error_dict = a[0]
456 else:
457 an_id, error_dict = a
458 self.assertEqual(an_id, args[0])
459
454 self.assertEqual(error_dict[dbus_service.ERROR_TYPE],460 self.assertEqual(error_dict[dbus_service.ERROR_TYPE],
455 'AssertionError')461 'AssertionError')
456 self.deferred.callback("success")462 self.deferred.callback("success")

Subscribers

People subscribed via source and target branches