dbus/python dbus_bindings.pyx, 1.16, 1.17 exceptions.py, 1.3,
1.4 service.py, 1.19, 1.20
Robert McQueen
robot101 at freedesktop.org
Tue Nov 15 09:19:21 PST 2005
Update of /cvs/dbus/dbus/python
In directory gabe:/tmp/cvs-serv7289/python
Modified Files:
dbus_bindings.pyx exceptions.py service.py
Log Message:
2005-11-15 Robert McQueen <robot101 at debian.org>
* bus/driver.c, bus/services.c, bus/services.h: Add a ReleaseName
method to org.freedesktop.DBus to release a bus name or give up
waiting in the queue for it.
* dbus/dbus-bus.c, dbus/dbus-bus.h, dbus/dbus-shared.h: Add a
dbus_bus_release_name method to send the ReleaseName method calls.
Add constants for the return values to dbus/dbus-shared.h.
* doc/dbus-specification.xml: Document the new ReleaseName method
in the specification.
* python/dbus_bindings.pyx: Add a low-level python binding for the
release name method.
* python/exceptions.py, python/service.py: Make freeing BusName
objects release the name. Add a NameExistsException, and fix a
bug with creating UnknownMethodException.
* test/python/test-client.py: Add tests for freeing BusName
objects causing names to be released.
Index: dbus_bindings.pyx
===================================================================
RCS file: /cvs/dbus/dbus/python/dbus_bindings.pyx,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- dbus_bindings.pyx 7 Nov 2005 12:14:53 -0000 1.16
+++ dbus_bindings.pyx 15 Nov 2005 17:19:19 -0000 1.17
@@ -1710,10 +1710,10 @@
return retval
-#These are defines, not enums so they aren't auto generated
-DBUS_START_REPLY_SUCCESS = 0
-DBUS_START_REPLY_ALREADY_RUNNING = 1
-
+# these are defines, not enums, so they aren't auto generated
+DBUS_START_REPLY_SUCCESS = 0
+DBUS_START_REPLY_ALREADY_RUNNING = 1
+
def bus_start_service_by_name(Connection connection, service_name, flags=0):
cdef DBusError error
dbus_error_init(&error)
@@ -1771,9 +1771,30 @@
errormsg = error.message
dbus_error_free(&error)
raise DBusException, errormsg
-
+
return retval
-
+
+RELEASE_NAME_REPLY_RELEASED = 1
+RELEASE_NAME_REPLY_NON_EXISTENT = 2
+RELEASE_NAME_REPLY_NOT_OWNER = 3
+
+def bus_release_name(Connection connection, service_name):
+ cdef DBusError error
+ dbus_error_init(&error)
+ cdef int retval
+ cdef DBusConnection *conn
+
+ conn = connection._get_conn()
+ retval = dbus_bus_release_name(conn,
+ service_name,
+ &error)
+ if dbus_error_is_set(&error):
+ errormsg = error.message
+ dbus_error_free(&error)
+ raise DBusException, errormsg
+
+ return retval
+
def bus_name_has_owner(Connection connection, service_name):
cdef DBusError error
dbus_error_init(&error)
Index: exceptions.py
===================================================================
RCS file: /cvs/dbus/dbus/python/exceptions.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- exceptions.py 5 Oct 2005 20:43:46 -0000 1.3
+++ exceptions.py 15 Nov 2005 17:19:19 -0000 1.4
@@ -17,9 +17,13 @@
class IntrospectionParserException(DBusException):
def __init__(self, msg=''):
- DBusException.__init__(self, "Error parsing introspect data: %s"%msg)
+ DBusException.__init__(self, "Error parsing introspect data: %s"%msg)
class UnknownMethodException(DBusException):
- def __init__(self, msg=''):
- DBusException.__init__("Unknown method: %s"%msg)
+ def __init__(self, method):
+ DBusException.__init__(self, "Unknown method: %s"%method)
+
+class NameExistsException(DBusException):
+ def __init__(self, name):
+ DBusException.__init__(self, "Bus name already exists: %s"%name)
Index: service.py
===================================================================
RCS file: /cvs/dbus/dbus/python/service.py,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- service.py 14 Nov 2005 20:59:32 -0000 1.19
+++ service.py 15 Nov 2005 17:19:19 -0000 1.20
@@ -1,9 +1,9 @@
-
-import dbus_bindings
+import dbus_bindings
import _dbus
import operator
import traceback
+from exceptions import NameExistsException
from exceptions import UnknownMethodException
from decorators import method
from decorators import signal
@@ -31,13 +31,13 @@
# because you can't put flags in, but... who knows?
pass
elif retval == dbus_bindings.REQUEST_NAME_REPLY_EXISTS:
- raise dbus_bindings.DBusException('requested name %s already exists' % name)
+ raise NameExistsException(name)
elif retval == dbus_bindings.REQUEST_NAME_REPLY_ALREADY_OWNER:
# if this is a shared bus which is being used by someone
# else in this process, this can happen legitimately
pass
else:
- raise dbus_bindings.DBusException('requesting name %s returned unexpected value %s' % (name, retval))
+ raise RuntimeError('requesting bus name %s returned unexpected value %s' % (name, retval))
# and create the object
bus_name = object.__new__(cls)
@@ -57,8 +57,7 @@
# we can delete the low-level name here because these objects
# are guaranteed to exist only once for each bus name
def __del__(self):
- # FIXME: we don't have this function yet :)
- #dbus_bindings.bus_release_name(self._bus.get_connection(), self._named_service)
+ dbus_bindings.bus_release_name(self._bus.get_connection(), self._name)
pass
def get_bus(self):
More information about the dbus-commit
mailing list