bridge: DBusException also transports the twisted failure condition
This commit is contained in:
parent
8867ac6c60
commit
bba25dd62d
1 changed files with 45 additions and 5 deletions
|
|
@ -27,6 +27,8 @@ from sat.core.exceptions import BridgeExceptionNoService, BridgeInitError
|
|||
from dbus.mainloop.glib import DBusGMainLoop
|
||||
DBusGMainLoop(set_as_default=True)
|
||||
|
||||
import ast
|
||||
|
||||
const_INT_PREFIX = "org.goffi.SAT" # Interface prefix
|
||||
const_ERROR_PREFIX = const_INT_PREFIX + ".error"
|
||||
const_OBJ_PATH = '/org/goffi/SAT/bridge'
|
||||
|
|
@ -42,7 +44,15 @@ def dbus_to_bridge_exception(dbus_e):
|
|||
@return: BridgeException
|
||||
"""
|
||||
name = dbus_e.get_dbus_name()[len(const_ERROR_PREFIX) + 1:]
|
||||
return BridgeException(name, dbus_e.get_dbus_message())
|
||||
# XXX: dbus_e.args doesn't contain the original DBusException args, but we
|
||||
# receive its serialized form in dbus_e.args[0]. From that we can rebuild
|
||||
# the original arguments list thanks to ast.literal_eval (secure eval).
|
||||
message = dbus_e.get_dbus_message() # similar to dbus_e.args[0]
|
||||
try:
|
||||
message, condition = ast.literal_eval(message)
|
||||
except (SyntaxError, ValueError, TypeError):
|
||||
condition = ''
|
||||
return BridgeException(name, message, condition)
|
||||
|
||||
|
||||
class DBusBridgeFrontend(BridgeFrontend):
|
||||
|
|
|
|||
Loading…
Reference in a new issue