Пример #1
0
    def fetchBody(self, index):
        if Hellanzb.DEBUG_MODE_ENABLED:
            debug(str(self) + ' getting BODY: <' + self.currentSegment.messageId + \
                      '> ' + self.currentSegment.getDestination())

        Hellanzb.scroller.addClient(self.currentSegment, self.factory.color)
        NNTPClient.fetchBody(self, '<' + index + '>')
Пример #2
0
    def connectionLost(self, reason):
        debug(str(self) + ' CONNECTION LOST')
        self.setTimeout(None)
        # FIXME: could put failed segments into a failed queue. connections that are
        # flaged as being fill servers would try to attempt to d/l the failed files. you
        # couldn't write a 0 byte file to disk in that case -- not until all fill servers
        # had tried downloading

        # ReconnectingClientFactory will pretend it wants to reconnect after we CTRL-C --
        # we'll quiet it by canceling it
        if Hellanzb.SHUTDOWN:
            self.factory.stopTrying()

        if (not self.factory.activated or Hellanzb.downloadPaused) and \
                self.antiIdleTimeout == 0:
            debug(str(self) + ' CONNECTION LOST continueTrying=False')
            self.factory.continueTrying = False
            self.factory.idledOut = True

        NNTPClient.connectionLost(
            self)  # calls self.factory.clientConnectionLost(self, reason)

        if not Hellanzb.SHUTDOWN and self.currentSegment != None:
            if (self.currentSegment.priority, self.currentSegment, self.factory.color) in \
                    Hellanzb.scroller.segments:
                Hellanzb.scroller.removeClient(self.currentSegment,
                                               self.factory.color)

            # twisted doesn't reconnect our same client connections, we have to pitch
            # stuff back into the queue that hasn't finished before the connectionLost
            # occurred
            if self.currentSegment.nzbFile.nzb in Hellanzb.queue.currentNZBs() and \
                    not self.currentSegment.dontRequeue:
                # Only requeue the segment if its archive hasn't been previously postponed
                debug(
                    str(self) + ' requeueing segment: ' +
                    self.currentSegment.getDestination())
                Hellanzb.queue.requeue(self.factory, self.currentSegment)
            else:
                debug(str(self) + ' DID NOT requeue existing segment: ' + \
                          self.currentSegment.getDestination())
            self.resetCurrentSegment(removeEncFile=True)

        # Continue being quiet about things if we're shutting down. Don't bother plaguing
        # the log with typical disconnection reasons
        if not Hellanzb.SHUTDOWN and reason.type not in QUIET_CONNECTION_LOST_FAILURES:
            debug(str(self) + ' lost connection: ' + str(reason))

        self.activeGroups = []
        self.failedGroups = []
        self.gettingGroup = None
        self.factory.clients.remove(self)
        if self in self.factory.activeClients:
            self.factory.activeClients.remove(self)
        Hellanzb.scroller.size -= 1
        self.isLoggedIn = False
        self.setReaderAfterLogin = False
        self.factory.clientIds.insert(0, self.id)
        self.gotResponseCode = False
        self.lastChunk = ''
Пример #3
0
    def fetchBody(self, index):
        if Hellanzb.DEBUG_MODE_ENABLED:
            debug(str(self) + ' getting BODY: <' + self.currentSegment.messageId + \
                      '> ' + self.currentSegment.getDestination())

        Hellanzb.scroller.addClient(self.currentSegment, self.factory.color)
        NNTPClient.fetchBody(self, '<' + index + '>')
Пример #4
0
    def connectionLost(self, reason):
        debug(str(self) + ' CONNECTION LOST')
        self.setTimeout(None)
        # FIXME: could put failed segments into a failed queue. connections that are
        # flaged as being fill servers would try to attempt to d/l the failed files. you
        # couldn't write a 0 byte file to disk in that case -- not until all fill servers
        # had tried downloading
        
        # ReconnectingClientFactory will pretend it wants to reconnect after we CTRL-C --
        # we'll quiet it by canceling it
        if Hellanzb.SHUTDOWN:
            self.factory.stopTrying()

        if (not self.factory.activated or Hellanzb.downloadPaused) and \
                self.antiIdleTimeout == 0:
            debug(str(self) + ' CONNECTION LOST continueTrying=False')
            self.factory.continueTrying = False
            self.factory.idledOut = True

        NNTPClient.connectionLost(self) # calls self.factory.clientConnectionLost(self, reason)

        if not Hellanzb.SHUTDOWN and self.currentSegment != None:
            if (self.currentSegment.priority, self.currentSegment, self.factory.color) in \
                    Hellanzb.scroller.segments:
                Hellanzb.scroller.removeClient(self.currentSegment, self.factory.color)

            # twisted doesn't reconnect our same client connections, we have to pitch
            # stuff back into the queue that hasn't finished before the connectionLost
            # occurred
            if self.currentSegment.nzbFile.nzb in Hellanzb.queue.currentNZBs() and \
                    not self.currentSegment.dontRequeue:
                # Only requeue the segment if its archive hasn't been previously postponed
                debug(str(self) + ' requeueing segment: ' + self.currentSegment.getDestination())
                Hellanzb.queue.requeue(self.factory, self.currentSegment)
            else:
                debug(str(self) + ' DID NOT requeue existing segment: ' + \
                          self.currentSegment.getDestination())
            self.resetCurrentSegment(removeEncFile = True)
        
        # Continue being quiet about things if we're shutting down. Don't bother plaguing
        # the log with typical disconnection reasons
        if not Hellanzb.SHUTDOWN and reason.type not in QUIET_CONNECTION_LOST_FAILURES:
            debug(str(self) + ' lost connection: ' + str(reason))

        self.activeGroups = []
        self.failedGroups = []
        self.gettingGroup = None
        self.factory.clients.remove(self)
        if self in self.factory.activeClients:
            self.factory.activeClients.remove(self)
        Hellanzb.scroller.size -= 1
        self.isLoggedIn = False
        self.setReaderAfterLogin = False
        self.factory.clientIds.insert(0, self.id)
        self.gotResponseCode = False
        self.lastChunk = ''
Пример #5
0
    def connectionMade(self):
        debug(str(self) + ' CONNECTION MADE')
        NNTPClient.connectionMade(self)
        self.setTimeout(self.activeTimeout)

        # 'mode reader' is sometimes necessary to enable 'reader' mode.
        # However, the order in which 'mode reader' and 'authinfo' need to
        # arrive differs between some NNTP servers. Try to send
        # 'mode reader', and if it fails with an authorization failed
        # error, try again after sending authinfo.
        self.setReader()
Пример #6
0
    def connectionMade(self):
        debug(str(self) + ' CONNECTION MADE')
        NNTPClient.connectionMade(self)
        self.setTimeout(self.activeTimeout)

        # 'mode reader' is sometimes necessary to enable 'reader' mode.
        # However, the order in which 'mode reader' and 'authinfo' need to
        # arrive differs between some NNTP servers. Try to send
        # 'mode reader', and if it fails with an authorization failed
        # error, try again after sending authinfo.
        self.setReader()
Пример #7
0
    def __init__(self, username, password):
        """ """
        NNTPClient.__init__(self)
        self._endState()  # kill nntp's Passive state
        self._newState(self._statePassive, self._passiveError,
                       self._headerInitial)

        self.username = username
        self.password = password

        # successful GROUP commands during this session
        self.activeGroups = []
        # unsuccessful GROUP commands during this session
        self.failedGroups = []
        # group we're currently in the process of getting
        self.gettingGroup = None

        # current article (<segment>) we're dealing with
        self.currentSegment = None
        # function to write to the current segment
        self.write = None

        self.isLoggedIn = False
        self.setReaderAfterLogin = False

        self.activeTimeout = None
        # Idle time -- after being idle this long send anti idle requests
        self.antiIdleTimeout = None

        # whether or not this NZBLeecher is the in the fetchNextNZBSegment download loop
        self.activated = False

        # the connection is idle when it receives Empty()
        self.idle = False

        # Whether or not this client was created when hellanzb downloading was paused
        self.pauseReconnected = False

        # cache whether or not the response code has been received. only the BODY call
        # (dataReceivedToFile) utilizes this var
        self.gotResponseCode = False

        # hold the last chunk's final few bytes for when searching for the EOF char
        self.lastChunk = ''
Пример #8
0
    def __init__(self, username, password):
        """ """
        NNTPClient.__init__(self)
        self._endState() # kill nntp's Passive state
        self._newState(self._statePassive, self._passiveError, self._headerInitial)

        self.username = username
        self.password = password

        # successful GROUP commands during this session
        self.activeGroups = []
        # unsuccessful GROUP commands during this session
        self.failedGroups = []
        # group we're currently in the process of getting
        self.gettingGroup = None

        # current article (<segment>) we're dealing with
        self.currentSegment = None
        # function to write to the current segment
        self.write = None

        self.isLoggedIn = False
        self.setReaderAfterLogin = False
            
        self.activeTimeout = None
        # Idle time -- after being idle this long send anti idle requests
        self.antiIdleTimeout = None

        # whether or not this NZBLeecher is the in the fetchNextNZBSegment download loop
        self.activated = False

        # the connection is idle when it receives Empty()
        self.idle = False

        # Whether or not this client was created when hellanzb downloading was paused
        self.pauseReconnected = False

        # cache whether or not the response code has been received. only the BODY call
        # (dataReceivedToFile) utilizes this var
        self.gotResponseCode = False

        # hold the last chunk's final few bytes for when searching for the EOF char
        self.lastChunk = ''
Пример #9
0
 def fetchGroup(self, group):
     self.gettingGroup = group
     NNTPClient.fetchGroup(self, group)
Пример #10
0
 def fetchGroup(self, group):
     self.gettingGroup = group
     NNTPClient.fetchGroup(self, group)