Exemple #1
0
    def xmlrpc_process(self, archiveDir, rarPassword=None):
        """ Post process the specified directory. The -p option is preferable -- it will do this
        for you, or use the current process if this XML-RPC call fails """
        # FIXME: merge this with Daemon.postProcess
        if not os.path.isdir(archiveDir):
            raise Fault(
                9001,
                'Unable to process, not a directory: ' + toUnicode(archiveDir))

        if not os.access(archiveDir, os.R_OK) or not os.access(
                archiveDir, os.W_OK):
            raise Fault(9001, 'Unable to process, no read/write access to directory: ' + \
                        toUnicode(archiveDir))

        dirName = os.path.dirname(archiveDir.rstrip(os.sep))
        # We are the queue daemon -- Symlink to the archiveDir. If we are ctrl-ced, we'll
        # pick up the post processing afterward restart
        if os.path.normpath(dirName) != os.path.normpath(
                Hellanzb.PROCESSING_DIR):
            destDir = dupeName(
                os.path.join(Hellanzb.PROCESSING_DIR,
                             os.path.basename(archiveDir.rstrip(os.sep))))
            # UNIX: symlink, windows =[
            os.symlink(archiveDir, destDir)
            archiveDir = destDir

        archive = Archive(archiveDir, rarPassword=rarPassword)
        troll = PostProcessor(archive)
        troll.start()
        return self.xmlrpc_status()
Exemple #2
0
    def xmlrpc_process(self, archiveDir, rarPassword = None):
        """ Post process the specified directory. The -p option is preferable -- it will do this
        for you, or use the current process if this XML-RPC call fails """
        # FIXME: merge this with Daemon.postProcess
        if not os.path.isdir(archiveDir):
            raise Fault(9001, 'Unable to process, not a directory: ' + toUnicode(archiveDir))

        if not os.access(archiveDir, os.R_OK) or not os.access(archiveDir, os.W_OK):
            raise Fault(9001, 'Unable to process, no read/write access to directory: ' + \
                        toUnicode(archiveDir))
        
        dirName = os.path.dirname(archiveDir.rstrip(os.sep))
        # We are the queue daemon -- Symlink to the archiveDir. If we are ctrl-ced, we'll
        # pick up the post processing afterward restart
        if os.path.normpath(dirName) != os.path.normpath(Hellanzb.PROCESSING_DIR):
            destDir = dupeName(os.path.join(Hellanzb.PROCESSING_DIR,
                               os.path.basename(archiveDir.rstrip(os.sep))))
            # UNIX: symlink, windows =[
            os.symlink(archiveDir, destDir)
            archiveDir = destDir

        archive = Archive(archiveDir, rarPassword = rarPassword)
        troll = PostProcessor(archive)
        troll.start()
        return self.xmlrpc_status()
Exemple #3
0
    def testDupeName(self):
        """ Test the dupeName functionality. """ + dupeName.__doc__
        testFile = os.path.join(self.tempDir, 'file')
        testFile0 = os.path.join(self.tempDir, 'file_hellanzb_dupe0')
        testFile1 = os.path.join(self.tempDir, 'file_hellanzb_dupe1')
        testFile2 = os.path.join(self.tempDir, 'file_hellanzb_dupe2')
        
        self.assertEqual(dupeName(testFile), testFile)
        self.assertEqual(dupeName(testFile, eschewNames = (testFile)), testFile0)

        touch(testFile)
        touch(testFile0)

        self.assertEqual(dupeName(testFile), testFile1)
        self.assertEqual(dupeName(testFile, eschewNames = (testFile1)), testFile2)

        # checkOnDisk = False, minIteration = 0 should do nothing
        self.assertEqual(dupeName(testFile, checkOnDisk = False, minIteration = 0),
                         testFile)
Exemple #4
0
    def testDupeName(self):
        """ Test the dupeName functionality. """ + dupeName.__doc__
        testFile = os.path.join(self.tempDir, 'file')
        testFile0 = os.path.join(self.tempDir, 'file_hellanzb_dupe0')
        testFile1 = os.path.join(self.tempDir, 'file_hellanzb_dupe1')
        testFile2 = os.path.join(self.tempDir, 'file_hellanzb_dupe2')

        self.assertEqual(dupeName(testFile), testFile)
        self.assertEqual(dupeName(testFile, eschewNames=(testFile)), testFile0)

        touch(testFile)
        touch(testFile0)

        self.assertEqual(dupeName(testFile), testFile1)
        self.assertEqual(dupeName(testFile, eschewNames=(testFile1)),
                         testFile2)

        # checkOnDisk = False, minIteration = 0 should do nothing
        self.assertEqual(dupeName(testFile, checkOnDisk=False, minIteration=0),
                         testFile)
Exemple #5
0
def handleDupeNZBFile(nzbFile):
    """ Handle a duplicate NZBFile file on disk (prior to writing a new one), if one exists
    """
    dest = nzbFile.getDestination()
    # Ignore .nfo files -- newzbin.com dumps the .nfo file to the end of every nzb (if one
    # exists) -- so it's commonly a dupe. If it's already been downloaded (is an actual
    # fully assembled NZBFile on disk, not an NZBSegment), just overwrite it
    if validWorkingFile(dest, overwriteZeroByteFiles = 
                        nzbFile.nzb.overwriteZeroByteFiles) and \
                        getFileExtension(dest) != 'nfo':
        # Set a new dupeName -- avoid setting a dupeName that is on disk or in the
        # eschewNames (like above in handleDupeNZBSegment)
        dupeNZBFileName = dupeName(dest, eschewNames = knownRealNZBFilenames())
        
        info('Duplicate file, renaming: %s to %s' % (os.path.basename(dest),
                                                     os.path.basename(dupeNZBFileName)))
        debug('handleDupeNZBFile: renaming: %s to %s' % (os.path.basename(dest),
                                                        os.path.basename(dupeNZBFileName)))

        os.rename(dest, dupeNZBFileName)
Exemple #6
0
def handleDupeNZBFile(nzbFile):
    """ Handle a duplicate NZBFile file on disk (prior to writing a new one), if one exists
    """
    dest = nzbFile.getDestination()
    # Ignore .nfo files -- newzbin.com dumps the .nfo file to the end of every nzb (if one
    # exists) -- so it's commonly a dupe. If it's already been downloaded (is an actual
    # fully assembled NZBFile on disk, not an NZBSegment), just overwrite it
    if validWorkingFile(dest, overwriteZeroByteFiles =
                        nzbFile.nzb.overwriteZeroByteFiles) and \
                        getFileExtension(dest) != 'nfo':
        # Set a new dupeName -- avoid setting a dupeName that is on disk or in the
        # eschewNames (like above in handleDupeNZBSegment)
        dupeNZBFileName = dupeName(dest, eschewNames=knownRealNZBFilenames())

        info('Duplicate file, renaming: %s to %s' %
             (os.path.basename(dest), os.path.basename(dupeNZBFileName)))
        debug('handleDupeNZBFile: renaming: %s to %s' %
              (os.path.basename(dest), os.path.basename(dupeNZBFileName)))

        os.rename(dest, dupeNZBFileName)