summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert McQueen <robot101@debian.org>2005-10-29 22:04:01 +0000
committerRobert McQueen <robot101@debian.org>2005-10-29 22:04:01 +0000
commit6fbd1c7ff5b1023f543a304db4f76fc6eeb4dbd5 (patch)
tree0ca5b3936376fe84c9df1153019f28408254310d
parent20bcbaf21f4e94c48d6348a4ba8013d20f9e4d36 (diff)
2005-10-29 Robert McQueen <robot101@debian.org>
* python/dbus_bindings.pyx: Tweak 'raise AssertionError' to assert(). Add checking for the end of struct character when marshalling a struct in MessageIter.append_strict. * python/examples/example-service.py, python/examples/gconf-proxy-service.py, python/examples/gconf-proxy-service2.py: Update to use gobject mainloop directly rather than appearing to depend on gtk. * python/test/test-client.py, python/test/test-server.py: Remove obsolete and broken test scripts for old bindings. We have up to date and working tests in test/python/.
-rw-r--r--ChangeLog15
-rw-r--r--python/dbus_bindings.pyx10
-rw-r--r--python/examples/example-service.py6
-rw-r--r--python/examples/gconf-proxy-service.py5
-rw-r--r--python/examples/gconf-proxy-service2.py5
-rw-r--r--python/tests/test-client.py100
-rw-r--r--python/tests/test-server.py17
7 files changed, 30 insertions, 128 deletions
diff --git a/ChangeLog b/ChangeLog
index 128a78e2..d03d051f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,20 @@
2005-10-29 Robert McQueen <robot101@debian.org>
+ * python/dbus_bindings.pyx: Tweak 'raise AssertionError' to assert().
+ Add checking for the end of struct character when marshalling a
+ struct in MessageIter.append_strict.
+
+ * python/examples/example-service.py,
+ python/examples/gconf-proxy-service.py,
+ python/examples/gconf-proxy-service2.py: Update to use gobject
+ mainloop directly rather than appearing to depend on gtk.
+
+ * python/test/test-client.py, python/test/test-server.py: Remove
+ obsolete and broken test scripts for old bindings. We have up to date
+ and working tests in test/python/.
+
+2005-10-29 Robert McQueen <robot101@debian.org>
+
* python/decorators.py: Add optional arguments to the method and
signal decorators to allow you to specify the signature of arguments
and return values. Preserve the doc strings of signal functions in the
diff --git a/python/dbus_bindings.pyx b/python/dbus_bindings.pyx
index fe6e7777..c693a3d0 100644
--- a/python/dbus_bindings.pyx
+++ b/python/dbus_bindings.pyx
@@ -457,13 +457,12 @@ cdef class Connection:
dbus_error_free (&error)
raise DBusException, errormsg
- if retval == NULL:
- raise AssertionError
-
+ assert(retval != NULL)
+
m = EmptyMessage()
m._set_msg(retval)
- return m
+ return m
def set_watch_functions(self, add_function, remove_function, data):
pass
@@ -1048,6 +1047,9 @@ cdef class MessageIter:
elif sig_type == TYPE_OBJECT_PATH:
retval = self.append_object_path(value)
elif sig_type == STRUCT_BEGIN:
+ if ord(sig[-1]) != STRUCT_END:
+ raise TypeError, "Invalid struct entry in append_strict. No termination in signature %s." % (sig)
+
tmp_sig = sig[1:-1]
retval = self.append_struct(value, signature = tmp_sig)
elif sig_type == TYPE_VARIANT:
diff --git a/python/examples/example-service.py b/python/examples/example-service.py
index ce871a1f..cb25d203 100644
--- a/python/examples/example-service.py
+++ b/python/examples/example-service.py
@@ -3,8 +3,7 @@
import dbus
import dbus.service
import dbus.glib
-import pygtk
-import gtk
+import gobject
class SomeObject(dbus.service.Object):
def __init__(self, bus_name, object_path="/SomeObject"):
@@ -27,4 +26,5 @@ session_bus = dbus.SessionBus()
name = dbus.service.BusName("org.designfu.SampleService", bus=session_bus)
object = SomeObject(name)
-gtk.main()
+mainloop = gobject.MainLoop()
+mainloop.run()
diff --git a/python/examples/gconf-proxy-service.py b/python/examples/gconf-proxy-service.py
index b9bdef14..a899cf21 100644
--- a/python/examples/gconf-proxy-service.py
+++ b/python/examples/gconf-proxy-service.py
@@ -2,7 +2,7 @@
#FIXME: Doesn't work with the new bindings
import dbus
-import gtk
+import gobject
import gconf
class GConfService(dbus.Service):
@@ -39,4 +39,5 @@ gconf_service = GConfService()
print ("GConf Proxy service started.")
print ("Run 'gconf-proxy-client.py' to fetch a GConf key through the proxy...")
-gtk.main()
+mainloop = gobject.MainLoop()
+mainloop.run()
diff --git a/python/examples/gconf-proxy-service2.py b/python/examples/gconf-proxy-service2.py
index ba8d249b..5731ab28 100644
--- a/python/examples/gconf-proxy-service2.py
+++ b/python/examples/gconf-proxy-service2.py
@@ -2,7 +2,7 @@
#FIXME: doesn't work with the new bindings
import dbus
-import gtk
+import gobject
import gconf
class GConfService(dbus.Service):
@@ -35,4 +35,5 @@ gconf_service = GConfService()
print ("GConf Proxy service started.")
print ("Run 'gconf-proxy-client.py' to fetch a GConf key through the proxy...")
-gtk.main()
+mainloop = gobject.MainLoop()
+mainloop.run()
diff --git a/python/tests/test-client.py b/python/tests/test-client.py
deleted file mode 100644
index 5dc6e20c..00000000
--- a/python/tests/test-client.py
+++ /dev/null
@@ -1,100 +0,0 @@
-import dbus
-
-def ensure_same(expected, received):
- if type(received) != type(expected):
- raise Exception ("Sending %s, expected echo of type %s, but got %s" % (expected, type(expected), type(received)))
-
- if received.__class__ != expected.__class__:
- raise Exception ("Sending %s, expected echo to be of class %s, but got %s" % (expected, expected.__class__, received.__class__))
-
- if received != expected:
- raise Exception("Sending %s, expected echo to be the same, but was %s" % (expected, received))
-
-def TestEcho(value):
- global remote_object
- echoed = remote_object.Echo(value)
- ensure_same(value, echoed)
-
-def TestEchoList(sent_list):
- assert(type(sent_list) == list)
-
- global remote_object
-
- reply_list = remote_object.Echo(sent_list)
-
- if type(reply_list) != list:
- raise Exception ("Sending list %s, expected echo to be a list, but it was %s" % (sent_list, type(reply_list)))
-
- if len(reply_list) != len(sent_list):
- raise Exception ("Sending list %s, expected echo of length %d, but length was %d" % (len(sent_list), len(reply_list)))
-
- for i in range(len(sent_list)):
- ensure_same(sent_list[i], reply_list[i])
-
-def TestEchoDict(sent_dict):
- assert(type(sent_dict) == dict)
-
- global remote_object
-
- reply_dict = remote_object.Echo(sent_dict)
-
-
- assert(type(reply_dict) == dict)
-
- assert(len(reply_dict) == len(sent_dict))
-
- for key in sent_dict.keys():
- ensure_same(reply_dict[key], sent_dict[key])
-
-session_bus = dbus.SessionBus()
-
-remote_service = session_bus.get_service("org.designfu.Test")
-remote_object = remote_service.get_object("/TestObject", "org.designfu.Test")
-
-TestEcho(chr(120))
-TestEcho(10)
-TestEcho(39.5)
-TestEcho("HelloWorld")
-TestEcho(dbus.ObjectPath("/test/path"))
-TestEcho(dbus.ByteArray("blahblahblah"))
-
-string_list = []
-for i in range(200):
- string_list.append("List item " + str(i))
-TestEchoList(string_list)
-
-int_list = range(200)
-TestEchoList(int_list)
-
-path_list = []
-for i in range(200):
- path_list.append(dbus.ObjectPath("/some/object/path" + str(i)))
-TestEchoList(path_list)
-
-double_list = []
-for i in range(200):
- double_list.append(float(i) / 1000)
-TestEchoList(double_list)
-
-#FIXME: this currently fails!
-#empty_list = []
-#TestEchoList(empty_list)
-
-string_to_int_dict = {}
-for i in range(200):
- string_to_int_dict["key" + str(i)] = i
-TestEchoDict(string_to_int_dict)
-
-string_to_double_dict = {}
-for i in range(200):
- string_to_double_dict["key" + str(i)] = float(i) / 1000
-TestEchoDict(string_to_double_dict)
-
-string_to_string_dict = {}
-for i in range(200):
- string_to_string_dict["key" + str(i)] = "value" + str(i)
-TestEchoDict(string_to_string_dict)
-
-#FIXME: this currently crashes dbus in c code
-#empty_dict = {}
-#TestEchoDict(empty_dict)
diff --git a/python/tests/test-server.py b/python/tests/test-server.py
deleted file mode 100644
index 235da701..00000000
--- a/python/tests/test-server.py
+++ /dev/null
@@ -1,17 +0,0 @@
-import dbus
-import gtk
-
-class TestObject(dbus.Object):
- def __init__(self, service):
- method_list = [ self.Echo ]
- dbus.Object.__init__(self, "/TestObject", service, method_list)
-
- def Echo(self, variable):
- return variable
-
-session_bus = dbus.SessionBus()
-
-local_service = dbus.Service("org.designfu.Test", bus=session_bus)
-local_object = TestObject(local_service)
-
-gtk.main()