dbus/python Makefile.am, 1.10, 1.11 _dbus.py, 1.1, 1.2 exceptions.py, 1.1, 1.2 proxies.py, 1.1, 1.2

John Palmieri johnp at freedesktop.org
Thu May 5 11:01:47 PDT 2005


Update of /cvs/dbus/dbus/python
In directory gabe:/tmp/cvs-serv22918/python

Modified Files:
	Makefile.am _dbus.py exceptions.py proxies.py 
Log Message:
* 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)


Index: Makefile.am
===================================================================
RCS file: /cvs/dbus/dbus/python/Makefile.am,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- Makefile.am	1 May 2005 19:34:58 -0000	1.10
+++ Makefile.am	5 May 2005 18:01:45 -0000	1.11
@@ -5,7 +5,7 @@
 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: _dbus.py
===================================================================
RCS file: /cvs/dbus/dbus/python/_dbus.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- _dbus.py	1 May 2005 19:34:58 -0000	1.1
+++ _dbus.py	5 May 2005 18:01:45 -0000	1.2
@@ -187,7 +187,6 @@
     def __init__(self):
         Bus.__init__(self, Bus.TYPE_STARTER)
 
-
 class Interface:
     """An inteface into a remote object
 
@@ -216,4 +215,8 @@
             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: exceptions.py
===================================================================
RCS file: /cvs/dbus/dbus/python/exceptions.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- exceptions.py	1 May 2005 19:34:58 -0000	1.1
+++ exceptions.py	5 May 2005 18:01:45 -0000	1.2
@@ -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: proxies.py
===================================================================
RCS file: /cvs/dbus/dbus/python/proxies.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- proxies.py	1 May 2005 19:34:58 -0000	1.1
+++ proxies.py	5 May 2005 18:01:45 -0000	1.2
@@ -32,6 +32,11 @@
                                 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.



More information about the dbus-commit mailing list