* python/Makefile.am: changed to use pyexecdir for the binding
authorJohn (J5) Palmieri <johnp@redhat.com>
Thu, 5 May 2005 18:01:45 +0000 (18:01 +0000)
committerJohn (J5) Palmieri <johnp@redhat.com>
Thu, 5 May 2005 18:01:45 +0000 (18:01 +0000)
  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)

ChangeLog
python/Makefile.am
python/_dbus.py
python/exceptions.py
python/proxies.py

index e903e1b..608275c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2005-05-04  John (J5) Palmieir  <johnp@redhat.com>
+
+       * 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  <ross@burtonini.com>
 
        * glib/dbus-gobject.c (dbus_g_connection_register_g_object):
index f7a5631..1cd40ee 100644 (file)
@@ -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
index 9dc3bd0..d9c8123 100644 (file)
@@ -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 '<Interface %r implementing %r at %x>'%(
+        self._obj, self._dbus_interface, id(self))
+    __str__ = __repr__
index 66b8c56..b9df815 100644 (file)
@@ -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)
 
index 0e00d64..d8804c0 100644 (file)
@@ -32,6 +32,11 @@ class ProxyObject:
                                 self._named_service,
                                 self._object_path, iface, member)
 
+    def __repr__(self):
+        return '<ProxyObject wrapping %s %s %s at %x>'%( 
+            self._bus, self._named_service, self._object_path , id(self))
+    __str__ = __repr__
+
 
 class ProxyMethod:
     """A proxy Method.