Esempio n. 1
0
 def validFile(self, path ):
     fs = None
     try :
         fs = FileStat( path )
     except ( OSError ):
         return None
     
     if fs.isSoftLink():
         return None
     
     return fs
Esempio n. 2
0
    def testAddFromWeb(self):
        
        f = randomutils.RandomFileHere( 1024 )
        c =Checksum()
        checksum = c.blockComputeFile(f())
        statInfo = FileStat(f())
        
        payload =  { "host"     : socket.gethostname(),
                     "path"     : f(),
                     "filename" : os.path.basename(f()),
                     "size"     : statInfo.size(),
                     "ctime"    : statInfo.ctime(),
                     "atime"    : statInfo.atime(),
                     "mtime"    : statInfo.mtime(),
                     "isdir"    : statInfo.isdir(),
                     "checksum" : checksum }
                  
        self._fc.addFileFromWeb( payload )

        fRec = self._fc.getFileByPath( f())
        self.assertIsNotNone( fRec )
        self.assertEqual( os.path.getsize( f.name()), fRec[ 'size' ] )
        self.assertTrue( self._fc.inFilesCollection( f()))
        self.assertTrue( self._fc.isSameFile( FileStat( f.name()), fRec ))
        self.assertEqual( 1, self._fc.count())
        self.assertEqual(0, self._fc.duplicatesCount())
        f.rm()