comparison src/bridge/bridge_constructor/bridge_contructor.py @ 419:6c167a2e04b8

bridge: added generic D-Bus exception management + asyncCreateProfile method
author Goffi <goffi@goffi.org>
date Wed, 02 Nov 2011 22:47:59 +0100
parents 3646f6b9adb6
children 6c20c76abdcc
comparison
equal deleted inserted replaced
418:199cf4ebcc74 419:6c167a2e04b8
391 elif function["type"] == "method": 391 elif function["type"] == "method":
392 completion['debug'] = "" if not self.options.debug else 'debug ("%s")\n%s' % (section,8*' ') 392 completion['debug'] = "" if not self.options.debug else 'debug ("%s")\n%s' % (section,8*' ')
393 completion['args_result'] = self.getArguments(function['sig_in'], name=arg_doc, unicode_protect=self.options.unicode) 393 completion['args_result'] = self.getArguments(function['sig_in'], name=arg_doc, unicode_protect=self.options.unicode)
394 completion['async_comma'] = ', ' if async and function['sig_in'] else '' 394 completion['async_comma'] = ', ' if async and function['sig_in'] else ''
395 completion['async_args_def'] = 'callback=None, errback=None' if async else '' 395 completion['async_args_def'] = 'callback=None, errback=None' if async else ''
396 completion['async_args_call'] = 'callback, errback' if async else '' 396 completion['async_args_call'] = 'callback, lambda arg:errback(GenericException(arg))' if async else ''
397 completion['async_callbacks'] = "('callback', 'errback')" if async else "None" 397 completion['async_callbacks'] = "('callback', 'errback')" if async else "None"
398 methods_part.append("""\ 398 methods_part.append("""\
399 @dbus.service.method(const_INT_PREFIX+const_%(category)s_SUFFIX, 399 @dbus.service.method(const_INT_PREFIX+const_%(category)s_SUFFIX,
400 in_signature='%(sig_in)s', out_signature='%(sig_out)s', 400 in_signature='%(sig_in)s', out_signature='%(sig_out)s',
401 async_callbacks=%(async_callbacks)s) 401 async_callbacks=%(async_callbacks)s)
453 if function["type"] == "method": 453 if function["type"] == "method":
454 completion['debug'] = "" if not self.options.debug else 'debug ("%s")\n%s' % (section,8*' ') 454 completion['debug'] = "" if not self.options.debug else 'debug ("%s")\n%s' % (section,8*' ')
455 completion['args_result'] = self.getArguments(function['sig_in'], name=arg_doc) 455 completion['args_result'] = self.getArguments(function['sig_in'], name=arg_doc)
456 completion['async_args'] = ', callback=None, errback=None' if async else '' 456 completion['async_args'] = ', callback=None, errback=None' if async else ''
457 completion['async_comma'] = ', ' if async and function['sig_in'] else '' 457 completion['async_comma'] = ', ' if async and function['sig_in'] else ''
458 completion['async_args_result'] = 'reply_handler=callback, error_handler=errback' if async else '' 458 completion['async_args_result'] = 'reply_handler=callback, error_handler=lambda err:errback(err._dbus_error_name[len(const_ERROR_PREFIX)+1:])' if async else ''
459 result = "self.db_%(category)s_iface.%(name)s(%(args_result)s%(async_comma)s%(async_args_result)s)" % completion 459 result = "self.db_%(category)s_iface.%(name)s(%(args_result)s%(async_comma)s%(async_args_result)s)" % completion
460 completion['result'] = ("unicode(%s)" if self.options.unicode and function['sig_out'] == 's' else "%s") % result 460 completion['result'] = ("unicode(%s)" if self.options.unicode and function['sig_out'] == 's' else "%s") % result
461 methods_part.append("""\ 461 methods_part.append("""\
462 def %(name)s(self, %(args)s%(async_args)s): 462 def %(name)s(self, %(args)s%(async_args)s):
463 %(debug)sreturn %(result)s 463 %(debug)sreturn %(result)s