From: John (J5) Palmieri Date: Thu, 5 May 2005 18:01:45 +0000 (+0000) Subject: * python/Makefile.am: changed to use pyexecdir for the binding X-Git-Tag: dbus-0.34.0~30 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=425257ddf930105bea6d648a19e184c74da4177b;p=thirdparty%2Fdbus.git * python/Makefile.am: changed to use pyexecdir for the binding shared libraries (Bug#2494) * python/exceptions.py: bring exceptions over from the bindings so they can be used in applications (Bug#2036) Make all exceptions derive from DBusException * python/_dbus.py, python/proxies.py: implement __repr__ in a couple of classes so that print obj doesn't throw an exception (Bug #1685) --- diff --git a/ChangeLog b/ChangeLog index e903e1bc3..608275c99 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2005-05-04 John (J5) Palmieir + + * python/Makefile.am: changed to use pyexecdir for the binding + shared libraries (Bug#2494) + + * python/exceptions.py: bring exceptions over from the bindings + so they can be used in applications (Bug#2036) + Make all exceptions derive from DBusException + + * python/_dbus.py, python/proxies.py: implement __repr__ in a couple + of classes so that print obj doesn't throw an exception (Bug #1685) + 2005-05-03 Ross Burton * glib/dbus-gobject.c (dbus_g_connection_register_g_object): diff --git a/python/Makefile.am b/python/Makefile.am index f7a563184..1cd40ee30 100644 --- a/python/Makefile.am +++ b/python/Makefile.am @@ -5,7 +5,7 @@ INCLUDES=-I$(top_builddir) -I$(top_builddir)/dbus $(DBUS_CLIENT_CFLAGS) $(DBUS_G dbusdir = $(pythondir)/dbus dbus_PYTHON = __init__.py _dbus.py decorators.py exceptions.py services.py proxies.py _util.py types.py -dbusbindingsdir = $(pythondir)/dbus +dbusbindingsdir = $(pyexecdir)/dbus dbusbindings_LTLIBRARIES = dbus_bindings.la dbus_bindings_la_LDFLAGS = -module -avoid-version -fPIC -export-symbols-regex initdbus_bindings diff --git a/python/_dbus.py b/python/_dbus.py index 9dc3bd0a9..d9c81235a 100644 --- a/python/_dbus.py +++ b/python/_dbus.py @@ -187,7 +187,6 @@ class StarterBus(Bus): def __init__(self): Bus.__init__(self, Bus.TYPE_STARTER) - class Interface: """An inteface into a remote object @@ -216,4 +215,8 @@ class Interface: return object.__call__ else: return self._obj.__getattr__(member, dbus_interface=_dbus_interface) - + + def __repr__(self): + return ''%( + self._obj, self._dbus_interface, id(self)) + __str__ = __repr__ diff --git a/python/exceptions.py b/python/exceptions.py index 66b8c5669..b9df8150a 100644 --- a/python/exceptions.py +++ b/python/exceptions.py @@ -1,32 +1,21 @@ -class MissingErrorHandlerException(Exception): - def __init__(self): - Exception.__init__(self) - - - def __str__(self): - return "error_handler not defined: if you define a reply_handler you must also define an error_handler" +import dbus_bindings +DBusException = dbus_bindings.DBusException +ConnectionError = dbus_bindings.ConnectionError -class MissingReplyHandlerException(Exception): +class MissingErrorHandlerException(DBusException): def __init__(self): - Exception.__init__(self) + DBusException.__init__(self, "error_handler not defined: if you define a reply_handler you must also define an error_handler") - def __str__(self): - return "reply_handler not defined: if you define an error_handler you must also define a reply_handler" +class MissingReplyHandlerException(DBusException): + def __init__(self): + DBusException.__init__(self, "reply_handler not defined: if you define an error_handler you must also define a reply_handler") -class ValidationException(Exception): +class ValidationException(DBusException): def __init__(self, msg=''): - self.msg = msg - Exception.__init__(self) - - def __str__(self): - return "Error validating string: %s" % self.msg + DBusException.__init__(self, "Error validating string: %s"%msg) -class UnknownMethodException(Exception): +class UnknownMethodException(DBusException): def __init__(self, msg=''): - self.msg = msg - Exception.__init__(self) - - def __str__(self): - return "Unknown method: %s" % self.msg + DBusException.__init__("Unknown method: %s"%msg) diff --git a/python/proxies.py b/python/proxies.py index 0e00d64a5..d8804c027 100644 --- a/python/proxies.py +++ b/python/proxies.py @@ -32,6 +32,11 @@ class ProxyObject: self._named_service, self._object_path, iface, member) + def __repr__(self): + return ''%( + self._bus, self._named_service, self._object_path , id(self)) + __str__ = __repr__ + class ProxyMethod: """A proxy Method.