conduit r1203 - in trunk: . conduit/modules conduit/modules/NetworkModule test/python-tests
- From: jstowers svn gnome org
- To: svn-commits-list gnome org
- Subject: conduit r1203 - in trunk: . conduit/modules conduit/modules/NetworkModule test/python-tests
- Date: Sat, 12 Jan 2008 20:54:30 +0000 (GMT)
Author: jstowers
Date: Sat Jan 12 20:54:30 2008
New Revision: 1203
URL: http://svn.gnome.org/viewvc/conduit?rev=1203&view=rev
Log:
Fix xmlrpc again. Sigh
Modified:
trunk/ChangeLog
trunk/conduit/modules/NetworkModule/Client.py
trunk/conduit/modules/NetworkModule/Peers.py
trunk/conduit/modules/TestModule.py
trunk/test/python-tests/TestCoreSyncTestDataProviders.py
Modified: trunk/conduit/modules/NetworkModule/Client.py
==============================================================================
--- trunk/conduit/modules/NetworkModule/Client.py (original)
+++ trunk/conduit/modules/NetworkModule/Client.py Sat Jan 12 20:54:30 2008
@@ -97,7 +97,7 @@
if remoteUid not in currentSharedDps:
self.dataprovider_added(hostUrl, remoteUid, info)
- for remoteUid in currentSharedDps:
+ for remoteUid in currentSharedDps.keys():
if remoteUid not in remoteSharedDps:
self.dataprovider_removed(hostUrl, remoteUid)
Modified: trunk/conduit/modules/NetworkModule/Peers.py
==============================================================================
--- trunk/conduit/modules/NetworkModule/Peers.py (original)
+++ trunk/conduit/modules/NetworkModule/Peers.py Sat Jan 12 20:54:30 2008
@@ -11,7 +11,6 @@
License: GPLv2
"""
-import avahi
import dbus.glib
import logging
log = logging.getLogger("modules.Network")
@@ -24,31 +23,97 @@
PORT_IDX = 0
VERSION_IDX = 1
+###
+#Instead of having to depend on python-avahi we just
+#copy the functions and constants we need
+###
+DBUS_INTERFACE_ADDRESS_RESOLVER = 'org.freedesktop.Avahi.AddressResolver'
+DBUS_INTERFACE_DOMAIN_BROWSER = 'org.freedesktop.Avahi.DomainBrowser'
+DBUS_INTERFACE_ENTRY_GROUP = 'org.freedesktop.Avahi.EntryGroup'
+DBUS_INTERFACE_HOST_NAME_RESOLVER = 'org.freedesktop.Avahi.HostNameResolver'
+DBUS_INTERFACE_RECORD_BROWSER = 'org.freedesktop.Avahi.RecordBrowser'
+DBUS_INTERFACE_SERVER = 'org.freedesktop.Avahi.Server'
+DBUS_INTERFACE_SERVICE_BROWSER = 'org.freedesktop.Avahi.ServiceBrowser'
+DBUS_INTERFACE_SERVICE_RESOLVER = 'org.freedesktop.Avahi.ServiceResolver'
+DBUS_INTERFACE_SERVICE_TYPE_BROWSER = 'org.freedesktop.Avahi.ServiceTypeBrowser'
+DBUS_NAME = 'org.freedesktop.Avahi'
+DBUS_PATH_SERVER = '/'
+DOMAIN_BROWSER_BROWSE = 0
+DOMAIN_BROWSER_BROWSE_DEFAULT = 1
+DOMAIN_BROWSER_BROWSE_LEGACY = 4
+DOMAIN_BROWSER_REGISTER = 2
+DOMAIN_BROWSER_REGISTER_DEFAULT = 3
+ENTRY_GROUP_COLLISION = 3
+ENTRY_GROUP_ESTABLISHED = 2
+ENTRY_GROUP_FAILURE = 4
+ENTRY_GROUP_REGISTERING = 1
+ENTRY_GROUP_UNCOMMITED = 0
+IF_UNSPEC = -1
+LOOKUP_NO_ADDRESS = 8
+LOOKUP_NO_TXT = 4
+LOOKUP_RESULT_CACHED = 1
+LOOKUP_RESULT_LOCAL = 8
+LOOKUP_RESULT_MULTICAST = 4
+LOOKUP_RESULT_OUR_OWN = 16
+LOOKUP_RESULT_STATIC = 32
+LOOKUP_RESULT_WIDE_AREA = 2
+LOOKUP_USE_MULTICAST = 2
+LOOKUP_USE_WIDE_AREA = 1
+PROTO_INET = 0
+PROTO_INET6 = 1
+PROTO_UNSPEC = -1
+PUBLISH_ALLOW_MULTIPLE = 8
+PUBLISH_NO_ANNOUNCE = 4
+PUBLISH_NO_COOKIE = 32
+PUBLISH_NO_PROBE = 2
+PUBLISH_NO_REVERSE = 16
+PUBLISH_UNIQUE = 1
+PUBLISH_UPDATE = 64
+PUBLISH_USE_MULTICAST = 256
+PUBLISH_USE_WIDE_AREA = 128
+SERVER_COLLISION = 3
+SERVER_FAILURE = 4
+SERVER_INVALID = 0
+SERVER_REGISTERING = 1
+SERVER_RUNNING = 2
+SERVICE_COOKIE = 'org.freedesktop.Avahi.cookie'
+SERVICE_COOKIE_INVALID = 0
+
def byte_array_to_string(s):
r = ""
-
for c in s:
-
if c >= 32 and c < 127:
r += "%c" % c
else:
r += "."
-
return r
def txt_array_to_string_array(t):
l = []
-
for s in t:
l.append(byte_array_to_string(s))
+ return l
+
+def string_to_byte_array(s):
+ r = []
+ for c in s:
+ r.append(dbus.Byte(ord(c)))
+ return r
+
+def string_array_to_txt_array(t):
+ l = []
+ for s in t:
+ l.append(string_to_byte_array(s))
return l
-def decode_avahi_text_array_to_dict(array):
- """
- Avahi text arrays are encoded as key=value
- This function converts the array to a dict
- """
+def dict_to_txt_array(txt_dict):
+ l = []
+ for k,v in txt_dict.items():
+ l.append(string_to_byte_array("%s=%s" % (k,v)))
+ return l
+
+def txt_array_to_dict(array):
d = {}
for i in array:
bits = i.split("=")
@@ -56,16 +121,6 @@
d[bits[0]] = bits[1]
return d
-def encode_dict_to_avahi_text_array(d):
- """
- Encodes a python dict to the 'key=value' format expected
- by avahi
- """
- array = []
- for key in d:
- array.append("%s=%s" % (key, d[key]))
- return array
-
class AvahiAdvertiser:
"""
Advertises the presence of dataprovider instances on the network using avahi.
@@ -180,7 +235,7 @@
Dbus callback
"""
extra_info = txt_array_to_string_array(txt)
- extra = decode_avahi_text_array_to_dict(extra_info)
+ extra = txt_array_to_dict(extra_info)
log.debug("Resolved conduit service %s on %s - %s:%s\nExtra Info: %s" % (name, host, address, port, extra_info))
@@ -204,55 +259,5 @@
log.warn("Avahi/D-Bus error: %s" % repr(error))
-DBUS_INTERFACE_ADDRESS_RESOLVER = 'org.freedesktop.Avahi.AddressResolver'
-DBUS_INTERFACE_DOMAIN_BROWSER = 'org.freedesktop.Avahi.DomainBrowser'
-DBUS_INTERFACE_ENTRY_GROUP = 'org.freedesktop.Avahi.EntryGroup'
-DBUS_INTERFACE_HOST_NAME_RESOLVER = 'org.freedesktop.Avahi.HostNameResolver'
-DBUS_INTERFACE_RECORD_BROWSER = 'org.freedesktop.Avahi.RecordBrowser'
-DBUS_INTERFACE_SERVER = 'org.freedesktop.Avahi.Server'
-DBUS_INTERFACE_SERVICE_BROWSER = 'org.freedesktop.Avahi.ServiceBrowser'
-DBUS_INTERFACE_SERVICE_RESOLVER = 'org.freedesktop.Avahi.ServiceResolver'
-DBUS_INTERFACE_SERVICE_TYPE_BROWSER = 'org.freedesktop.Avahi.ServiceTypeBrowser'
-DBUS_NAME = 'org.freedesktop.Avahi'
-DBUS_PATH_SERVER = '/'
-DOMAIN_BROWSER_BROWSE = 0
-DOMAIN_BROWSER_BROWSE_DEFAULT = 1
-DOMAIN_BROWSER_BROWSE_LEGACY = 4
-DOMAIN_BROWSER_REGISTER = 2
-DOMAIN_BROWSER_REGISTER_DEFAULT = 3
-ENTRY_GROUP_COLLISION = 3
-ENTRY_GROUP_ESTABLISHED = 2
-ENTRY_GROUP_FAILURE = 4
-ENTRY_GROUP_REGISTERING = 1
-ENTRY_GROUP_UNCOMMITED = 0
-IF_UNSPEC = -1
-LOOKUP_NO_ADDRESS = 8
-LOOKUP_NO_TXT = 4
-LOOKUP_RESULT_CACHED = 1
-LOOKUP_RESULT_LOCAL = 8
-LOOKUP_RESULT_MULTICAST = 4
-LOOKUP_RESULT_OUR_OWN = 16
-LOOKUP_RESULT_STATIC = 32
-LOOKUP_RESULT_WIDE_AREA = 2
-LOOKUP_USE_MULTICAST = 2
-LOOKUP_USE_WIDE_AREA = 1
-PROTO_INET = 0
-PROTO_INET6 = 1
-PROTO_UNSPEC = -1
-PUBLISH_ALLOW_MULTIPLE = 8
-PUBLISH_NO_ANNOUNCE = 4
-PUBLISH_NO_COOKIE = 32
-PUBLISH_NO_PROBE = 2
-PUBLISH_NO_REVERSE = 16
-PUBLISH_UNIQUE = 1
-PUBLISH_UPDATE = 64
-PUBLISH_USE_MULTICAST = 256
-PUBLISH_USE_WIDE_AREA = 128
-SERVER_COLLISION = 3
-SERVER_FAILURE = 4
-SERVER_INVALID = 0
-SERVER_REGISTERING = 1
-SERVER_RUNNING = 2
-SERVICE_COOKIE = 'org.freedesktop.Avahi.cookie'
-SERVICE_COOKIE_INVALID = 0
+
Modified: trunk/conduit/modules/TestModule.py
==============================================================================
--- trunk/conduit/modules/TestModule.py (original)
+++ trunk/conduit/modules/TestModule.py Sat Jan 12 20:54:30 2008
@@ -227,7 +227,7 @@
class TestSource(_TestBase, DataProvider.DataSource):
_name_ = "Test Source"
- _description_ = "Prints Debug Messages"
+ _description_ = "Emits TestDataTypes"
_category_ = conduit.dataproviders.CATEGORY_TEST
_module_type_ = "source"
_in_type_ = "test_type"
@@ -291,7 +291,7 @@
class TestSink(_TestBase, DataProvider.DataSink):
_name_ = "Test Sink"
- _description_ = "Prints Debug Messages"
+ _description_ = "Consumes TestDataTypes"
_category_ = conduit.dataproviders.CATEGORY_TEST
_module_type_ = "sink"
_in_type_ = "test_type"
@@ -315,7 +315,7 @@
class TestTwoWay(TestSource, TestSink):
_name_ = "Test Two Way"
- _description_ = "Prints Debug Messages"
+ _description_ = "Sync TestDataTypes"
_category_ = conduit.dataproviders.CATEGORY_TEST
_module_type_ = "twoway"
_in_type_ = "test_type"
@@ -326,10 +326,10 @@
TestSource.__init__(self)
TestSink.__init__(self)
-class TestFileSource(DataProvider.DataSource):
+class TestFileSource(_TestBase, DataProvider.DataSource):
_name_ = "Test File Source"
- _description_ = "Prints Debug Messages"
+ _description_ = "Emits Files"
_category_ = conduit.dataproviders.CATEGORY_TEST
_module_type_ = "source"
_in_type_ = "file"
@@ -337,7 +337,9 @@
_icon_ = "text-x-generic"
def __init__(self, *args):
+ _TestBase.__init__(self)
DataProvider.DataSource.__init__(self)
+ self.UID = Utils.random_string()
def get_all(self):
DataProvider.DataSource.get_all(self)
@@ -354,13 +356,10 @@
f.set_UID(LUID)
return f
- def get_UID(self):
- return Utils.random_string()
-
-class TestFileSink(DataProvider.DataSink):
+class TestFileSink(_TestBase, DataProvider.DataSink):
_name_ = "Test File Sink"
- _description_ = "Prints Debug Messages"
+ _description_ = "Consumes Files"
_category_ = conduit.dataproviders.CATEGORY_TEST
_module_type_ = "sink"
_in_type_ = "file"
@@ -368,6 +367,7 @@
_icon_ = "text-x-generic"
def __init__(self, *args):
+ _TestBase.__init__(self)
DataProvider.DataSink.__init__(self)
def put(self, data, overwrite, LUID=None):
@@ -376,16 +376,15 @@
newData = TestDataType(data.get_size())
return newData.get_rid()
- def get_UID(self):
- return Utils.random_string()
-
-class TestImageSink(Image.ImageSink):
+class TestImageSink(_TestBase, Image.ImageSink):
_name_ = "Test Image Sink"
+ _description_ = "Consumes Images"
_icon_ = "image-x-generic"
_category_ = conduit.dataproviders.CATEGORY_TEST
def __init__(self, *args):
+ _TestBase.__init__(self)
Image.ImageSink.__init__(self)
self.format = "image/jpeg"
@@ -447,13 +446,10 @@
def is_configured (self):
return True
- def get_UID(self):
- return Utils.random_string()
-
class TestConversionArgs(_TestConversionBase):
_name_ = "Test Conversion Args"
- _description_ = "Pass args to converters"
+ _description_ = "Pass Arguments to TestConverter"
_category_ = conduit.dataproviders.CATEGORY_TEST
_module_type_ = "sink"
_in_type_ = "test_type"
@@ -499,7 +495,7 @@
class TestWebTwoWay(TestTwoWay):
_name_ = "Test Web"
- _description_ = "Launches Conduits Browser"
+ _description_ = "Launches Web Browser"
_category_ = conduit.dataproviders.CATEGORY_TEST
_module_type_ = "twoway"
_in_type_ = "test_type"
@@ -549,7 +545,7 @@
class TestSinkNeedConfigure(_TestBase, DataProvider.DataSink):
_name_ = "Test Need Configure"
- _description_ = "Test Sink Needs Configuration"
+ _description_ = "Needs Configuration"
_category_ = conduit.dataproviders.CATEGORY_TEST
_module_type_ = "sink"
_in_type_ = "test_type"
@@ -570,7 +566,7 @@
class TestSinkFailRefresh(_TestBase, DataProvider.DataSink):
_name_ = "Test Fail Refresh"
- _description_ = "Test Sink Fails Refresh"
+ _description_ = "Fails Refresh"
_category_ = conduit.dataproviders.CATEGORY_TEST
_module_type_ = "sink"
_in_type_ = "test_type"
@@ -585,10 +581,10 @@
DataProvider.DataSink.refresh(self)
raise Exceptions.RefreshError
-class TestConflict(DataProvider.DataSink):
+class TestConflict(_TestBase, DataProvider.DataSink):
_name_ = "Test Conflict"
- _description_ = "Test Sink Conflict"
+ _description_ = "Raises a Conflict"
_category_ = conduit.dataproviders.CATEGORY_TEST
_module_type_ = "sink"
_in_type_ = "test_type"
@@ -596,6 +592,7 @@
_icon_ = "dialog-warning"
def __init__(self, *args):
+ _TestBase.__init__(self)
DataProvider.DataSink.__init__(self)
def refresh(self):
Modified: trunk/test/python-tests/TestCoreSyncTestDataProviders.py
==============================================================================
--- trunk/test/python-tests/TestCoreSyncTestDataProviders.py (original)
+++ trunk/test/python-tests/TestCoreSyncTestDataProviders.py Sat Jan 12 20:54:30 2008
@@ -40,6 +40,22 @@
ok("Sync aborted due to no refreshing sinks", aborted == True)
###
+#One way, should abort (not configured)
+###
+ok("---- ONE WAY: SHOULD ABORT (Not Configured)", True)
+test = SimpleSyncTest()
+test.set_two_way_policy({"conflict":"skip","deleted":"skip"})
+test.prepare(
+ test.get_dataprovider("TestSource"),
+ test.get_dataprovider("TestSinkNeedConfigure")
+ )
+
+test.set_two_way_sync(False)
+test.sync(debug=False)
+aborted = test.sync_aborted()
+ok("Sync aborted due to no configured sinks", aborted == True)
+
+###
#One way, should conflict
###
ok("---- ONE WAY: SHOULD CONFLICT", True)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]