dbus/python/examples example-client.py, 1.4, 1.5 example-service.py,
1.7, 1.8 example-signal-recipient.py, 1.1, 1.2
John Palmieri
johnp at freedesktop.org
Fri Feb 11 11:51:20 PST 2005
Update of /cvs/dbus/dbus/python/examples
In directory gabe:/tmp/cvs-serv23789/python/examples
Modified Files:
example-client.py example-service.py
example-signal-recipient.py
Log Message:
* python/dbus.py (class Sender): added to support dbus signals better
(Bus::add_signal_receiver): added expand_args parameter which defaults
to True. When expand args is True the signal handler will pass the
message arguments as parameters to the signal handler. If False
revert to previous behavior where the signal handler must get the
argument list from the message. This is to help port applications
like HAL that have a tendancy to send variable length argument lists.
self._match_rule_to_receivers is now a dict of dicts.
(Bus::remove_signal_receiver): pop handler off the dict intead of
removing it from a list
(Bus::_signal_func): change signal handlers so that interface,
signal_name, service, path and message are packed into a Sender
object and that is passed to the handler. If expand_args is True
extract the args list from the message and append it to the parameter
list
* python/dbus_bindings.pyx.in (class Signature): added to support
signiature types
(MessageIter::__init__): changed iteration limit to match D-BUS
(MessageIter::get*): added INT16, UINT16, SIGNATURE, DICT_ENTRY,
STRUCT and VARIENT type support
(MessageIter::python_value_to_dbus_sig): made recursive to support
recursive types
(MessageIter::append*): added Signature, dict, tuple
support
* python/examples/example-client.py: added examples of getting tuples
and dicts
* python/examples/example-service.py: added examples of sending tuples
and dicts
* python/examples/example-signal-recipient.py: Fixed to handle new
signal callback format
Index: example-client.py
===================================================================
RCS file: /cvs/dbus/dbus/python/examples/example-client.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- example-client.py 30 May 2004 06:26:24 -0000 1.4
+++ example-client.py 11 Feb 2005 19:51:18 -0000 1.5
@@ -9,4 +9,13 @@
hello_reply_list = remote_object.HelloWorld("Hello from example-client.py!")
+hello_reply_tuple = remote_object.GetTuple()
+
+hello_reply_dict = remote_object.GetDict()
+
print (hello_reply_list)
+
+print str(hello_reply_tuple)
+
+print str(hello_reply_dict)
+
Index: example-service.py
===================================================================
RCS file: /cvs/dbus/dbus/python/examples/example-service.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- example-service.py 28 Jan 2005 19:09:55 -0000 1.7
+++ example-service.py 11 Feb 2005 19:51:18 -0000 1.8
@@ -5,12 +5,19 @@
class SomeObject(dbus.Object):
def __init__(self, service):
- dbus.Object.__init__(self, "/SomeObject", service, [self.HelloWorld])
+ export = [self.HelloWorld, self.GetTuple, self.GetDict]
+ dbus.Object.__init__(self, "/SomeObject", service, export)
def HelloWorld(self, message, hello_message):
print (str(hello_message))
return ["Hello", " from example-service.py"]
+ def GetTuple(self, message):
+ return ("Hello Tuple", " from example-service.py")
+
+ def GetDict(self, message):
+ return {"first": "Hello Dict", "second": " from example-service.py"}
+
session_bus = dbus.SessionBus()
service = dbus.Service("org.designfu.SampleService", bus=session_bus)
object = SomeObject(service)
Index: example-signal-recipient.py
===================================================================
RCS file: /cvs/dbus/dbus/python/examples/example-signal-recipient.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- example-signal-recipient.py 11 Jul 2004 03:02:14 -0000 1.1
+++ example-signal-recipient.py 11 Feb 2005 19:51:18 -0000 1.2
@@ -5,9 +5,9 @@
service = bus.get_service("org.designfu.TestService")
object = service.get_object("/org/designfu/TestService/object", "org.designfu.TestService")
-def hello_signal_handler(interface, signal_name, service, path, message):
+def hello_signal_handler(sender):
print ("Received signal '%s.%s' from object '%s%s'"
- % (interface, signal_name, service, path))
+ % (sender.interface, sender.signal_name, sender.service, sender.path))
object.connect_to_signal("hello", hello_signal_handler)
More information about the dbus-commit
mailing list