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

def Hellanzb::PostProcessor::PostProcessor::finishedPostProcess (   self  ) 

finish the post processing work 

Definition at line 344 of file PostProcessor.py.

00344                                  :
        """ finish the post processing work """

        # Move other cruft out of the way
        if self.nzbFile is not None:
            if os.path.isfile(os.path.join(self.dirName, self.nzbFile)) and \
                    os.access(os.path.join(self.dirName, self.nzbFile), os.R_OK):
                move(os.path.join(self.dirName, self.nzbFile),
                     os.path.join(self.dirName, Hellanzb.PROCESSED_SUBDIR, self.nzbFile))

        # Move out anything else that's broken, a dupe or tagged as
        # not required
        for file in self.brokenFiles:
            if os.path.isfile(os.path.join(self.dirName, file)):
                move(os.path.join(self.dirName, file),
                     os.path.join(self.dirName, Hellanzb.PROCESSED_SUBDIR, file))

        for file in os.listdir(self.dirName):
            ext = getFileExtension(file)
            if ext is not None and len(ext) > 0 and \
                    ext.lower() not in Hellanzb.KEEP_FILE_TYPES and \
                   ext.lower() in Hellanzb.NOT_REQUIRED_FILE_TYPES:
                move(os.path.join(self.dirName, file),
                     os.path.join(self.dirName, Hellanzb.PROCESSED_SUBDIR, file))
            elif re.match(r'.*_duplicate\d{0,4}', file):
                move(os.path.join(self.dirName, file),
                     os.path.join(self.dirName, Hellanzb.PROCESSED_SUBDIR, file))

        handledPars = False
        if os.path.isfile(os.path.join(self.dirName, Hellanzb.PROCESSED_SUBDIR, '.par_done')):
            handledPars = True
        # Finally, nuke the processed dir. Hopefully the PostProcessor did its job and
        # there was absolutely no need for any of the files in the processed dir,
        # otherwise tough! (otherwise disable the option and redownload again)
        deleteDir = os.path.join(self.dirName, Hellanzb.PROCESSED_SUBDIR)
        deletedFiles = walk(deleteDir, 1, return_folders = 1)
        deletedFiles = [fileName.replace(deleteDir + os.sep, '') for fileName in deletedFiles]

        if hasattr(Hellanzb, 'DELETE_PROCESSED') and Hellanzb.DELETE_PROCESSED:
            msg = 'Deleting processed dir: ' + \
                os.path.join(archiveName(self.dirName), Hellanzb.PROCESSED_SUBDIR) + \
                ', it contains: ' + str(deletedFiles) + '\n'
            if len(deletedFiles):
            rmtree(os.path.join(self.dirName, Hellanzb.PROCESSED_SUBDIR))

        # Finished. Move dirName to DEST_DIR if we need to
        # We're done
        e = time.time() - self.startTime 
        if not self.isSubDir:
            parMessage = ''
            if not handledPars:
                parMessage = ' (No Pars)'
            archive = archiveName(self.dirName)
            info('%s: Finished processing (took: %s)%s' % (archive,
                                                           prettyElapsed(e), parMessage))
            dispatchExternalHandler(SUCCESS, archiveName=archive,
                                    destDir=os.path.join(Hellanzb.DEST_DIR, archive),

            if parMessage != '':
                parMessage = '\n' + parMessage
            growlNotify('Archive Success', 'hellanzb Done Processing' + parMessage + ':',
                        archive, True)
        # FIXME: could unsticky the message if we're running hellanzb.py -p
        # and preferably if the post processing took say over 30 seconds

    def postProcess(self):

Generated by  Doxygen 1.6.0   Back to index