Пример #1
0
 def updateBundles(self):
     dirsToBundle = self.__getDirsToBundle()
     #Delete bundles that don't have to be updated
     for bId in self.__bundles:
         if bId not in dirsToBundle:
             gLogger.info("Deleting old bundle %s" % bId)
             del (self.__bundles[bId])
     for bId in dirsToBundle:
         bundlePaths = dirsToBundle[bId]
         gLogger.info("Updating %s bundle %s" % (bId, bundlePaths))
         buffer_ = cStringIO.StringIO()
         filesToBundle = sorted(File.getGlobbedFiles(bundlePaths))
         if filesToBundle:
             commonPath = File.getCommonPath(filesToBundle)
             commonEnd = len(commonPath)
             gLogger.info("Bundle will have %s files with common path %s" %
                          (len(filesToBundle), commonPath))
             tarBuffer = tarfile.open('dummy', "w:gz", buffer_)
             for filePath in filesToBundle:
                 tarBuffer.add(filePath, filePath[commonEnd:])
             tarBuffer.close()
             zippedData = buffer_.getvalue()
             buffer_.close()
             hash_ = File.getMD5ForFiles(filesToBundle)
             gLogger.info("Bundled %s : %s bytes (%s)" %
                          (bId, len(zippedData), hash_))
             self.__bundles[bId] = (hash_, zippedData)
         else:
             self.__bundles[bId] = (None, None)
Пример #2
0
 def updateBundles( self ):
   dirsToBundle = self.__getDirsToBundle()
   #Delete bundles that don't have to be updated
   for bId in self.__bundles:
     if bId not in dirsToBundle:
       gLogger.info( "Deleting old bundle %s" % bId )
       del( self.__bundles[ bId ] )
   for bId in dirsToBundle:
     bundlePaths = dirsToBundle[ bId ]
     gLogger.info( "Updating %s bundle %s" % ( bId, bundlePaths ) )
     buffer_ = cStringIO.StringIO()
     filesToBundle = sorted( File.getGlobbedFiles( bundlePaths ) )
     if filesToBundle:
       commonPath = File.getCommonPath( filesToBundle )
       commonEnd = len( commonPath )
       gLogger.info( "Bundle will have %s files with common path %s" % ( len( filesToBundle ), commonPath ) )
       tarBuffer = tarfile.open( 'dummy', "w:gz", buffer_ )
       for filePath in filesToBundle:
         tarBuffer.add( filePath, filePath[ commonEnd: ] )
       tarBuffer.close()
       zippedData = buffer_.getvalue()
       buffer_.close()
       hash_ = File.getMD5ForFiles( filesToBundle )
       gLogger.info( "Bundled %s : %s bytes (%s)" % ( bId, len( zippedData ), hash_ ) )
       self.__bundles[ bId ] = ( hash_, zippedData )
     else:
       self.__bundles[ bId ] = ( None, None )