示例#1
0
    def startElement(self, name, attrs):
        if name == 'file':
            subject = self.parseUnicode(attrs.get('subject'))
            poster = self.parseUnicode(attrs.get('poster'))

            self.file = NZBFile(subject, attrs.get('date'), poster, self.nzb)
            self.segmentNumbers.clear()

            self.fileNeedsDownload = \
                self.file.needsDownload(workingDirListing = self.workingDirListing,
                                        workingDirDupeMap = self.workingDirDupeMap)

            # Special handling for par recovery downloads
            extraMsg = ''
            if Hellanzb.SMART_PAR and self.fileNeedsDownload and self.nzb.isParRecovery:
                if not self.nzb.isSkippedParSubject(subject):
                    # Only download previously marked pars
                    self.fileNeedsDownload = False
                    extraMsg = ' (not on disk but wasn\'t previously marked as an skippedParFile)'
                    self.file.nzb.firstSegmentsDownloaded += 1
                elif toUnicode(self.nzb.parPrefix) not in toUnicode(subject):
                    # Previously marked par -- only download it if it pertains to the
                    # particular par. We keep it set to needsDownload here so it gets to
                    # parseNZB -- parseNZB won't actually queue it
                    self.file.isSkippedPar = True
                    
            if not self.fileNeedsDownload:
                debug('SKIPPING FILE%s: %s subject: %s' % (extraMsg, self.file.getTempFileName(),
                                                           self.file.subject))

            self.fileCount += 1
            self.file.number = self.fileCount
            self.fileSegmentNumber = 1
                
        elif name == 'group':
            self.chars = []
                        
        elif name == 'segment':
            try:
                self.bytes = int(attrs.get('bytes'))
            except ValueError:
                self.bytes = 0
            try:
                self.number = int(attrs.get('number'))
            except ValueError:
                self.number = self.fileSegmentNumber
                        
            self.fileSegmentNumber += 1
            self.chars = []
示例#2
0
    def assertRecoveredSkippedPar(self, subject):
        n = NZB('test.nzb')
        n.isParRecovery = True
        n.parPrefix = 'test'
        n.parType = PAR2
        Hellanzb.queue.nzbAdd(n)

        file = NZBFile(subject, 'today', '*****@*****.**', n)
        file.isSkippedPar = True

        self.writeState()
        del n
        self.recoverState()

        n2 = NZB.fromStateXML('downloading', 'test')
        #print str(Hellanzb.recoveredState)
        #print str(n2.skippedParSubjects)
        self.assertEquals(True, n2.isSkippedParSubject(subject))