bridge: added generic D-Bus exception management + asyncCreateProfile method
This commit is contained in:
parent
ff787e5ca4
commit
407ae30ffb
1 changed files with 38 additions and 4 deletions
|
|
@ -27,10 +27,16 @@ import dbus.mainloop.glib
|
|||
from logging import debug, info
|
||||
|
||||
const_INT_PREFIX = "org.goffi.SAT" #Interface prefix
|
||||
const_ERROR_PREFIX = const_INT_PREFIX+".error"
|
||||
const_OBJ_PATH = '/org/goffi/SAT/bridge'
|
||||
const_CORE_SUFFIX = ".core"
|
||||
const_PLUGIN_SUFFIX = ".plugin"
|
||||
|
||||
class GenericException(dbus.DBusException):
|
||||
def __init__(self, name):
|
||||
super(GenericException,self).__init__()
|
||||
self._dbus_error_name = const_ERROR_PREFIX+"."+name
|
||||
|
||||
class DbusObject(dbus.service.Object):
|
||||
|
||||
def __init__(self, bus, path):
|
||||
|
|
@ -134,13 +140,19 @@ class DbusObject(dbus.service.Object):
|
|||
in_signature='s', out_signature='',
|
||||
async_callbacks=('callback', 'errback'))
|
||||
def asyncConnect(self, profile_key="@DEFAULT@", callback=None, errback=None):
|
||||
return self.cb["asyncConnect"](unicode(profile_key), callback, errback)
|
||||
return self.cb["asyncConnect"](unicode(profile_key), callback, lambda arg:errback(GenericException(arg)))
|
||||
|
||||
@dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
|
||||
in_signature='s', out_signature='',
|
||||
async_callbacks=('callback', 'errback'))
|
||||
def asyncCreateProfile(self, profile, callback=None, errback=None):
|
||||
return self.cb["asyncCreateProfile"](unicode(profile), callback, lambda arg:errback(GenericException(arg)))
|
||||
|
||||
@dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
|
||||
in_signature='ssss', out_signature='s',
|
||||
async_callbacks=('callback', 'errback'))
|
||||
def asyncGetParamA(self, name, category, attribute="value", profile_key="@DEFAULT@", callback=None, errback=None):
|
||||
return self.cb["asyncGetParamA"](unicode(name), unicode(category), unicode(attribute), unicode(profile_key), callback, errback)
|
||||
return self.cb["asyncGetParamA"](unicode(name), unicode(category), unicode(attribute), unicode(profile_key), callback, lambda arg:errback(GenericException(arg)))
|
||||
|
||||
@dbus.service.method(const_INT_PREFIX+const_CORE_SUFFIX,
|
||||
in_signature='ssss', out_signature='s',
|
||||
|
|
|
|||
Loading…
Reference in a new issue