conduit r1682 - in trunk: . conduit conduit/datatypes conduit/platform scripts



Author: jstowers
Date: Fri Aug 29 23:35:17 2008
New Revision: 1682
URL: http://svn.gnome.org/viewvc/conduit?rev=1682&view=rev

Log:
	* conduit/Vfs.py:
	* conduit/datatypes/File.py:
	* conduit/platform/FileGnomeVfs.py:
	* conduit/platform/__init__.py: Move gnomevfs file code into the
	FileGnomeVfs platform implementation.
	* scripts/run-tests.sh:
	* conduit/conduit: Set PYTHONPATH to pick up gio libs (pygobject > 2.15)


Added:
   trunk/   (props changed)
      - copied from r1602, /trunk/
   trunk/conduit/platform/FileGnomeVfs.py
Modified:
   trunk/ChangeLog
   trunk/conduit/Vfs.py
   trunk/conduit/conduit
   trunk/conduit/datatypes/File.py
   trunk/conduit/platform/__init__.py
   trunk/scripts/run-tests.sh

Modified: trunk/conduit/Vfs.py
==============================================================================
--- /trunk/conduit/Vfs.py	(original)
+++ trunk/conduit/Vfs.py	Fri Aug 29 23:35:17 2008
@@ -9,7 +9,7 @@
     from gnome import gnomevfs
 
 import conduit.utils.Singleton as Singleton
-    
+
 #
 # URI Functions
 #

Modified: trunk/conduit/conduit
==============================================================================
--- /trunk/conduit/conduit	(original)
+++ trunk/conduit/conduit	Fri Aug 29 23:35:17 2008
@@ -8,6 +8,9 @@
 # Run mozilla takes care of settin up the appropriate environment variables
 # to run a program using mozilla libs
 
+export LD_LIBRARY_PATH=/opt/gio/lib/
+export PYTHONPATH=/opt/gio/lib/python2.5/site-packages/gtk-2.0/
+
 for d in `ls -d /usr/lib*/firefox* | sort -r`
 do
     if [ -x $d/run-mozilla.sh ]; then

Modified: trunk/conduit/datatypes/File.py
==============================================================================
--- /trunk/conduit/datatypes/File.py	(original)
+++ trunk/conduit/datatypes/File.py	Fri Aug 29 23:35:17 2008
@@ -5,15 +5,12 @@
 import logging
 log = logging.getLogger("datatypes.File")
 
-try:
-    import gnomevfs
-except ImportError:
-    from gnome import gnomevfs # for maemo
-
 import conduit
 import conduit.datatypes.DataType as DataType
 import conduit.Vfs as Vfs
 
+from conduit.platform.FileGnomeVfs import FileImpl, FileTransferImpl
+
 class FileTransferError(Exception):
     pass
 
@@ -32,33 +29,30 @@
           - group: A named group to which this file belongs
         """
         DataType.DataType.__init__(self)
-        #compulsory args
-        self.URI = gnomevfs.URI(URI)
+        self._file = FileImpl(URI)
 
         #optional args
         self.basePath = kwargs.get("basepath","")
         self.group = kwargs.get("group","")
 
         #instance
-        self.fileInfo = None
-        self.fileExists = False
-        self.triedOpen = False
         self._newFilename = None
         self._newMtime = None
 
         self._isProxyFile = False
         self._proxyFileSize = None
         
-    def _open_file(self):
-        if self.triedOpen == False:
-            self.triedOpen = True
-            self.fileExists = gnomevfs.exists(self.URI)
+#    def _open_file(self):
+#        if self.triedOpen == False:
+#            self.triedOpen = True
+#            self.fileExists = gnomevfs.exists(self.URI)
 
     def _close_file(self):
-        log.debug("Closing file")
-        self.fileInfo = None
-        self.fileExists = False
-        self.triedOpen = False
+        self._file.close()
+#        log.debug("Closing file")
+#        self.fileInfo = None
+#        self.fileExists = False
+#        self.triedOpen = False
 
         #check to see if we have applied the rename/mtimes yet
         if self.get_filename() == self._newFilename:
@@ -71,38 +65,34 @@
     def _xfer_check_global_cancel_flag(self):
         return conduit.GLOBALS.cancelled
 
-    def _xfer_progress_callback(self, info, cancel_func):
-        #check if cancelled
-        try:
-            if cancel_func():
-                log.info("Transfer of %s -> %s cancelled" % (info.source_name, info.target_name))
-                return 0
-        except Exception, ex:
-            log.warn("Could not call gnomevfs cancel function")
-            return 0
-        return True
+#    def _xfer_progress_callback(self, info, cancel_func):
+#        #check if cancelled
+#        try:
+#            if cancel_func():
+#                log.info("Transfer of %s -> %s cancelled" % (info.source_name, info.target_name))
+#                return 0
+#        except Exception, ex:
+#            log.warn("Could not call gnomevfs cancel function")
+#            return 0
+#        return True
 
     def _get_text_uri(self):
-        """
-        The mixing of text_uri and gnomevfs.URI in the gnomevfs api is very
-        annoying. This function returns the full text uri for the file
-        """
-        return str(self.URI)        
+        return self._file.get_text_uri()
             
-    def _get_file_info(self):
-        """
-        Gets the file info. Because gnomevfs is dumb this method works a lot
-        more reliably than self.vfsFileHandle.get_file_info().
-        
-        Only tries to get the info once for performance reasons
-        """
-        self._open_file()
-        #The get_file_info works more reliably on remote vfs shares
-        if self.fileInfo == None:
-            if self.exists() == True:
-                self.fileInfo = gnomevfs.get_file_info(self.URI, gnomevfs.FILE_INFO_DEFAULT)
-            else:
-                log.warn("Cannot get info on non-existant file %s" % self.URI)
+#    def _get_file_info(self):
+#        """
+#        Gets the file info. Because gnomevfs is dumb this method works a lot
+#        more reliably than self.vfsFileHandle.get_file_info().
+#        
+#        Only tries to get the info once for performance reasons
+#        """
+#        self._open_file()
+#        #The get_file_info works more reliably on remote vfs shares
+#        if self.fileInfo == None:
+#            if self.exists() == True:
+#                self.fileInfo = gnomevfs.get_file_info(self.URI, gnomevfs.FILE_INFO_DEFAULT)
+#            else:
+#                log.warn("Cannot get info on non-existant file %s" % self.URI)
 
     def _defer_rename(self, filename):
         """
@@ -128,7 +118,7 @@
         
     def _is_tempfile(self):
         tmpdir = tempfile.gettempdir()
-        if self.is_local() and self.URI.path.startswith(tmpdir):
+        if self._file.is_local() and self._file.get_path().startswith(tmpdir):
             return True
         else:
             return False
@@ -138,30 +128,25 @@
 
     def _set_file_mtime(self, mtime):
         timestamp = conduit.utils.datetime_get_timestamp(mtime)
-        log.debug("Setting mtime of %s to %s (%s)" % (self.URI, timestamp, type(timestamp)))
-        newInfo = gnomevfs.FileInfo()
-        newInfo.mtime = timestamp
-        gnomevfs.set_file_info(self.URI,newInfo,gnomevfs.SET_FILE_INFO_TIME)
-        #close so the file info is re-read
-        self._close_file()
+        log.debug("Setting mtime of %s to %s (%s)" % (
+                            self._file.get_text_uri(),
+                            timestamp,
+                            type(timestamp)))
+        return self._file.set_mtime(timestamp)
 
     def _set_filename(self, filename):
-        newInfo = gnomevfs.FileInfo()
-        
-        #FIXME: Gnomevfs complains if name is unicode
-        filename =  str(filename)
-        oldname =   str(self.get_filename())
-
-        if filename != oldname:
-            newInfo.name = filename
-            olduri = self._get_text_uri()
-            newuri = olduri.replace(oldname, filename)
-
-            log.debug("Trying to rename file %s (%s) -> %s (%s)" % (olduri,oldname,newuri,filename))
-            gnomevfs.set_file_info(self.URI,newInfo,gnomevfs.SET_FILE_INFO_NAME)
-            #close so the file info is re-read
-            self.URI = gnomevfs.URI(newuri)
-            self._close_file()
+        oldname = self._file.get_filename()
+        olduri = self._file.get_text_uri()
+        #ignore unicode for equality
+        if str(filename) != str(oldname):
+            newuri = self._file.set_filename(filename)
+            if newuri:
+                log.debug("Rename file %s (%s) -> %s (%s)" % (olduri,oldname,newuri,filename))
+            else:
+                log.debug("Error renaming file %s (%s) -> %s" % (olduri,oldname,filename))
+            return newuri
+        else:
+            return olduri
             
     def set_from_instance(self, f):
         """
@@ -170,12 +155,9 @@
         might be pending renames etc on the file that you
         do not want to lose
         """
-        self.URI = f.URI
+        self._file = f._file
         self.basePath = f.basePath
         self.group = f.group
-        self.fileInfo = f.fileInfo
-        self.fileExists = f.fileExists
-        self.triedOpen = f.triedOpen
         self._newFilename = f._newFilename
         self._newMtime = f._newMtime
         self._isProxyFile = f._isProxyFile
@@ -188,7 +170,7 @@
         """
         #Get a temporary file name
         tempname = tempfile.mkstemp(prefix="conduit")[1]
-        log.debug("Tempfile %s -> %s" % (self.URI, tempname))
+        log.debug("Tempfile %s -> %s" % (self._get_text_uri(), tempname))
         filename = self.get_filename()
         mtime = self.get_mtime()
         self.transfer(
@@ -201,8 +183,10 @@
         return tempname
 
     def exists(self):
-        self._open_file()
-        return self.fileExists
+        """
+        Checks the file exists
+        """        
+        return self._file.exists()
 
     def is_local(self):
         """
@@ -210,14 +194,13 @@
         expected that the caller will call get_local_uri, which will
         copy the file to that location, and return the new path
         """
-        return self.URI.is_local
+        return self._file.is_local()
 
     def is_directory(self):
         """
         @returns: True if the File is a directory
         """
-        self._get_file_info()
-        return self.fileInfo.type == gnomevfs.FILE_TYPE_DIRECTORY
+        return self._file.is_directory()
 
     def force_new_filename(self, filename):
         """
@@ -226,20 +209,8 @@
         if self._is_tempfile() or self._is_proxyfile():
             self._defer_rename(filename)
         else:
-            try:
-                self._set_filename(filename)
-            except gnomevfs.NotSupportedError:
-                #dunno what this is
-                self._defer_rename(filename)
-            except gnomevfs.AccessDeniedError:
-                #file is on readonly filesystem
+            if not self._set_filename(filename):
                 self._defer_rename(filename)
-            except gnomevfs.NotPermittedError:
-                #file is on readonly filesystem
-                self._defer_rename(filename)
-            except gnomevfs.FileExistsError:
-                #I think this is when you rename a file to its current name
-                pass
                 
     def force_new_file_extension(self, ext):
         """
@@ -257,71 +228,36 @@
         if self._is_tempfile() or self._is_proxyfile():
             self._defer_new_mtime(mtime)
         else:
-            try:
-                self._set_file_mtime(mtime)
-            except gnomevfs.NotSupportedError:
-                #dunno what this is
-                self._defer_new_mtime(mtime)
-            except gnomevfs.AccessDeniedError:
-                #file is on readonly filesystem
-                self._defer_new_mtime(mtime)
-            except gnomevfs.NotPermittedError:
-                #file is on readonly filesystem
+            if not self._set_file_mtime(mtime):
                 self._defer_new_mtime(mtime)
 
     def transfer(self, newURIString, overwrite=False, cancel_function=None):
         """
-        Transfers the file to newURI. Thin wrapper around go_gnomevfs_transfer
-        because it also sets the new info of the file. By wrapping the xfer_uri
-        funtion it gives the ability to cancel transfers
+        Transfers the file to newURI. Returning True from 
+        cancel_function gives the ability to cancel transfers
 
         @type newURIString: C{string}
         """
+        trans = FileTransferImpl(
+                        source=self._file,
+                        dest=newURIString)
+        
         #the default cancel function just checks conduit.GLOBALS.cancelled
         if cancel_function == None:
             cancel_function = self._xfer_check_global_cancel_flag
 
         if self._is_deferred_rename():
-            newURI = gnomevfs.URI(newURIString)
-            #if it exists and its a directory then transfer into that dir
-            #with the new filename
-            if gnomevfs.exists(newURI):
-                info = gnomevfs.get_file_info(newURI, gnomevfs.FILE_INFO_DEFAULT)
-                if info.type == gnomevfs.FILE_TYPE_DIRECTORY:
-                    #append the new filename
-                    newURI = newURI.append_file_name(self._newFilename)
-                    log.debug("Using deferred filename in transfer")
-        else:
-            newURI = gnomevfs.URI(newURIString)
-            
-        if overwrite:
-            mode = gnomevfs.XFER_OVERWRITE_MODE_REPLACE
-        else:
-            mode = gnomevfs.XFER_OVERWRITE_MODE_SKIP
-        
-        log.debug("Transfering File %s -> %s" % (self.URI, newURI))
+            log.debug("Using deferred filename in transfer")
+            trans.set_destination_filename(self._newFilename)
 
-        #recursively create all parent dirs if needed
-        parent = str(newURI.parent)
-        if not gnomevfs.exists(parent):
-            Vfs.uri_make_directory_and_parents(parent)
-
-        #Copy the file
-        try:        
-            result = gnomevfs.xfer_uri(
-                        source_uri=self.URI,
-                        target_uri=newURI,
-                        xfer_options=gnomevfs.XFER_NEW_UNIQUE_DIRECTORY,
-                        error_mode=gnomevfs.XFER_ERROR_MODE_ABORT,
-                        overwrite_mode=mode,
-                        progress_callback=self._xfer_progress_callback,
-                        data=cancel_function
-                        )
-        except gnomevfs.InterruptedError:
-            raise FileTransferError
+        #transfer file
+        ok,f = trans.transfer(overwrite, cancel_function)
+        
+        #if not ok:
+        #    raise FileTransferError
 
         #close the file and the handle so that the file info is refreshed
-        self.URI = newURI
+        self._file = f
         self._close_file()
         
         #if we have been transferred anywhere (i.e. the destination, our
@@ -335,18 +271,17 @@
             self.force_new_mtime(self._newMtime)
       
     def delete(self):
-        #close the file and the handle so that the file info is refreshed
-        self._close_file()
-        log.debug("Deleting %s" % self.URI)
-        result = gnomevfs.unlink(self.URI)
+        """
+        Deletes the file
+        """
+        log.debug("Deleting %s" % self._file.get_text_uri())
+        self._file.delete()
 
     def get_mimetype(self):
-        self._get_file_info()
-        try:
-            return self.fileInfo.mime_type
-        except ValueError:
-            #Why is gnomevfs so stupid and must I do this for local URIs??
-            return gnomevfs.get_mime_type(self._get_text_uri())
+        """
+        @returns: The file mimetype
+        """
+        return self._file.get_mimetype()
         
     def get_mtime(self):
         """
@@ -359,10 +294,10 @@
         if self._is_deferred_new_mtime():
             return self._newMtime
         else:
-            self._get_file_info()
-            try:
-                return datetime.datetime.fromtimestamp(self.fileInfo.mtime)
-            except:
+            ts = self._file.get_mtime()
+            if ts:
+                return datetime.datetime.fromtimestamp(ts)
+            else:
                 return None
 
     def set_mtime(self, mtime):
@@ -370,10 +305,7 @@
         Sets the modification time of the file
         """
         if mtime != None:
-            try:
-                self.force_new_mtime(mtime)
-            except Exception, err:
-                log.warn("Error setting mtime of %s. \n%s" % (self.URI, traceback.format_exc()))
+            self.force_new_mtime(mtime)
     
     def get_size(self):
         """
@@ -382,11 +314,7 @@
         if self._is_proxyfile():
             return self._proxyFileSize
         else:
-            self._get_file_info()
-            try:
-                return self.fileInfo.size
-            except:
-                return None
+            return self._file.get_size()
 
     def get_hash(self):
         # Join the tags into a string to be hashed so the object is updated if
@@ -402,8 +330,7 @@
         if self._is_deferred_rename():
             return self._newFilename
         else:
-            self._get_file_info()
-            return self.fileInfo.name
+            return self._file.get_filename()
 
     def get_filename_and_extension(self):
         """
@@ -412,7 +339,7 @@
         return os.path.splitext(self.get_filename())
 
     def get_contents_as_text(self):
-        return gnomevfs.read_entire_file(self._get_text_uri())
+        return self._file.contents()
         
     def get_local_uri(self):
         """
@@ -422,18 +349,16 @@
         
         If it is a remote file then a local temporary file copy is created
         
-        This function is useful for non gnomevfs enabled libs
-
         @returns: local absolute path the the file or None on error
         @rtype: C{string}
         """
         if self.is_local():
             #FIXME: The following call produces a runtime error if the URI
             #is malformed. Reason number 37 gnomevfs should die
-            u = gnomevfs.get_local_path_from_uri(self._get_text_uri())
+            #u = gnomevfs.get_local_path_from_uri(self._get_text_uri())
             #Backup approach...
             #u = self.URI[len("file://"):]
-            return u
+            return self._file.get_path()
         else:
             return self.to_tempfile()
             
@@ -451,14 +376,14 @@
         Compare me with B based upon their modification times, or optionally
         based on size only
         """
-        if gnomevfs.exists(B.URI) == False:
+        if B.exists() == False:
             return conduit.datatypes.COMPARISON_NEWER
 
         #Compare based on size only?
         if sizeOnly:
             meSize = self.get_size()
             bSize = B.get_size()
-            log.debug("Comparing %s (SIZE: %s) with %s (SIZE: %s)" % (self.URI, meSize, B.URI, bSize))
+            log.debug("Comparing %s (SIZE: %s) with %s (SIZE: %s)" % (self._get_text_uri(), meSize, B._get_text_uri(), bSize))
             if meSize == None or bSize == None:
                 return conduit.datatypes.COMPARISON_UNKNOWN
             elif meSize == bSize:
@@ -469,7 +394,7 @@
         #Else look at the modification times
         meTime = self.get_mtime()
         bTime = B.get_mtime()
-        log.debug("Comparing %s (MTIME: %s) with %s (MTIME: %s)" % (self.URI, meTime, B.URI, bTime))
+        log.debug("Comparing %s (MTIME: %s) with %s (MTIME: %s)" % (self._get_text_uri(), meTime, B._get_text_uri(), bTime))
         if meTime is None:
             return conduit.datatypes.COMPARISON_UNKNOWN
         if bTime is None:            
@@ -519,16 +444,16 @@
         os.write(fd, data['data'])
         os.close(fd)
         
-        self.URI = gnomevfs.URI(name)
+        self._file = FileImpl(name)
         self.basePath = data['basePath']
         self.group = data['group']
         self._defer_rename(data['filename'])
         self._defer_new_mtime(data['filemtime'])
 
         #Ensure we re-read the fileInfo
-        self.fileInfo = None
-        self.fileExists = False
-        self.triedOpen = False
+        #self.fileInfo = None
+        #self.fileExists = False
+        #self.triedOpen = False
         
         DataType.DataType.__setstate__(self, data)
 

Added: trunk/conduit/platform/FileGnomeVfs.py
==============================================================================
--- (empty file)
+++ trunk/conduit/platform/FileGnomeVfs.py	Fri Aug 29 23:35:17 2008
@@ -0,0 +1,203 @@
+try:
+    import gnomevfs
+except ImportError:
+    from gnome import gnomevfs # for maemo
+
+import conduit.Vfs as Vfs
+import conduit.platform
+
+import logging
+log = logging.getLogger("Settings")
+
+class FileImpl(conduit.platform.File):
+    SCHEMES = ("file://","http://","ftp://","smb://";)
+    def __init__(self, URI):
+        self._URI = gnomevfs.URI(URI)
+        self.close()
+
+    def _open_file(self):
+        if not self.triedOpen:
+            self.triedOpen = True
+            self.fileExists = gnomevfs.exists(self._URI)
+            
+    def _get_file_info(self):
+        self._open_file()
+        #get_file_info works more reliably on remote vfs shares
+        #than self.vfsFileHandle.get_file_info().
+        if self.fileInfo == None:
+            if self.exists():
+                self.fileInfo = gnomevfs.get_file_info(self._URI, gnomevfs.FILE_INFO_DEFAULT)
+
+    def get_text_uri(self):
+        return str(self._URI)
+        
+    def get_path(self):
+        return self._URI.path
+        
+    def is_local(self):
+        return self._URI.is_local
+        
+    def is_directory(self):
+        self._get_file_info()
+        return self.fileInfo.type == gnomevfs.FILE_TYPE_DIRECTORY
+        
+    def delete(self):
+        #close the file and the handle so that the file info is refreshed
+        self.close()
+        result = gnomevfs.unlink(self._URI)
+        
+    def exists(self):
+        self._open_file()
+        return self.fileExists
+        
+    def set_mtime(self, timestamp=None, datetime=None):
+        newInfo = gnomevfs.FileInfo()
+        newInfo.mtime = timestamp
+        
+        try:
+            gnomevfs.set_file_info(self._URI,newInfo,gnomevfs.SET_FILE_INFO_TIME)
+            self.close()
+            return timestamp
+        except gnomevfs.NotSupportedError:
+            #dunno what this is
+            return None
+        except gnomevfs.AccessDeniedError:
+            #file is on readonly filesystem
+            return None
+        except gnomevfs.NotPermittedError:
+            #file is on readonly filesystem
+            return None
+        
+    def set_filename(self, filename):
+        #gnomevfs doesnt seem to like unicode filenames
+        filename = str(filename)
+        oldname = str(self.get_filename())
+    
+        newInfo = gnomevfs.FileInfo()
+        newInfo.name = filename
+        
+        olduri = self.get_text_uri()
+        newuri = olduri.replace(oldname, filename)
+
+        try:
+            gnomevfs.set_file_info(self._URI,newInfo,gnomevfs.SET_FILE_INFO_NAME)
+            #close so the file info is re-read
+            self._URI = gnomevfs.URI(newuri)
+            self.close()
+        except gnomevfs.NotSupportedError:
+            #dunno what this is
+            return None
+        except gnomevfs.AccessDeniedError:
+            #file is on readonly filesystem
+            return None
+        except gnomevfs.NotPermittedError:
+            #file is on readonly filesystem
+            return None
+        except gnomevfs.FileExistsError:
+            #I think this is when you rename a file to its current name
+            pass
+
+        return newuri
+        
+    def get_mtime(self):
+        self._get_file_info()
+        try:
+            return self.fileInfo.mtime
+        except:
+            return None
+
+    def get_filename(self):
+        self._get_file_info()
+        return self.fileInfo.name
+        
+    def get_contents(self):
+        return gnomevfs.read_entire_file(self.get_text_uri())
+        
+    def get_mimetype(self):
+        self._get_file_info()
+        try:
+            return self.fileInfo.mime_type
+        except ValueError:
+            #Why is gnomevfs so stupid and must I do this for local URIs??
+            return gnomevfs.get_mime_type(self.get_text_uri())
+
+    def get_size(self):
+        self._get_file_info()
+        try:
+            return self.fileInfo.size
+        except:
+            return None
+
+    def set_props(self, **props):
+        raise NotImplementedError
+        
+    def close(self):
+        self.fileInfo = None
+        self.fileExists = False
+        self.triedOpen = False
+
+class FileTransferImpl(conduit.platform.FileTransfer):
+    def __init__(self, source, dest):
+        self._source = source._URI
+        self._dest = gnomevfs.URI(dest)
+        self._cancel_func = lambda : False
+        
+    def _xfer_progress_callback(self, info):
+        #check if cancelled
+        try:
+            if self._cancel_func():
+                log.info("Transfer of %s -> %s cancelled" % (info.source_name, info.target_name))
+                return 0
+        except Exception, ex:
+            log.warn("Could not call gnomevfs cancel function")
+            return 0
+        return True
+        
+    def set_destination_filename(self, name):
+        #if it exists and its a directory then transfer into that dir
+        #with the new filename
+        if gnomevfs.exists(self._dest):
+            info = gnomevfs.get_file_info(self._dest, gnomevfs.FILE_INFO_DEFAULT)
+            if info.type == gnomevfs.FILE_TYPE_DIRECTORY:
+                #append the new filename
+                self._dest = self._dest.append_file_name(name)
+        
+    def transfer(self, overwrite, cancel_func):
+        self._cancel_func = cancel_func
+    
+        if overwrite:
+            mode = gnomevfs.XFER_OVERWRITE_MODE_REPLACE
+        else:
+            mode = gnomevfs.XFER_OVERWRITE_MODE_SKIP
+
+        log.debug("Transfering File %s -> %s" % (self._source, self._dest))
+
+        #recursively create all parent dirs if needed
+        parent = str(self._dest.parent)
+        if not gnomevfs.exists(parent):
+            Vfs.uri_make_directory_and_parents(parent)
+
+        #Copy the file
+        try:        
+            result = gnomevfs.xfer_uri(
+                        source_uri=self._source,
+                        target_uri=self._dest,
+                        xfer_options=gnomevfs.XFER_NEW_UNIQUE_DIRECTORY,
+                        error_mode=gnomevfs.XFER_ERROR_MODE_ABORT,
+                        overwrite_mode=mode,
+                        progress_callback=self._xfer_progress_callback
+                        )
+            #FIXME: Check error
+            return True, FileImpl(str(self._dest))
+        except gnomevfs.InterruptedError:
+            return False, None
+        except Exception, e:
+            log.warn("File transfer error: %s" % e)
+            return False, None
+    
+    
+    
+
+
+            
+

Modified: trunk/conduit/platform/__init__.py
==============================================================================
--- /trunk/conduit/platform/__init__.py	(original)
+++ trunk/conduit/platform/__init__.py	Fri Aug 29 23:35:17 2008
@@ -1,5 +1,65 @@
 import gobject
 
+class File:
+
+    def __init__(self, URI):
+        pass
+        
+    def get_text_uri(self):
+        raise NotImplementedError
+        
+    def get_path(self):
+        raise NotImplementedError
+        
+    def is_local(self):
+        raise NotImplementedError
+        
+    def is_directory(self):
+        raise NotImplementedError
+        
+    def delete(self):
+        raise NotImplementedError
+        
+    def exists(self):
+        raise NotImplementedError
+        
+    def set_mtime(self, timestamp=None, datetime=None):
+        raise NotImplementedError        
+        
+    def set_filename(self, filename):
+        raise NotImplementedError
+        
+    def get_mtime(self):
+        raise NotImplementedError
+
+    def get_filename(self):
+        raise NotImplementedError
+        
+    def get_contents(self):
+        raise NotImplementedError
+
+    def get_mimetype(self):
+        raise NotImplementedError
+        
+    def get_size(self):
+        raise NotImplementedError
+
+    def set_props(self, **props):
+        raise NotImplementedError
+        
+    def close(self):
+        raise NotImplementedError
+        
+class FileTransfer:
+    def __init__(self, source, dest):
+        pass
+        
+    def set_destination_filename(self, name):
+        raise NotImplementedError
+        
+    def transfer(self, cancel_func):
+        raise NotImplementedError
+
 class Settings:
 
     def __init__(self, defaults, changedCb):

Modified: trunk/scripts/run-tests.sh
==============================================================================
--- /trunk/scripts/run-tests.sh	(original)
+++ trunk/scripts/run-tests.sh	Fri Aug 29 23:35:17 2008
@@ -9,6 +9,9 @@
 COVERAGE_APP="scripts/coverage.py"
 COVERAGE_RESULTS="$BASEDIR/results/coverage"
 
+export LD_LIBRARY_PATH=/opt/gio/lib/
+export PYTHONPATH=/opt/gio/lib/python2.5/site-packages/gtk-2.0/
+
 USAGE="\
 Usage:\n\
 ./scripts/run-tests.sh [OPTIONS]\n\n\



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]