conduit r1479 - in trunk: . conduit conduit/dataproviders conduit/gtkui conduit/modules conduit/modules/ZotoModule test/python-tests tools tools/eog-plugin tools/yaput
- From: jstowers svn gnome org
- To: svn-commits-list gnome org
- Subject: conduit r1479 - in trunk: . conduit conduit/dataproviders conduit/gtkui conduit/modules conduit/modules/ZotoModule test/python-tests tools tools/eog-plugin tools/yaput
- Date: Sun, 1 Jun 2008 09:23:48 +0000 (UTC)
Author: jstowers
Date: Sun Jun 1 09:23:47 2008
New Revision: 1479
URL: http://svn.gnome.org/viewvc/conduit?rev=1479&view=rev
Log:
merge from uni branch
Added:
trunk/test/python-tests/TestDataProviderZoto.py
Removed:
trunk/tools/yaput/
Modified:
trunk/ (props changed)
trunk/ChangeLog
trunk/conduit/Conduit.py
trunk/conduit/DBus.py
trunk/conduit/Main.py
trunk/conduit/Synchronization.py
trunk/conduit/dataproviders/HalFactory.py
trunk/conduit/dataproviders/SimpleFactory.py
trunk/conduit/dataproviders/VolumeFactory.py
trunk/conduit/gtkui/Canvas.py
trunk/conduit/modules/TestModule.py
trunk/conduit/modules/ZotoModule/ZotoModule.py
trunk/tools/conduit-client
trunk/tools/eog-plugin/conduit.py
trunk/tools/example-dbus-gui-remote.py
Modified: trunk/conduit/Conduit.py
==============================================================================
--- trunk/conduit/Conduit.py (original)
+++ trunk/conduit/Conduit.py Sun Jun 1 09:23:47 2008
@@ -59,7 +59,8 @@
gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, []),
"sync-progress": (
gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, [
- gobject.TYPE_FLOAT]) #percent complete
+ gobject.TYPE_FLOAT, #percent complete
+ gobject.TYPE_PYOBJECT]) #list of successfully completed UIDs
}
def __init__(self, syncManager, uid=""):
Modified: trunk/conduit/DBus.py
==============================================================================
--- trunk/conduit/DBus.py (original)
+++ trunk/conduit/DBus.py Sun Jun 1 09:23:47 2008
@@ -8,7 +8,6 @@
import os.path
import dbus
import dbus.service
-import dbus.glib
import logging
log = logging.getLogger("DBus")
@@ -20,7 +19,7 @@
ERROR = -1
SUCCESS = 0
-DEBUG_ALL_CALLS = False
+DEBUG_ALL_CALLS = True
APPLICATION_DBUS_IFACE="org.conduit.Application"
SYNCSET_DBUS_IFACE="org.conduit.SyncSet"
@@ -82,7 +81,7 @@
# SyncStarted
# SyncCompleted(aborted, error, conflict)
# SyncConflict
-# SyncProgress(progress)
+# SyncProgress(progress, completedUIDs)
# DataproviderAdded
# DataproviderRemoved
#
@@ -154,9 +153,9 @@
if cond == self.conduit:
self.SyncCompleted(bool(aborted), bool(error), bool(conflict))
- def _on_sync_progress(self, cond, progress):
+ def _on_sync_progress(self, cond, progress, UIDs):
if cond == self.conduit:
- self.SyncProgress(float(progress))
+ self.SyncProgress(float(progress), UIDs)
def _on_sync_conflict(self, cond, conflict):
if cond == self.conduit:
@@ -229,9 +228,9 @@
def SyncConflict(self):
self._print("SyncConflict")
- @dbus.service.signal(CONDUIT_DBUS_IFACE, signature='d')
- def SyncProgress(self, progress):
- self._print("SyncProgress %s%%" % (progress*100.0))
+ @dbus.service.signal(CONDUIT_DBUS_IFACE, signature='das')
+ def SyncProgress(self, progress, UIDs):
+ self._print("SyncProgress %s%%\n\t%s" % ((progress*100.0), UIDs))
#
# org.conduit.Exporter
Modified: trunk/conduit/Main.py
==============================================================================
--- trunk/conduit/Main.py (original)
+++ trunk/conduit/Main.py Sun Jun 1 09:23:47 2008
@@ -1,9 +1,12 @@
import os
import getopt
import sys
-import dbus, dbus.service, dbus.glib
+import dbus, dbus.service, dbus.mainloop.glib
import gobject
+dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
+dbus.mainloop.glib.threads_init()
+
import logging
log = logging.getLogger("Main")
@@ -269,12 +272,15 @@
#unitialize all dataproviders
log.info("Unitializing dataproviders")
self.guiSyncSet.quit()
+ log.info("GUI Quit")
self.dbusSyncSet.quit()
+ log.info("DBus Quit")
#Save the mapping DB
conduit.GLOBALS.mappingDB.save()
conduit.GLOBALS.mappingDB.close()
+ log.info("Main Loop Quitting")
conduit.GLOBALS.mainloop.quit()
@dbus.service.method(APPLICATION_DBUS_IFACE, in_signature='', out_signature='')
Modified: trunk/conduit/Synchronization.py
==============================================================================
--- trunk/conduit/Synchronization.py (original)
+++ trunk/conduit/Synchronization.py Sun Jun 1 09:23:47 2008
@@ -272,6 +272,9 @@
Operates on a per Conduit basis, so a single SyncWorker may synchronize
one source with many sinks within a single conduit
"""
+
+ PROGRESS_UPDATE_THRESHOLD = 5.0/100
+
def __init__(self, typeConverter, cond, do_sync):
_ThreadedWorker.__init__(self)
self.typeConverter = typeConverter
@@ -280,11 +283,28 @@
self.sinks = cond.datasinks
self.do_sync = do_sync
+ self._progress = 0
+ self._progressUIDs = []
+
+
if self.cond.is_two_way():
self.setName("%s <--> %s" % (self.source, self.sinks[0]))
else:
self.setName("%s |--> %s" % (self.source, self.sinks))
+ def _emit_progress(self, progress, dataUID):
+ """
+ Emits progress signals, if the elapsed progress since the last
+ call to this function is greater that 5%. This is necessary because
+ otherwise we starve the main loop with too frequent progress
+ events
+ """
+ self._progressUIDs.append(dataUID)
+ if (progress - self._progress) > self.PROGRESS_UPDATE_THRESHOLD or progress == 1.0:
+ self._progress = progress
+ self.cond.emit("sync-progress", self._progress, self._progressUIDs)
+ self._progressUIDs = []
+
def _get_data(self, source, sink, uid):
"""
Gets the data from source. Handles exceptions, etc.
@@ -303,10 +323,13 @@
"""
Handles exceptions when putting data from source to sink. Default is
not to overwrite
+
+ @returns: True if the data was successfully put
"""
if sourceData != None:
try:
put_data(source, sink, sourceData, sourceDataRid, False)
+ return True
except Exceptions.SyncronizeError, err:
log.warn("%s\n%s" % (err, traceback.format_exc()))
self.sinkErrors[sink] = DataProvider.STATUS_DONE_SYNC_ERROR
@@ -321,6 +344,8 @@
self._apply_conflict_policy(source, sink, err.comparison, sourceData, sourceDataRid, err.toData, err.toData.get_rid())
else:
log.info("Could not put data: Was None")
+
+ return False
def _convert_data(self, source, sink, data):
"""
@@ -457,11 +482,6 @@
idx += 1.0
self.check_thread_not_cancelled([source, sink])
- #work out the percent complete
- done = idx/(numItems*len(self.sinks)) + \
- float(self.sinks.index(sink))/len(self.sinks)
- self.cond.emit("sync-progress", done)
-
#transfer the data
data = self._get_data(source, sink, i)
if data != None:
@@ -469,6 +489,11 @@
dataRid = data.get_rid()
data = self._convert_data(source, sink, data)
self._put_data(source, sink, data, dataRid)
+
+ #work out the percent complete
+ done = idx/(numItems*len(self.sinks)) + \
+ float(self.sinks.index(sink))/len(self.sinks)
+ self._emit_progress(done, i)
def two_way_sync(self, source, sink):
"""
@@ -535,7 +560,7 @@
#progress
cnt = cnt+1
- self.cond.emit("sync-progress", float(cnt)/total)
+ self._emit_progress(float(cnt)/total, dataUID)
for sourcedp, dataUID, sinkdp in toput:
data = self._get_data(sourcedp, sinkdp, dataUID)
@@ -546,7 +571,7 @@
self._put_data(sourcedp, sinkdp, data, dataRid)
cnt = cnt+1
- self.cond.emit("sync-progress", float(cnt)/total)
+ self._emit_progress(float(cnt)/total, dataUID)
#FIXME: rename dp1 -> sourcedp1 and dp2 -> sinkdp2 because when both
#data is modified we might as well choost source -> sink as the comparison direction
@@ -562,9 +587,6 @@
log.debug("2WAY CMP: %s v %s" % (data1, data2))
- cnt = cnt+1
- self.cond.emit("sync-progress", float(cnt)/total)
-
#compare the data
if data1 != None and data2 != None:
comparison = data1.compare(data2)
@@ -573,6 +595,10 @@
else:
self._apply_conflict_policy(dp1, dp2, COMPARISON_UNKNOWN, data1, data1Rid, data2, data2Rid)
+ cnt = cnt+1
+ self._emit_progress(float(cnt)/total, data1UID)
+
+
def run(self):
"""
The main syncronisation state machine.
Modified: trunk/conduit/dataproviders/HalFactory.py
==============================================================================
--- trunk/conduit/dataproviders/HalFactory.py (original)
+++ trunk/conduit/dataproviders/HalFactory.py Sun Jun 1 09:23:47 2008
@@ -1,6 +1,5 @@
import gobject
import dbus
-import dbus.glib
import conduit.utils as Utils
import conduit.dataproviders.SimpleFactory as SimpleFactory
Modified: trunk/conduit/dataproviders/SimpleFactory.py
==============================================================================
--- trunk/conduit/dataproviders/SimpleFactory.py (original)
+++ trunk/conduit/dataproviders/SimpleFactory.py Sun Jun 1 09:23:47 2008
@@ -1,4 +1,3 @@
-
import logging
log = logging.getLogger("dataproviders.SimpleFactory")
Modified: trunk/conduit/dataproviders/VolumeFactory.py
==============================================================================
--- trunk/conduit/dataproviders/VolumeFactory.py (original)
+++ trunk/conduit/dataproviders/VolumeFactory.py Sun Jun 1 09:23:47 2008
@@ -1,4 +1,3 @@
-
import logging
log = logging.getLogger("dataproviders.SimpleFactory")
@@ -8,7 +7,6 @@
import conduit.Vfs as Vfs
import dbus
-import dbus.glib
class VolumeFactory(SimpleFactory.SimpleFactory):
"""
Modified: trunk/conduit/gtkui/Canvas.py
==============================================================================
--- trunk/conduit/gtkui/Canvas.py (original)
+++ trunk/conduit/gtkui/Canvas.py Sun Jun 1 09:23:47 2008
@@ -783,7 +783,7 @@
if item.model.get_key() == olddpw.get_key():
item.set_model(newdpw)
- def _on_conduit_progress(self, cond, percent):
+ def _on_conduit_progress(self, cond, percent, UIDs):
self.progressText.set_property("text","%2.1d%% complete" % int(percent*100.0))
def _get_connector_coordinates(self, fromdp, todp):
Modified: trunk/conduit/modules/TestModule.py
==============================================================================
--- trunk/conduit/modules/TestModule.py (original)
+++ trunk/conduit/modules/TestModule.py Sun Jun 1 09:23:47 2008
@@ -462,9 +462,12 @@
self.format = "image/jpeg"
self.defaultFormat = "image/jpeg"
self.size = "640x480"
+ self.slow = False
#ImageSink Methods
def _upload_photo(self, uploadInfo):
+ if self.slow:
+ time.sleep(2)
LUID = "%s%s%s" % (uploadInfo.name,uploadInfo.url,self._name_)
return Rid(uid=LUID)
@@ -491,6 +494,8 @@
self.defaultFormat = str(param)
def setSize(param):
self.size = str(param)
+ def setSlow(param):
+ self.slow = bool(param)
items = [
{
@@ -510,14 +515,17 @@
"Widget" : gtk.Entry,
"Callback" : setSize,
"InitialValue" : self.size
+ },
+ {
+ "Name" : "Take a Long Time?",
+ "Widget" : gtk.CheckButton,
+ "Callback" : setSlow,
+ "InitialValue" : self.slow
}
]
dialog = SimpleConfigurator.SimpleConfigurator(window, self._name_, items)
dialog.run()
- def is_configured (self):
- return True
-
class TestConversionArgs(_TestConversionBase):
_name_ = "Test Conversion Args"
Modified: trunk/conduit/modules/ZotoModule/ZotoModule.py
==============================================================================
--- trunk/conduit/modules/ZotoModule/ZotoModule.py (original)
+++ trunk/conduit/modules/ZotoModule/ZotoModule.py Sun Jun 1 09:23:47 2008
@@ -85,6 +85,9 @@
f.close()
fotoId= md5.md5(buf).hexdigest()
+ if not uploadInfo.caption:
+ uploadInfo.caption=''
+
self.server.images.add(self.zapiKey, self.zotoAuth, uploadInfo.name,
uploadInfo.name, uploadInfo.caption, xmlrpclib.Binary(buf))
self.server.albums.multi_add_image(self.zapiKey, self.zotoAuth,
Added: trunk/test/python-tests/TestDataProviderZoto.py
==============================================================================
--- (empty file)
+++ trunk/test/python-tests/TestDataProviderZoto.py Sun Jun 1 09:23:47 2008
@@ -0,0 +1,55 @@
+#common sets up the conduit environment
+from common import *
+
+if not is_online():
+ skip()
+
+#A Reliable album name
+SAFE_ALBUM_NAME = "test"
+# Album id of the Conduit test album
+SAFE_ALBUM_ID = 15860
+# Image id of photo in test album
+SAFE_PHOTO_ID = '6fd9a52fbb14c4e044b5a6c5de956b7e'
+
+#setup the test
+test = SimpleTest(sinkName="ZotoSink")
+config = {
+ "username": os.environ.get("TEST_USERNAME","conduitproject"),
+ "password": os.environ["TEST_PASSWORD"],
+ "albumName" : SAFE_ALBUM_NAME
+}
+
+test.configure(sink=config)
+
+#get the module directly so we can call some special functions on it
+zoto = test.get_sink().module
+
+#Log in
+try:
+ zoto.refresh()
+ ok("Logged in", True)
+except Exception, err:
+ ok("Logged in (%s)" % err, False)
+
+# Test getting the album id
+if not zoto.albumId:
+ ok("Didn't succeed in getting an album id...", False)
+
+album_id = zoto.albumId
+
+if album_id:
+ ok("Got album id %s for album %s" % (album_id, SAFE_ALBUM_NAME), True)
+ if album_id == SAFE_ALBUM_ID:
+ ok("Album id %s equals the one we're expecting %s" % (album_id, SAFE_ALBUM_ID), True)
+ else:
+ ok("Album id %s does not equal the one we're expecting %s" % (album_id, SAFE_ALBUM_ID), False)
+
+#Perform image tests
+test.do_image_dataprovider_tests(
+ supportsGet=True,
+ supportsDelete=True,
+ safePhotoLUID=SAFE_PHOTO_ID,
+ ext="jpg"
+ )
+
+finished()
Modified: trunk/tools/conduit-client
==============================================================================
--- trunk/tools/conduit-client (original)
+++ trunk/tools/conduit-client Sun Jun 1 09:23:47 2008
@@ -37,7 +37,7 @@
for dp in self.app.GetAllDataProviders():
print " *\t%s" % dp
- def on_sync_progress(self, progress):
+ def on_sync_progress(self, progress, uids):
print "Synchronization %2.2f%% complete" % (progress*100.0)
def on_sync_completed(self, abort, error, conflict):
@@ -72,7 +72,7 @@
#configure
if config != None:
self.sink.SetConfigurationXml(config)
- if not self.sink.IsConfigured():
+ if not self.sink.IsConfigured(False, twoWay):
self.sink.Configure()
# now create conduit
Modified: trunk/tools/eog-plugin/conduit.py
==============================================================================
--- trunk/tools/eog-plugin/conduit.py (original)
+++ trunk/tools/eog-plugin/conduit.py Sun Jun 1 09:23:47 2008
@@ -41,7 +41,7 @@
self.rowref = None
self.configured = False
self.pendingSync = False
-
+
self.conduit.connect_to_signal(
"SyncProgress",
self._on_sync_progress,
@@ -52,6 +52,11 @@
self._on_sync_completed,
dbus_interface=CONDUIT_DBUS_IFACE
)
+ self.conduit.connect_to_signal(
+ "SyncStarted",
+ self._on_sync_started,
+ dbus_interface=CONDUIT_DBUS_IFACE
+ )
def _get_configuration(self):
"""
@@ -109,10 +114,27 @@
def _configure_error_handler(self, error):
pass
-
- def _on_sync_progress(self, progress):
- rowref = self._get_rowref()
- self.store.set_value(rowref, STATUS_IDX, "finished")
+
+ def _on_sync_started(self):
+ self.store.set_value(self._get_rowref(), STATUS_IDX, "uploading")
+
+ def _on_sync_progress(self, progress, uids):
+ uris = [str(i) for i in uids]
+ delete = []
+
+ treeiter = self.store.iter_children(self._get_rowref())
+ while treeiter:
+ if self.store.get_value(treeiter, URI_IDX) in uris:
+ delete.append(treeiter)
+ treeiter = self.store.iter_next(treeiter)
+
+ for d in delete:
+ self.store.remove(d)
+
+ #for uri in uids:
+ # rowref = self._get_rowref_for_photo(str(uri))
+ # print "\t%s - %s" % (uri, rowref)
+ # print "\t",self.photoRefs
def _on_sync_completed(self, abort, error, conflict):
rowref = self._get_rowref()
Modified: trunk/tools/example-dbus-gui-remote.py
==============================================================================
--- trunk/tools/example-dbus-gui-remote.py (original)
+++ trunk/tools/example-dbus-gui-remote.py Sun Jun 1 09:23:47 2008
@@ -33,7 +33,7 @@
dps = app.GetAllDataProviders()
if not FOLDER_TWOWAY in dps or not FLICKR_TWOWAY in dps:
- print "Could not find folder/flickt"
+ print "Could not find folder/flickr"
exit()
bus = dbus.SessionBus()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]