dbus/python _dbus.py, 1.12, 1.13 dbus_bindings.pyx, 1.10, 1.11 proxies.py, 1.9, 1.10

John Palmieri johnp at freedesktop.org
Mon Oct 17 21:38:07 PDT 2005


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

Modified Files:
	_dbus.py dbus_bindings.pyx proxies.py 
Log Message:
* glib/dbus-gvalue-utils.c (hash_free_from_gtype): handle gdouble
and G_TYPE_VALUE_ARRAY (DBUS_TYPE_STRUCT)
(gvalue_from_hash_value, hash_value_from_gvalue): handle gdouble

* glib/dbus-gvalue.c (dbus_gvalue_to_signature): add missing
DBUS_STRUCT_BEGIN_CHAR and DBUS_STRUCT_END_CHAR charaters
when constructing struct signatures

* python/_dbus.py (Bus): handle private connections using the
private keyword in the constructor. defaults to private=False
(Bus::close): new method to close a connection to the bus

* python/dbus_bindings.pyx (Connection::close): renamed method
was previously called disconnect
(bus_get): now supports getting a private connection

* python/proxies.py (ProxyMethod::__call__): check if ignore_reply
keyword is set to True.  if it is, execute the method without waiting
for a reply
(ProxyObject::_introspect_execute_queue): new method for executing
all the pending methods that were waiting for the introspect to
finish.  this is called when introspect either succeeds or fails
(ProxyObject::_introspect_error_handler): call queued methods



Index: _dbus.py
===================================================================
RCS file: /cvs/dbus/dbus/python/_dbus.py,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- _dbus.py	24 Aug 2005 19:58:32 -0000	1.12
+++ _dbus.py	18 Oct 2005 04:38:04 -0000	1.13
@@ -67,8 +67,8 @@
     START_REPLY_SUCCESS = dbus_bindings.DBUS_START_REPLY_SUCCESS
     START_REPLY_ALREADY_RUNNING = dbus_bindings.DBUS_START_REPLY_ALREADY_RUNNING 
 
-    def __init__(self, bus_type=TYPE_SESSION, use_default_mainloop=True):
-        self._connection = dbus_bindings.bus_get(bus_type)
+    def __init__(self, bus_type=TYPE_SESSION, use_default_mainloop=True, private=False):
+        self._connection = dbus_bindings.bus_get(bus_type, private)
 
         self._connection.add_filter(self._signal_func)
         self._match_rule_tree = SignalMatchTree()
@@ -78,25 +78,28 @@
             if func != None:
                 func(self)
 
+    def close(self):
+        self._connection.close()
+
     def get_connection(self):
         return self._connection
 
-    def get_session():
+    def get_session(private=False):
         """Static method that returns the session bus"""
-        return SessionBus()
+        return SessionBus(private)
 
     get_session = staticmethod(get_session)
 
-    def get_system():
+    def get_system(private=False):
         """Static method that returns the system bus"""
-        return SystemBus()
+        return SystemBus(private)
 
     get_system = staticmethod(get_system)
 
 
-    def get_starter():
+    def get_starter(private=False):
         """Static method that returns the starter bus"""
-        return StarterBus()
+        return StarterBus(private)
 
     get_starter = staticmethod(get_starter)
 
@@ -196,21 +199,21 @@
 class SystemBus(Bus):
     """The system-wide message bus
     """
-    def __init__(self):
-        Bus.__init__(self, Bus.TYPE_SYSTEM)
+    def __init__(self, use_default_mainloop=True, private=False):
+        Bus.__init__(self, Bus.TYPE_SYSTEM, use_default_mainloop, private)
 
 class SessionBus(Bus):
     """The session (current login) message bus
     """
-    def __init__(self):
-        Bus.__init__(self, Bus.TYPE_SESSION)
+    def __init__(self, use_default_mainloop=True, private=False):
+        Bus.__init__(self, Bus.TYPE_SESSION, use_default_mainloop, private)
 
 class StarterBus(Bus):
     """The bus that activated this process (if
     this process was launched by DBus activation)
     """
-    def __init__(self):
-        Bus.__init__(self, Bus.TYPE_STARTER)
+    def __init__(self, use_default_mainloop=True, private=False):
+        Bus.__init__(self, Bus.TYPE_STARTER, use_default_mainloop, private)
 
 class Interface:
     """An inteface into a remote object

Index: dbus_bindings.pyx
===================================================================
RCS file: /cvs/dbus/dbus/python/dbus_bindings.pyx,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- dbus_bindings.pyx	14 Oct 2005 21:44:00 -0000	1.10
+++ dbus_bindings.pyx	18 Oct 2005 04:38:04 -0000	1.11
@@ -278,8 +278,8 @@
     def get_unique_name(self):
         return bus_get_unique_name(self)
 
-    def disconnect(self):
-        dbus_connection_disconnect(self.conn)
+    def close(self):
+        dbus_connection_close(self.conn)
 
     def get_is_connected(self):
         return dbus_connection_get_is_connected(self.conn)
@@ -1638,14 +1638,18 @@
 BUS_SYSTEM = DBUS_BUS_SYSTEM
 BUS_STARTER = DBUS_BUS_STARTER
 
-def bus_get (bus_type):
+def bus_get (bus_type, private=False):
     cdef DBusError error
     cdef Connection conn
-    dbus_error_init(&error)
     cdef DBusConnection *connection
 
-    connection = dbus_bus_get(bus_type,
-                              &error)
+    dbus_error_init(&error)
+    if private:
+        connection = dbus_bus_get_private(bus_type,
+                                          &error)
+    else:
+        connection = dbus_bus_get(bus_type,
+                                  &error)
 
     if dbus_error_is_set(&error):
         errormsg = error.message

Index: proxies.py
===================================================================
RCS file: /cvs/dbus/dbus/python/proxies.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- proxies.py	5 Oct 2005 20:43:46 -0000	1.9
+++ proxies.py	18 Oct 2005 04:38:04 -0000	1.10
@@ -46,6 +46,10 @@
         if keywords.has_key('error_handler'):
             error_handler = keywords['error_handler']            
 
+        ignore_reply = False
+        if keywords.has_key('ignore_reply'):
+            ignore_reply = keywords['ignore_reply']
+
         if not(reply_handler and error_handler):
             if reply_handler:
                 raise MissingErrorHandlerException()
@@ -65,8 +69,11 @@
                 iter.append_strict(arg, sig)
             else:
                 iter.append(arg)
-
-        if reply_handler:
+       
+        if ignore_reply:
+            result = self._connection.send(message)
+            args_tuple = (result,)
+        elif reply_handler:
             result = self._connection.send_with_reply_handlers(message, timeout, reply_handler, error_handler)
             args_tuple = result
         else:
@@ -94,8 +101,6 @@
     INTROSPECT_STATE_INTROSPECT_IN_PROGRESS = 1
     INTROSPECT_STATE_INTROSPECT_DONE = 2
 
-    #TODO: default introspect to False right now because it is not done yet
-    #      make sure to default to True later
     def __init__(self, bus, named_service, object_path, introspect=True):
         self._bus           = bus
         self._named_service = named_service
@@ -132,20 +137,8 @@
                                                                      self._introspect_reply_handler, 
                                                                      self._introspect_error_handler)
         return result   
-
     
-    
-
-    def _introspect_reply_handler(self, data):
-        try:
-            self._introspect_method_map = introspect_parser.process_introspection_data(data)
-        except IntrospectionParserException, e:
-            self._introspect_error_handler(e)
-            return
-        
-        self._introspect_state = self.INTROSPECT_STATE_INTROSPECT_DONE
-
-        #TODO: we should actually call these even if introspection fails
+    def _introspect_execute_queue(self): 
         for call in self._pending_introspect_queue:
             (member, iface, args, keywords) = call
 
@@ -162,14 +155,27 @@
             
             call_object = self.ProxyMethodClass(self._bus.get_connection(),
                                                 self._named_service,
-                                                self._object_path, iface, member,
+                                                self._object_path, 
+                                                iface, 
+                                                member,
                                                 introspect_sig)
                                                                        
             call_object(args, keywords)
 
+    def _introspect_reply_handler(self, data):
+        try:
+            self._introspect_method_map = introspect_parser.process_introspection_data(data)
+        except IntrospectionParserException, e:
+            self._introspect_error_handler(e)
+            return
+        
+        self._introspect_state = self.INTROSPECT_STATE_INTROSPECT_DONE
+        #self._introspect_execute_queue()
+
     def _introspect_error_handler(self, error):
         self._introspect_state = self.INTROSPECT_STATE_DONT_INTROSPECT
-        sys.stderr.write(str(error))
+        self._introspect_execute_queue()
+        sys.stderr.write("Introspect error: " + str(error) + "\n")
 
     def __getattr__(self, member, **keywords):
         if member == '__call__':



More information about the dbus-commit mailing list