conduit r1176 - in trunk: . conduit conduit/modules/FileModule test/python-tests
- From: jstowers svn gnome org
- To: svn-commits-list gnome org
- Subject: conduit r1176 - in trunk: . conduit conduit/modules/FileModule test/python-tests
- Date: Thu, 10 Jan 2008 02:06:19 +0000 (GMT)
Author: jstowers
Date: Thu Jan 10 02:06:19 2008
New Revision: 1176
URL: http://svn.gnome.org/viewvc/conduit?rev=1176&view=rev
Log:
Share some more file dp code and move vfs functions to utils
Modified:
trunk/ChangeLog
trunk/conduit/Database.py
trunk/conduit/Utils.py
trunk/conduit/modules/FileModule/FileConfiguration.py
trunk/conduit/modules/FileModule/FileModule.py
trunk/test/python-tests/TestSyncFolderFolder.py
trunk/test/python-tests/common.py
Modified: trunk/conduit/Database.py
==============================================================================
--- trunk/conduit/Database.py (original)
+++ trunk/conduit/Database.py Thu Jan 10 02:06:19 2008
@@ -186,7 +186,7 @@
return sql
def execute(self, sql, args=()):
- if GenericDB.DEBUG: log.debug(sql)
+ if self.DEBUG: log.debug(sql)
self.cur.execute(sql, args)
def select(self, sql, args=()):
@@ -319,7 +319,7 @@
self.db.close()
def execute(self, req, args=(), res=None, operation=""):
- if GenericDB.DEBUG: log.debug(req)
+ if self.DEBUG: log.debug(req)
if not self.stopped:
self.reqs.put((req, args, res, operation))
Modified: trunk/conduit/Utils.py
==============================================================================
--- trunk/conduit/Utils.py (original)
+++ trunk/conduit/Utils.py Thu Jan 10 02:06:19 2008
@@ -118,6 +118,19 @@
" "*len(ILLEGAL_CHARS)))
return uri
+def uri_is_folder(uri):
+ """
+ @returns: True if the uri is a folder and not a file
+ """
+ info = gnomevfs.get_file_info(uri)
+ return info.type == gnomevfs.FILE_TYPE_DIRECTORY
+
+def uri_format_for_display(uri):
+ """
+ Formats the uri so it can be displayed to the user (strips passwords, etc)
+ """
+ return gnomevfs.format_uri_for_display(uri)
+
#
# Temporary file functions
#
Modified: trunk/conduit/modules/FileModule/FileConfiguration.py
==============================================================================
--- trunk/conduit/modules/FileModule/FileConfiguration.py (original)
+++ trunk/conduit/modules/FileModule/FileConfiguration.py Thu Jan 10 02:06:19 2008
@@ -6,13 +6,7 @@
import conduit
import conduit.Utils as Utils
import conduit.gtkui.Database as Database
-try:
- import gnomevfs
-except:
- from gnome import gnomevfs
-
-TYPE_FILE = "0"
-TYPE_FOLDER = "1"
+import conduit.dataproviders.File as FileDataProvider
#Indexes of data in the list store
OID_IDX = 0
@@ -70,7 +64,7 @@
self.dlg.show_all()
#Now go an background scan some folders to populate the UI estimates.
- for oid,uri in self.db.select("SELECT oid,URI FROM config WHERE TYPE=? and SCAN_COMPLETE=?",(TYPE_FOLDER,False,)):
+ for oid,uri in self.db.select("SELECT oid,URI FROM config WHERE TYPE=? and SCAN_COMPLETE=?",(FileDataProvider.TYPE_FOLDER,False,)):
self.make_thread(
uri,
False,
@@ -83,8 +77,7 @@
for uri in selection.get_uris():
try:
log.debug("Drag recieved %s" % uri)
- info = gnomevfs.get_file_info(uri)
- if info.type == gnomevfs.FILE_TYPE_DIRECTORY:
+ if Utils.uri_is_folder(uri):
self._add_folder(uri)
else:
self._add_file(uri)
@@ -124,7 +117,7 @@
"""
path = self.model.get_path(rowref)
- if self.model[path][TYPE_IDX] == TYPE_FILE:
+ if self.model[path][TYPE_IDX] == FileDataProvider.TYPE_FILE:
icon = _FileSourceConfigurator.FILE_ICON
else:
icon = _FileSourceConfigurator.FOLDER_ICON
@@ -136,7 +129,7 @@
string if the model item is a File
"""
path = self.model.get_path(rowref)
- if self.model[path][TYPE_IDX] == TYPE_FILE:
+ if self.model[path][TYPE_IDX] == FileDataProvider.TYPE_FILE:
contains = ""
else:
contains = _("<i>Contains %s files</i>") % self.model[path][CONTAINS_NUM_ITEMS_IDX]
@@ -153,13 +146,13 @@
if self.model[path][GROUP_NAME_IDX] != "":
displayName = self.model[path][GROUP_NAME_IDX]
else:
- displayName = gnomevfs.format_uri_for_display(uri)
+ displayName = Utils.uri_format_for_display(uri)
cell_renderer.set_property("text", displayName)
cell_renderer.set_property("ellipsize", True)
#Can not edit the group name of a file
- if self.model[path][TYPE_IDX] == TYPE_FILE:
+ if self.model[path][TYPE_IDX] == FileDataProvider.TYPE_FILE:
cell_renderer.set_property("editable", False)
else:
cell_renderer.set_property("editable", True)
@@ -203,7 +196,7 @@
if folderURI not in self.scanThreads:
oid = self.db.insert(
table="config",
- values=(folderURI,TYPE_FOLDER,0,False,"")
+ values=(folderURI,FileDataProvider.TYPE_FOLDER,0,False,"")
)
self.make_thread(
folderURI,
@@ -216,7 +209,7 @@
def _add_file(self, uri):
self.db.insert(
table="config",
- values=(uri,TYPE_FILE,0,False,"")
+ values=(uri,FileDataProvider.TYPE_FILE,0,False,"")
)
def show_dialog(self):
@@ -290,7 +283,7 @@
"""
if response_id == gtk.RESPONSE_OK:
#check the user has specified a named group for all folders
- count, = self.db.select_one("SELECT COUNT(oid) FROM config WHERE TYPE=? and GROUP_NAME=?", (TYPE_FOLDER,""))
+ count, = self.db.select_one("SELECT COUNT(oid) FROM config WHERE TYPE=? and GROUP_NAME=?", (FileDataProvider.TYPE_FOLDER,""))
if count > 0:
#stop this dialog from closing, and show a warning to the
#user indicating that all folders must be named
Modified: trunk/conduit/modules/FileModule/FileModule.py
==============================================================================
--- trunk/conduit/modules/FileModule/FileModule.py (original)
+++ trunk/conduit/modules/FileModule/FileModule.py Thu Jan 10 02:06:19 2008
@@ -16,9 +16,6 @@
# "USBFactory" : { "type": "dataprovider-factory" }
}
-TYPE_FILE = "0"
-TYPE_FOLDER = "1"
-
class FileSource(FileDataProvider.FileSource):
_name_ = _("Files")
@@ -39,13 +36,12 @@
for f in config.get("folders",[]):
f,group = f.split("---FIXME---")
self._add_folder(f,group)
- self.db.debug(200,True)
def get_configuration(self):
files = []
folders = []
for uri,ftype,group in self.db.select("SELECT URI,TYPE,GROUP_NAME FROM config"):
- if ftype == TYPE_FILE:
+ if ftype == FileDataProvider.TYPE_FILE:
files.append(uri)
else:
folders.append("%s---FIXME---%s" % (uri,group))
Modified: trunk/test/python-tests/TestSyncFolderFolder.py
==============================================================================
--- trunk/test/python-tests/TestSyncFolderFolder.py (original)
+++ trunk/test/python-tests/TestSyncFolderFolder.py Thu Jan 10 02:06:19 2008
@@ -5,6 +5,7 @@
import conduit.datatypes.File as File
from conduit.datatypes import COMPARISON_EQUAL
+import os.path
import traceback
import random
import time
Modified: trunk/test/python-tests/common.py
==============================================================================
--- trunk/test/python-tests/common.py (original)
+++ trunk/test/python-tests/common.py Thu Jan 10 02:06:19 2008
@@ -369,6 +369,9 @@
def sync(self, debug=True):
#sync conduit
self.conduit.sync(block=True)
+
+ abort,error,conflict = self.get_sync_result()
+ ok("Sync completed (a:%d e:%d c:%d)" % (abort,error,conflict), True)
if debug:
print conduit.GLOBALS.mappingDB.debug()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]