Web · Wiki · Activities · Blog · Lists · Chat · Meeting · Bugs · Git · Translate · Archive · People · Donate

Commit d22ae3e8c80e828cfa2dff04efb73e2c1eda79ba

Log all exceptions for D-Bus methods

For easier debugging, log any exception we pass through to the caller.
  
1717"""
1818
1919import ast
20import functools
2021import hashlib
2122import logging
2223import os
7979 return self.__unicode__()
8080
8181
82def method_log_exception(func):
83 @functools.wraps(func)
84 def wrapper(*args, **kwargs):
85 try:
86 return func(*args, **kwargs)
87 except:
88 logging.exception('Exception encountered:')
89 raise
90 return wrapper
91
92
8293class DBusApiNativeV1(dbus.service.Object):
8394 """Native gdatastore D-Bus API
8495 """
127127 # pylint: disable-msg=C0103
128128 pass
129129
130 @method_log_exception
130131 @dbus.service.method(DBUS_INTERFACE_NATIVE_V1,
131132 in_signature='a{sv}ay', out_signature='ss',
132133 async_callbacks=('async_cb', 'async_err_cb'),
145145 async_cb=async_cb,
146146 async_err_cb=async_err_cb)
147147
148 @method_log_exception
148149 @dbus.service.method(DBUS_INTERFACE_NATIVE_V1,
149150 in_signature='a{sv}h', out_signature='ss',
150151 async_callbacks=('async_cb', 'async_err_cb'),
166166 async_cb=async_cb,
167167 async_err_cb=async_err_cb)
168168
169 @method_log_exception
169170 @dbus.service.method(DBUS_INTERFACE_NATIVE_V1,
170171 in_signature='ssa{sv}ay', out_signature='s',
171172 async_callbacks=('async_cb', 'async_err_cb'),
191191 async_cb=success_cb,
192192 async_err_cb=async_err_cb)
193193
194 @method_log_exception
194195 @dbus.service.method(DBUS_INTERFACE_NATIVE_V1,
195196 in_signature='ssa{sv}h', out_signature='s',
196197 async_callbacks=('async_cb', 'async_err_cb'),
222222 async_cb=success_cb,
223223 async_err_cb=async_err_cb)
224224
225 @method_log_exception
225226 @dbus.service.method(DBUS_INTERFACE_NATIVE_V1,
226227 in_signature='ssa{sv}', out_signature='',
227228 byte_arrays=True)
233233 object_id = (tree_id, version_id)
234234 self._internal_api.change_metadata(object_id, metadata)
235235
236 @method_log_exception
236237 @dbus.service.method(DBUS_INTERFACE_NATIVE_V1,
237238 in_signature='ss', out_signature='')
238239 def delete(self, tree_id, version_id):
239240 object_id = (tree_id, version_id)
240241 self._internal_api.delete(object_id)
241242
243 @method_log_exception
242244 @dbus.service.method(DBUS_INTERFACE_NATIVE_V1,
243245 in_signature='a{sv}a{sv}', out_signature='aa{sv}u',
244246 byte_arrays=True)
245247 def find(self, query_dict, options):
246248 return self._internal_api.find(query_dict, options)
247249
250 @method_log_exception
248251 @dbus.service.method(DBUS_INTERFACE_NATIVE_V1,
249252 in_signature='ss', out_signature='ay',
250253 sender_keyword='sender')
255255 object_id = (tree_id, version_id)
256256 return self._internal_api.get_data_path(object_id, sender=sender)
257257
258 @method_log_exception
258259 @dbus.service.method(DBUS_INTERFACE_NATIVE_V1,
259260 in_signature='ss', out_signature='h',
260261 sender_keyword='sender')
264264 path = self._internal_api.get_data_path(object_id, sender=sender)
265265 return os.open(path, os.O_RDONLY)
266266
267 @method_log_exception
267268 @dbus.service.method(DBUS_INTERFACE_NATIVE_V1,
268269 in_signature='ss', out_signature='a{sv}')
269270 def get_metadata(self, tree_id, version_id):
270271 object_id = (tree_id, version_id)
271272 return self._internal_api.get_properties(object_id)
272273
274 @method_log_exception
273275 @dbus.service.method(DBUS_INTERFACE_NATIVE_V1,
274276 in_signature='a{sv}sa{sv}', out_signature='aa{sv}u',
275277 byte_arrays=True)
276278 def text_search(self, query_dict, query_string, options):
277279 return self._internal_api.find(query_dict, options, query_string)
278280
281 @method_log_exception
279282 @dbus.service.method(DBUS_INTERFACE_NATIVE_V1,
280283 in_signature='sssa{sv}ay', out_signature='ss',
281284 async_callbacks=('async_cb', 'async_err_cb'),
298298 async_cb=async_cb,
299299 async_err_cb=async_err_cb)
300300
301 @method_log_exception
301302 @dbus.service.method(DBUS_INTERFACE_NATIVE_V1,
302303 in_signature='sssa{sv}s', out_signature='ss',
303304 async_callbacks=('async_cb', 'async_err_cb'),
355355 self._internal_api.add_callback('delete', self.__delete_cb)
356356 self._internal_api.add_callback('save', self.__save_cb)
357357
358 @method_log_exception
358359 @dbus.service.method(DBUS_INTERFACE_SUGAR_V2,
359360 in_signature='a{sv}sb', out_signature='s',
360361 async_callbacks=('async_cb', 'async_err_cb'),
376376 # pylint: disable-msg=C0103
377377 pass
378378
379 @method_log_exception
379380 @dbus.service.method(DBUS_INTERFACE_SUGAR_V2,
380381 in_signature='sa{sv}sb', out_signature='',
381382 async_callbacks=('async_cb', 'async_err_cb'),
407407 # pylint: disable-msg=C0103
408408 pass
409409
410 @method_log_exception
410411 @dbus.service.method(DBUS_INTERFACE_SUGAR_V2,
411412 in_signature='a{sv}as', out_signature='aa{sv}u')
412413 def find(self, query, properties):
432432
433433 return results, count
434434
435 @method_log_exception
435436 @dbus.service.method(DBUS_INTERFACE_SUGAR_V2,
436437 in_signature='s', out_signature='s',
437438 sender_keyword='sender')
444444 object_id = (uid, latest_versions[0]['version_id'])
445445 return self._internal_api.get_data_path(object_id, sender=sender)
446446
447 @method_log_exception
447448 @dbus.service.method(DBUS_INTERFACE_SUGAR_V2,
448449 in_signature='s', out_signature='a{sv}')
449450 def get_properties(self, uid):
456456 del latest_versions[0]['version_id']
457457 return latest_versions[0]
458458
459 @method_log_exception
459460 @dbus.service.method(DBUS_INTERFACE_SUGAR_V2,
460461 in_signature='sa{sv}', out_signature='as')
461462 def get_uniquevaluesfor(self, propertyname, query=None):
462463 return self._internal_api.find_unique_values(query, propertyname)
463464
465 @method_log_exception
464466 @dbus.service.method(DBUS_INTERFACE_SUGAR_V2,
465467 in_signature='s', out_signature='')
466468 def delete(self, uid):