Пример #1
0
    def __init__(self,
                 timeout=0,
                 actorClass=TCPClientActor,
                 sid=None,
                 sapID=None):
        if _debug:
            TCPClientDirector._debug(
                "__init__ timeout=%r actorClass=%r sid=%r sapID=%r", timeout,
                actorClass, sid, sapID)
        Server.__init__(self, sid)
        ServiceAccessPoint.__init__(self, sapID)

        # check the actor class
        if not issubclass(actorClass, TCPClientActor):
            raise TypeError, "actorClass must be a subclass of TCPClientActor"
        self.actorClass = actorClass

        # save the timeout for actors
        self.timeout = timeout

        # start with an empty client pool
        self.clients = {}

        # no clients automatically reconnecting
        self.reconnect = {}
Пример #2
0
    def __init__(self, cid=None, sid=None):
        """An Annex-H BACnet Tunneling Router node."""
        if _debug: BTR._debug("__init__ cid=%r sid=%r", cid, sid)
        Client.__init__(self, cid)
        Server.__init__(self, sid)

        # initialize a dicitonary of peers
        self.peers = {}
Пример #3
0
 def __init__(self, sapID=None, cid=None, sid=None):
     """A BIP node."""
     if _debug:
         BIPSimple._debug("__init__ sapID=%r cid=%r sid=%r", sapID, cid,
                          sid)
     BIPSAP.__init__(self, sapID)
     Client.__init__(self, cid)
     Server.__init__(self, sid)
Пример #4
0
    def __init__(self, cid=None, sid=None):
        """An Annex-H BACnet Tunneling Router node."""
        if _debug: BTR._debug("__init__ cid=%r sid=%r", cid, sid)
        Client.__init__(self, cid)
        Server.__init__(self, sid)

        # initialize a dicitonary of peers
        self.peers = {}
Пример #5
0
 def __init__(self, fn, cid=None, sid=None):
     if _debug: StreamToPacket._debug("__init__ %r cid=%r, sid=%r", fn, cid, sid)
     Client.__init__(self, cid)
     Server.__init__(self, sid)
     
     # save the packet function
     self.packetFn = fn
     
     # start with an empty set of buffers
     self.upstreamBuffer = {}
     self.downstreamBuffer = {}
Пример #6
0
 def __init__(self, fn, cid=None, sid=None):
     if _debug: StreamToPacket._debug("__init__ %r cid=%r, sid=%r", fn, cid, sid)
     Client.__init__(self, cid)
     Server.__init__(self, sid)
     
     # save the packet function
     self.packetFn = fn
     
     # start with an empty set of buffers
     self.upstreamBuffer = {}
     self.downstreamBuffer = {}
Пример #7
0
    def __init__(self, sap=None, sid=None):
        if _debug:
            NetworkServiceAccessPoint._debug("__init__ sap=%r sid=%r", sap,
                                             sid)
        ServiceAccessPoint.__init__(self, sap)
        Server.__init__(self, sid)

        self.adapters = []  # list of adapters
        self.routers = {}  # (adapter, address) -> RouterReference
        self.networks = {}  # network -> RouterReference

        self.localAdapter = None  # which one is local
        self.localAddress = None  # what is the local address
Пример #8
0
    def __init__(self, addr, sapID=None, cid=None, sid=None):
        """A BBMD node."""
        if _debug: BIPBBMD._debug("__init__ %r sapID=%r cid=%r sid=%r", addr, sapID, cid, sid)
        BIPSAP.__init__(self, sapID)
        Client.__init__(self, cid)
        Server.__init__(self, sid)
        RecurringTask.__init__(self, 1000.0)

        self.bbmdAddress = addr
        self.bbmdBDT = []
        self.bbmdFDT = []

        # install so process_task runs
        self.install_task()
Пример #9
0
    def __init__(self,
                 address,
                 timeout=0,
                 reuse=False,
                 actorClass=UDPActor,
                 sid=None,
                 sapID=None):
        if _debug:
            UDPDirector._debug(
                "__init__ %r timeout=%r reuse=%r actorClass=%r sid=%r sapID=%r",
                address, timeout, reuse, actorClass, sid, sapID)
        Server.__init__(self, sid)
        ServiceAccessPoint.__init__(self, sapID)

        # check the actor class
        if not issubclass(actorClass, UDPActor):
            raise TypeError, "actorClass must be a subclass of UDPActor"
        self.actorClass = actorClass

        # save the timeout for actors
        self.timeout = timeout

        # save the address
        self.address = address

        asyncore.dispatcher.__init__(self)

        # ask the dispatcher for a socket
        self.create_socket(socket.AF_INET, socket.SOCK_DGRAM)

        # if the reuse parameter is provided, set the socket option
        if reuse:
            self.set_reuse_addr()

        # proceed with the bind
        self.bind(address)
        if _debug:
            UDPDirector._debug("    - getsockname: %r",
                               self.socket.getsockname())

        # allow it to send broadcasts
        self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)

        # create the request queue
        self.request = Queue.Queue()

        # start with an empty peer pool
        self.peers = {}
Пример #10
0
    def __init__(self, addr, sapID=None, cid=None, sid=None):
        """A BBMD node."""
        if _debug:
            BIPBBMD._debug("__init__ %r sapID=%r cid=%r sid=%r", addr, sapID,
                           cid, sid)
        BIPSAP.__init__(self, sapID)
        Client.__init__(self, cid)
        Server.__init__(self, sid)
        RecurringTask.__init__(self, 1000.0)

        self.bbmdAddress = addr
        self.bbmdBDT = []
        self.bbmdFDT = []

        # install so process_task runs
        self.install_task()
Пример #11
0
    def __init__(self, address, listeners=5, timeout=0, reuse=False, actorClass=TCPServerActor, cid=None, sapID=None):
        if _debug:
            TCPServerDirector._debug("__init__ %r listeners=%r timeout=%r reuse=%r actorClass=%r cid=%r sapID=%r"
                , address, listeners, timeout, reuse, actorClass, cid, sapID
                )
        Server.__init__(self, cid)
        ServiceAccessPoint.__init__(self, sapID)

        # save the address and timeout
        self.port = address
        self.timeout = timeout

        # check the actor class
        if not issubclass(actorClass, TCPServerActor):
            raise TypeError, "actorClass must be a subclass of TCPServerActor"
        self.actorClass = actorClass
        
        # start with an empty pool of servers
        self.servers = {}

        # continue with initialization
        asyncore.dispatcher.__init__(self)
        
        # create a listening port
        self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
        if reuse:
            self.set_reuse_addr()

        # try to bind, keep trying for a while if its already in use
        hadBindErrors = False
        for i in range(30):
            try:
                self.bind(address)
                break
            except socket.error as err:
                hadBindErrors = True
                TCPServerDirector._warning('bind error %r, sleep and try again', err)
                _sleep(REBIND_SLEEP_INTERVAL)
        else:
            TCPServerDirector._error('unable to bind')
            raise RuntimeError, "unable to bind"

        # if there were some bind errors, generate a meesage that all is OK now
        if hadBindErrors:
            TCPServerDirector._info('bind successful')

        self.listen(listeners)
Пример #12
0
    def __init__(self, timeout=0, actorClass=TCPClientActor, sid=None, sapID=None):
        if _debug: TCPClientDirector._debug("__init__ timeout=%r actorClass=%r sid=%r sapID=%r", timeout, actorClass, sid, sapID)
        Server.__init__(self, sid)
        ServiceAccessPoint.__init__(self, sapID)

        # check the actor class
        if not issubclass(actorClass, TCPClientActor):
            raise TypeError, "actorClass must be a subclass of TCPClientActor"
        self.actorClass = actorClass
        
        # save the timeout for actors
        self.timeout = timeout

        # start with an empty client pool
        self.clients = {}

        # no clients automatically reconnecting
        self.reconnect = {}
Пример #13
0
    def __init__(self, addr, lan=None, promiscuous=False, spoofing=False, sid=None):
        if _debug:
            Node._debug("__init__ %r lan=%r promiscuous=%r spoofing=%r sid=%r",
                addr, lan, promiscuous, spoofing, sid
                )
        Server.__init__(self, sid)

        if not isinstance(addr, Address):
            raise TypeError, "addr must be an address"
            
        self.lan = None
        self.address = addr

        # bind to a lan if it was provided
        if lan:
            self.bind(lan)

        # might receive all packets and might spoof
        self.promiscuous = promiscuous
        self.spoofing = spoofing
Пример #14
0
    def __init__(self, addr=None, ttl=None, sapID=None, cid=None, sid=None):
        """A BIP node."""
        if _debug: BIPForeign._debug("__init__ addr=%r ttl=%r sapID=%r cid=%r sid=%r", addr, ttl, sapID, cid, sid)
        BIPSAP.__init__(self, sapID)
        Client.__init__(self, cid)
        Server.__init__(self, sid)
        OneShotTask.__init__(self)

        # -2=unregistered, -1=not attempted or no ack, 0=OK, >0 error
        self.registrationStatus = -1

        # clear the BBMD address and time-to-live
        self.bbmdAddress = None
        self.bbmdTimeToLive = None

        # registration provided
        if addr:
            # a little error checking
            if ttl is None:
                raise RuntimeError, "BBMD address and time-to-live must both be specified"

            self.register(addr, ttl)
Пример #15
0
    def __init__(self, address, listeners=5, timeout=0, reuse=False, actorClass=TCPServerActor, cid=None, sapID=None):
        if _debug:
            TCPServerDirector._debug("__init__ %r listeners=%r timeout=%r reuse=%r actorClass=%r cid=%r sapID=%r"
                , address, listeners, timeout, reuse, actorClass, cid, sapID
                )
        Server.__init__(self, cid)
        ServiceAccessPoint.__init__(self, sapID)

        # save the address and timeout
        self.port = address
        self.timeout = timeout

        # check the actor class
        if not issubclass(actorClass, TCPServerActor):
            raise TypeError, "actorClass must be a subclass of TCPServerActor"
        self.actorClass = actorClass
        
        # start with an empty pool of servers
        self.servers = {}

        # continue with initialization
        asyncore.dispatcher.__init__(self)
        
        # create a listening port
        self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
        if reuse:
            self.set_reuse_addr()

        # try to bind, keep trying for a while if its already in use
        hadBindErrors = False
        for i in range(30):
            try:
                self.bind(address)
                break
            except socket.error, err:
                hadBindErrors = True
                TCPServerDirector._warning('bind error %r, sleep and try again', err)
                _sleep(REBIND_SLEEP_INTERVAL)
Пример #16
0
    def __init__(self, addr=None, ttl=None, sapID=None, cid=None, sid=None):
        """A BIP node."""
        if _debug:
            BIPForeign._debug("__init__ addr=%r ttl=%r sapID=%r cid=%r sid=%r",
                              addr, ttl, sapID, cid, sid)
        BIPSAP.__init__(self, sapID)
        Client.__init__(self, cid)
        Server.__init__(self, sid)
        OneShotTask.__init__(self)

        # -2=unregistered, -1=not attempted or no ack, 0=OK, >0 error
        self.registrationStatus = -1

        # clear the BBMD address and time-to-live
        self.bbmdAddress = None
        self.bbmdTimeToLive = None

        # registration provided
        if addr:
            # a little error checking
            if ttl is None:
                raise RuntimeError, "BBMD address and time-to-live must both be specified"

            self.register(addr, ttl)
Пример #17
0
    def __init__(self,
                 addr,
                 lan=None,
                 promiscuous=False,
                 spoofing=False,
                 sid=None):
        if _debug:
            Node._debug("__init__ %r lan=%r promiscuous=%r spoofing=%r sid=%r",
                        addr, lan, promiscuous, spoofing, sid)
        Server.__init__(self, sid)

        if not isinstance(addr, Address):
            raise TypeError, "addr must be an address"

        self.lan = None
        self.address = addr

        # bind to a lan if it was provided
        if lan:
            self.bind(lan)

        # might receive all packets and might spoof
        self.promiscuous = promiscuous
        self.spoofing = spoofing
Пример #18
0
 def __init__(self, mux):
     Server.__init__(self)
     self.multiplexer = mux
Пример #19
0
 def __init__(self, cid=None, sid=None):
     if _debug: AnnexJCodec._debug("__init__ cid=%r sid=%r", cid, sid)
     Client.__init__(self, cid)
     Server.__init__(self, sid)
Пример #20
0
 def __init__(self, cid=None, sid=None):
     if _debug: AnnexJCodec._debug("__init__ cid=%r sid=%r", cid, sid)
     Client.__init__(self, cid)
     Server.__init__(self, sid)
Пример #21
0
 def __init__(self, sapID=None, cid=None, sid=None):
     """A BIP node."""
     if _debug: BIPSimple._debug("__init__ sapID=%r cid=%r sid=%r", sapID, cid, sid)
     BIPSAP.__init__(self, sapID)
     Client.__init__(self, cid)
     Server.__init__(self, sid)
Пример #22
0
 def __init__(self, sid=None):
     ConsoleServer._debug("__init__ sid=%r", sid)
     asyncore.file_dispatcher.__init__(self, sys.stdin)
     Server.__init__(self, sid)
Пример #23
0
 def __init__(self, mux):
     Server.__init__(self)
     self.multiplexer = mux
Пример #24
0
 def __init__(self, sid=None):
     ConsoleServer._debug("__init__ sid=%r", sid)
     asyncore.file_dispatcher.__init__(self, sys.stdin)
     Server.__init__(self, sid)