patch to expose dbus_bus_get_unix_user in python bindings

Rob Taylor robtaylor at fastmail.fm
Mon Dec 13 03:58:47 PST 2004


This patch consists of the addition of a get_unix_user method to the Bus 
class, and a fix for extract.py so it copes with 'unsigned long' return 
types in function definitions.

Thanks

Rob Taylor


-------------- next part --------------
Index: python/dbus.py
===================================================================
RCS file: /cvs/dbus/dbus/python/dbus.py,v
retrieving revision 1.12
diff -u -r1.12 dbus.py
--- python/dbus.py	28 Jul 2004 18:14:55 -0000	1.12
+++ python/dbus.py	13 Dec 2004 11:38:35 -0000
@@ -99,6 +99,10 @@
     def get_connection(self):
         """Get the dbus_bindings.Connection object associated with this Bus"""
         return self._connection
+    
+    def get_unix_user(self, service_name):
+        """Get the unix user for the given service_name on this Bus"""
+        return dbus_bindings.bus_get_unix_user(self._connection, service_name)
 
     def _get_match_rule(self, signal_name, interface, service, path):
         match_rule = "type='signal'"
Index: python/dbus_bindings.pyx.in
===================================================================
RCS file: /cvs/dbus/dbus/python/dbus_bindings.pyx.in,v
retrieving revision 1.15
diff -u -r1.15 dbus_bindings.pyx.in
--- python/dbus_bindings.pyx.in	16 Sep 2004 19:56:26 -0000	1.15
+++ python/dbus_bindings.pyx.in	13 Dec 2004 11:38:35 -0000
@@ -1132,6 +1132,19 @@
     conn = connection._get_conn()
     return dbus_bus_get_base_service(conn)
 
+def bus_get_unix_user(Connection connection, service_name):
+    cdef DBusError error
+    dbus_error_init(&error)
+    cdef int retval
+    cdef DBusConnection *conn
+
+    conn = connection._get_conn()
+    retval = dbus_bus_get_unix_user(conn, service_name, &error)
+
+    if dbus_error_is_set(&error):
+        raise DBusException, error.message
+    return retval
+    
 def bus_register(Connection connection):
     cdef DBusError error
     dbus_error_init(&error)
Index: python/extract.py
===================================================================
RCS file: /cvs/dbus/dbus/python/extract.py,v
retrieving revision 1.2
diff -u -r1.2 extract.py
--- python/extract.py	30 Sep 2003 02:40:49 -0000	1.2
+++ python/extract.py	13 Dec 2004 11:38:35 -0000
@@ -108,7 +108,7 @@
     return typedefs
 
 proto_pat = re.compile(r"""
-(?P<ret>(-|\w|\&|\*)+\s*)      # return type
+(?P<ret>(-|\w|\&|\*|\s)+\s*)      # return type
 \s+                            # skip whitespace
 (?P<func>\w+)\s*[(]  # match the function name until the opening (
 (?P<args>.*?)[)]               # group the function arguments
@@ -123,7 +123,6 @@
     for p in buf:
         if len(p) == 0:
             continue
-        
         m = proto_pat.match(p)
         if m == None:
             continue


More information about the dbus mailing list