Logo Search packages:      
Sourcecode: hellanzb version File versions  Download package

def Hellanzb::PostProcessor::PostProcessor::processMusic (   self  ) 

Assume the integrity of the files in the specified directory have been
verified. Iterate through the music files, and decompres them when appropriate in
multiple threads 

Definition at line 264 of file PostProcessor.py.

00264                           :
        """ Assume the integrity of the files in the specified directory have been
        verified. Iterate through the music files, and decompres them when appropriate in
        multiple threads """
        if not isFreshState(self.dirName, 'music'):
            info(archiveName(self.dirName) + ': Skipping music file decompression')
            return
        
        # Determine the music files to decompress
        self.musicFiles = []
        for file in os.listdir(self.dirName):
            absPath = os.path.join(self.dirName, file)
            if os.path.isfile(absPath) and getMusicType(file) and getMusicType(file).shouldDecompress():
                self.musicFiles.append(absPath)
    
        if len(self.musicFiles) == 0:
            return

        self.musicFiles.sort()

        threadCount = min(len(self.musicFiles), int(Hellanzb.MAX_DECOMPRESSION_THREADS))
        
        filesTxt = 'file'
        threadsTxt = 'thread'
        if len(self.musicFiles) != 1:
            filesTxt += 's'
        if threadCount != 1:
            threadsTxt += 's'

        fileCount = len(self.musicFiles)
        info(archiveName(self.dirName) + ': Decompressing ' + str(fileCount) + \
             ' ' + filesTxt + ' via ' + str(threadCount) + ' ' + threadsTxt + '..')

        # Failed decompress threads put their file names in this list
        self.failedToProcesses = []
        self.failedLock = Lock()

        start = time.time()
        # Maintain a pool of threads of the specified size until we've exhausted the
        # musicFiles list
        while len(self.musicFiles) > 0:
    
            # Block the pool until we're done spawning
            self.decompressorCondition.acquire()
            
            if len(self.decompressionThreadPool) < int(Hellanzb.MAX_DECOMPRESSION_THREADS):
                # will pop the next music file off the list
                decompressor = DecompressionThread(parent = self,         
                                                   dirName = self.dirName)
                decompressor.start()
    
            else:
                # Unblock and wait until we're notified of a thread's completition before
                # doing anything else
                self.decompressorCondition.wait()
                
            self.decompressorCondition.release()
            checkShutdown()

        # We're not finished until all the threads are done
        self.decompressorLock.acquire()
        decompressorThreads = self.decompressionThreadPool[:]
        self.decompressorLock.release()
        
        for decompressor in decompressorThreads:
            decompressor.join()

        del decompressorThreads
        checkShutdown()

        if len(self.failedToProcesses) > 0:
            raise FatalError('Failed to complete music decompression')

        processComplete(self.dirName, 'music', None)

        e = time.time() - start
        info('%s: Finished decompressing (%i %s, took: %s)' % (archiveName(self.dirName),
                                                               fileCount, filesTxt,
                                                               prettyElapsed(e)))

    def finishedPostProcess(self):


Generated by  Doxygen 1.6.0   Back to index