https://t.me/RX1948
Server : Apache/2.4.18 (Ubuntu)
System : Linux canvaswebdesign 3.13.0-71-generic #114-Ubuntu SMP Tue Dec 1 02:34:22 UTC 2015 x86_64
User : oppastar ( 1041)
PHP Version : 7.0.33-0ubuntu0.16.04.15
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
Directory :  /usr/lib/python2.7/dist-packages/twisted/news/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //usr/lib/python2.7/dist-packages/twisted/news/news.py
# Copyright (c) Twisted Matrix Laboratories.
# See LICENSE for details.


"""
Maintainer: Jp Calderone
"""

from twisted.news import nntp
from twisted.internet import protocol, reactor

import time

class NNTPFactory(protocol.ServerFactory):
    """A factory for NNTP server protocols."""
    
    protocol = nntp.NNTPServer
    
    def __init__(self, backend):
        self.backend = backend
    
    def buildProtocol(self, connection):
        p = self.protocol()
        p.factory = self
        return p


class UsenetClientFactory(protocol.ClientFactory):
    def __init__(self, groups, storage):
        self.lastChecks = {}
        self.groups = groups
        self.storage = storage


    def clientConnectionLost(self, connector, reason):
        pass


    def clientConnectionFailed(self, connector, reason):
        print 'Connection failed: ', reason
    
    
    def updateChecks(self, addr):
        self.lastChecks[addr] = time.mktime(time.gmtime())


    def buildProtocol(self, addr):
        last = self.lastChecks.setdefault(addr, time.mktime(time.gmtime()) - (60 * 60 * 24 * 7))
        p = nntp.UsenetClientProtocol(self.groups, last, self.storage)
        p.factory = self
        return p


# XXX - Maybe this inheritance doesn't make so much sense?
class UsenetServerFactory(NNTPFactory):
    """A factory for NNTP Usenet server protocols."""

    protocol = nntp.NNTPServer

    def __init__(self, backend, remoteHosts = None, updatePeriod = 60):
        NNTPFactory.__init__(self, backend)
        self.updatePeriod = updatePeriod
        self.remoteHosts = remoteHosts or []
        self.clientFactory = UsenetClientFactory(self.remoteHosts, self.backend)


    def startFactory(self):
        self._updateCall = reactor.callLater(0, self.syncWithRemotes)


    def stopFactory(self):
        if self._updateCall:
            self._updateCall.cancel()
            self._updateCall = None


    def buildProtocol(self, connection):
        p = self.protocol()
        p.factory = self
        return p


    def syncWithRemotes(self):
        for remote in self.remoteHosts:
            reactor.connectTCP(remote, 119, self.clientFactory)
        self._updateCall = reactor.callLater(self.updatePeriod, self.syncWithRemotes)


# backwards compatibility
Factory = UsenetServerFactory

https://t.me/RX1948 - 2025