conduit r1375 - in trunk: . conduit conduit/modules/FileModule
- From: jstowers svn gnome org
- To: svn-commits-list gnome org
- Subject: conduit r1375 - in trunk: . conduit conduit/modules/FileModule
- Date: Sat, 15 Mar 2008 00:37:13 +0000 (GMT)
Author: jstowers
Date: Sat Mar 15 00:37:13 2008
New Revision: 1375
URL: http://svn.gnome.org/viewvc/conduit?rev=1375&view=rev
Log:
2008-03-15 John Stowers <john stowers gmail com>
* conduit/Vfs.py:
* conduit/modules/FileModule/FileModule.py: Even if a removable volume
does not contain previously synchronized groups, still create a
preconfigured dataprovider. This really helps discoverability.
Modified:
trunk/ChangeLog
trunk/conduit/Vfs.py
trunk/conduit/modules/FileModule/FileModule.py
Modified: trunk/conduit/Vfs.py
==============================================================================
--- trunk/conduit/Vfs.py (original)
+++ trunk/conduit/Vfs.py Sat Mar 15 00:37:13 2008
@@ -49,14 +49,15 @@
@returns: True if the specified uri is on a removable volume, like a USB key
or removable/mountable disk.
"""
- #HACKISH
- #return uri.count("/media/") != 0
scheme = gnomevfs.get_uri_scheme(uri)
if scheme == "file":
+ #FIXME: Unfortunately this approach actually works better than gnomevfs
+ #return uri.startswith("file:///media/")
try:
path = uri_to_local_path(uri)
return VolumeMonitor().get_volume_for_path(path).is_user_visible()
- except:
+ except Exception, e:
+ log.warn("Could not determine if uri on removable volume: %s" % uri)
return False
return False
Modified: trunk/conduit/modules/FileModule/FileModule.py
==============================================================================
--- trunk/conduit/modules/FileModule/FileModule.py (original)
+++ trunk/conduit/modules/FileModule/FileModule.py Sat Mar 15 00:37:13 2008
@@ -136,20 +136,35 @@
VolumeFactory.VolumeFactory.__init__(self, **kwargs)
self._volumes = []
- def _make_class(self, folder, name):
+ def _make_class(self, udi, folder, name):
log.info("Creating preconfigured folder dataprovider: %s" % folder)
+ info = {
+ "DEFAULT_FOLDER": folder,
+ "_udi_" : udi
+ }
+ if name:
+ info["DEFAULT_GROUP"] = name
+ info["_name_"] = name
+
klass = type(
"FolderTwoWay",
(FolderTwoWay,),
- {"DEFAULT_FOLDER":folder,"DEFAULT_GROUP":name}
+ info
)
return klass
def emit_added(self, klass, initargs, category):
"""
- Override emit_added to allow duplictes.
+ Override emit_added to allow duplictes. The custom key is based on
+ the folder and the udi to allow multiple preconfigured groups per
+ usb key
"""
- VolumeFactory.VolumeFactory.emit_added(self, klass, initargs, category, customKey="12345")
+ VolumeFactory.VolumeFactory.emit_added(self,
+ klass,
+ initargs,
+ category,
+ customKey="%s-%s" % (klass.DEFAULT_FOLDER, klass._udi_)
+ )
def is_interesting(self, udi, props):
if props.has_key("info.parent") and props.has_key("info.parent") != "":
@@ -160,12 +175,24 @@
#check for the presence of a mount/.conduit group file
#which describe the folder sync groups, and their names,
mountUri = "file://%s" % mount
- for relativeUri,name in FileDataProvider.read_removable_volume_group_file(mountUri):
- klass = self._make_class(
- #uri is relative, make it absolute
- "%s%s" % (mountUri,relativeUri),
- name)
- self._volumes.append(klass)
+
+ groups = FileDataProvider.read_removable_volume_group_file(mountUri)
+ if len(groups) > 0:
+ for relativeUri,name in groups:
+ klass = self._make_class(
+ udi=udi,
+ #uri is relative, make it absolute
+ folder="%s%s" % (mountUri,relativeUri),
+ name=name)
+ self._volumes.append(klass)
+ else:
+ if FileDataProvider.is_on_removable_volume(mountUri):
+ klass = self._make_class(
+ udi=udi,
+ folder=mountUri,
+ name=None)
+ self._volumes.append(klass)
+
return True
return False
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]