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

def Hellanzb::NZBLeecher::NZBLeecher::fetchNextNZBSegment (   self  ) 

Pop nzb article from the queue, and attempt to retrieve it if it hasn't already been
retrieved

Definition at line 445 of file __init__.py.

00445                                  :
        """ Pop nzb article from the queue, and attempt to retrieve it if it hasn't already been
        retrieved"""
        if self.currentSegment is None:

            try:
                priority, self.currentSegment = \
                    Hellanzb.queue.getSmart(self.factory.serverPoolName)
                self.currentSegment.encodedData = \
                    open(os.path.join(Hellanzb.DOWNLOAD_TEMP_DIR,
                                      self.currentSegment.getTempFileName() + '_ENC'),
                         'w')
                debug(str(self) + ' PULLED FROM QUEUE: ' + self.currentSegment.getDestination())

                # got a segment - set ourselves as active unless we're already set as so
                self.activate()

                # Determine the filename to show in the UI
                if self.currentSegment.nzbFile.showFilename == None:
                    if self.currentSegment.nzbFile.filename == None:
                        self.currentSegment.nzbFile.showFilenameIsTemp = True
                        
                    self.currentSegment.nzbFile.showFilename = self.currentSegment.nzbFile.getFilename()

            except EmptyForThisPool:
                debug(str(self) + ' EMPTY QUEUE (for just this pool)')
                # done for this download pool
                self.deactivate(justThisDownloadPool = True)
                return
            
            except Empty:
                debug(str(self) + ' EMPTY QUEUE')
                # all done
                self.deactivate()
                return

        if not self.factory.skipGroupCmd:
            # Change group
            for group in self.currentSegment.nzbFile.groups:

                # NOTE: we could get away with activating only one of the groups instead
                # of all
                if group not in self.activeGroups and group not in self.failedGroups:
                    debug(str(self) + ' getting GROUP: ' + group)
                    self.fetchGroup(group)
                    return

                # We only need to get the groups once during the lifetime of this
                # NZBLeecher. Once we've ensured all groups have been attempted to be
                # retrieved (the above block of code), check that we haven't failed
                # finding all groups (if so, punt) here instead of getGroupFailed
                elif self.allGroupsFailed(self.currentSegment.nzbFile.groups):
                    try:
                        Hellanzb.queue.requeueMissing(self.factory.serverPoolName,
                                                      self.currentSegment)
                        debug(str(self) + \
                              ' All groups failed, requeueing to another pool!')
                        self.resetCurrentSegment(removeEncFile = True)
                        reactor.callLater(0, self.fetchNextNZBSegment)

                    except PoolsExhausted:
                        error('Unable to retrieve *any* groups for file (subject: ' + \
                              self.currentSegment.nzbFile.subject + ')')
                        msg = 'Groups:'
                        for group in self.currentSegment.nzbFile.groups:
                            msg += ' ' + group
                        error(msg)
                        error('Cancelling NZB download: ' + \
                              self.currentSegment.nzbFile.nzb.archiveName)

                        # cancelCurrent will deactivate, kill the connections (and
                        # connectionLost will take care of closing file handles etc)
                        cancelCurrent()

                    return
            
        # Don't call later here -- we could be disconnected and lose our currentSegment
        # before it even happens!
        #reactor.callLater(0, self.fetchBody, str(self.currentSegment.messageId))
        self.fetchBody(str(self.currentSegment.messageId))

    def fetchGroup(self, group):


Generated by  Doxygen 1.6.0   Back to index