示例#1
0
文件: rpycs.py 项目: Rigyu/MaixPy3
 def __init__(self, Address):
     """Set up an initially empty mapping between a user' s nickname
   and the file-like object used to send data to that user."""
     TCPServer.__init__(self,
                        Address,
                        RtspServerThread.Server._Rtsp_,
                        bind_and_activate=True)
示例#2
0
 def __init__(self, address, unit=0, updatetime=True):
     self.time_updater = None
     self.aquaero = Aquaero(unit)
     TCPServer.__init__(self, address, PyquaeroHandler)
     if updatetime:
         self.time_updater = PyquaeroTimeUpdater(self.aquaero)
         self.time_updater.start()
示例#3
0
 def __init__(self, *, host="0.0.0.0", port=1150, objects={}):
     TCPServer.allow_reuse_address = True
     TCPServer.__init__(self, (host, port), ImageHandler)
     Thread.__init__(self)
     self.host = host
     self.port = port
     self.objects = objects
示例#4
0
    def __init__(self, port=7767, handler=None, start=False):
        Handler = handler or AutoUploadHandler
        TCPServer.__init__(self, ('', port), Handler)

        TranxFerLogger.info('Serving on %s : %d ' %
                            (self.getNetwork().ip or self.lh, port))
        if start: self.start()
示例#5
0
	def __init__(self, server_address, request_class, numThreads=10, bind_and_activate=True):
		ThreadPoolMixIn.__init__(self, numThreads=numThreads)
		TCPServer.__init__(
			self,
			server_address,
			request_class,
			bind_and_activate)
示例#6
0
    def __init__(self, address, commands, handler=SteppingParrotRequest):
        """Create a new AssociationServer, bind a socket and start listening.

        Parameters
        ----------
        ae : ae.ApplicationEntity
            The parent AE that's running the server.
        address : 2-tuple
            The (host, port) that the server should run on.
        ssl_context : ssl.SSLContext, optional
            If TLS is to be used then this should be the ssl.SSLContext used
            to wrap the client sockets, otherwise if None then no TLS will be
            used (default).
        """
        self.commands = commands
        self.event = threading.Event()
        self.event.set()
        self.ssl_context = None
        self.allow_reuse_address = True

        TCPServer.__init__(self, address, handler, bind_and_activate=True)

        self.timeout = 60
        self.handlers = []
        self._gc = [0, 59]
示例#7
0
    def __init__(self,
                 server_address,
                 RequestHandlerClass=None,
                 timeout=3.0,
                 authenticator=None,
                 queue_manager=None,
                 topic_manager=None,
                 protocol=None):
        """
        Extension to C{TCPServer} constructor to provide mechanism for providing implementation classes.

        @param server_address: The (address,port) C{tuple}
        @param RequestHandlerClass: The class to use for handling requests.
        @param timeout: The timeout for the underlying socket.
        @keyword authenticator: The configure L{coilmq.auth.Authenticator} object to use.
        @keyword queue_manager: The configured L{coilmq.queue.QueueManager} object to use.
        @keyword topic_manager: The configured L{coilmq.topic.TopicManager} object to use. 
        """
        self.log = logging.getLogger(
            '%s.%s' % (self.__module__, self.__class__.__name__))
        if not RequestHandlerClass:
            RequestHandlerClass = StompRequestHandler
        self.timeout = timeout
        self.authenticator = authenticator
        self.queue_manager = queue_manager
        self.topic_manager = topic_manager
        self.protocol = protocol
        self.frames_queue = Queue.Queue()
        self._serving_event = threading.Event()
        self._shutdown_request_event = threading.Event()
        TCPServer.__init__(self, server_address, RequestHandlerClass)
 def __init__(self,
              server_address,
              router: ServerHandler,
              secure_connection=True,
              certificate_file=None,
              certificate_key_file=None,
              ssl_version=ssl.PROTOCOL_TLS_SERVER,
              ca_certs=None,
              bind_and_activate=True,
              message_parsers=None):
     if message_parsers is None:
         message_parsers = [JsonMessage, ByteMessage]
     handler = ServerClientConnectionFactory(
         router=router, message_parsers=message_parsers)
     Thread.__init__(self)
     TCPServer.__init__(self,
                        server_address=server_address,
                        RequestHandlerClass=handler.create_with_router,
                        bind_and_activate=bind_and_activate)
     self.ssl_version = ssl_version
     self.certificate_file = certificate_file
     self.certificate_key_file = certificate_key_file
     self.ca_certs = ca_certs
     self.secure_connection = secure_connection
     self.router = router
示例#9
0
    def __init__(self, server_address, HandlerClass, nametodns, nameserver,
                 ipv6):
        self.ipv6 = ipv6
        self.nametodns = nametodns
        self.nameserver = nameserver
        self.address_family = socket.AF_INET6 if self.ipv6 else socket.AF_INET

        TCPServer.__init__(self, server_address, HandlerClass)
 def start(self):
     TCPServer.__init__(self, ('localhost', int(HTTP_PORT)), CustomHandler)
     self.RESOURCE_LOCATION = path.abspath(path.dirname(__file__))
     print("Server serving from DocumentRoot:" + self.RESOURCE_LOCATION)
     chdir(self.RESOURCE_LOCATION)
     server_thread = threading.Thread(name='test_file_server', target=self.serve_forever)
     server_thread.daemon = True
     server_thread.start()
示例#11
0
 def __init__(self):
     """
     Tworzy instancję serwera.
     """
     self.__configuration = Configuration()
     TCPServer.__init__(
         self, (self.__configuration.host, self.__configuration.port),
         ClientServerHandler)
    def __init__(self, port, host=SERVER_HOST, loglevel=logging.WARNING):
        logger.setLevel(loglevel)

        # Params: server_address, RequestHandlerClass
        # server_bind(), socket.bind() and server_activate(), socket.listen()
        TCPServer.__init__(self, (host, port), WebSocketRequestHandler)

        # socket.getsockname() return server local address
        self.port = self.socket.getsockname()[1]
示例#13
0
    def __init__(self, server_address, handler_cls):

        TCPServer.__init__(self,
                           server_address,
                           handler_cls,
                           bind_and_activate=False)

        self.socket = socket.fromfd(self.SYSTEMD_FIRST_SOCKET_FD,
                                    self.address_family, self.socket_type)
示例#14
0
 def __init__(self, server_address, handler_cls):
     # Invoke base but omit bind/listen steps (performed by systemd activation!)
     TCPServer.__init__(self,
                        server_address,
                        handler_cls,
                        bind_and_activate=False)
     # Override socket
     self.socket = socket.fromfd(self.SYSTEMD_FIRST_SOCKET_FD,
                                 self.address_family, self.socket_type)
 def __init__(self, port, logfile=None):
     self.port = port
     Handler = webwin.WebWinHTTPRequestHandler
     TCPServer.__init__(self, ("", port), Handler)
     self.timeout = 1
     self.patterngenerator = self
     self._listening = threading.Event()
     self.logfile = logfile
     self.pattern = "#808080|#808080|0|0|1|1"
示例#16
0
    def __init__(self,
                 server_address,
                 base_url,
                 RequestHandlerClass,
                 bind_and_activate=True):
        TCPServer.__init__(self, server_address, RequestHandlerClass,
                           bind_and_activate)

        self.base_url = base_url
示例#17
0
 def __init__(self, address, heartbeat_interval = 10000, family = socket.AF_INET):
     self.address_family = family
     TCPServer.__init__(self, address, BaseRequestHandler, False)
     self._clients = dict()
     self._lock = threading.RLock()
     self._data_items = []
     self._running = False
     self._heartbeat_interval = heartbeat_interval
     self._ping_pat = re.compile('\\* PING')
示例#18
0
 def start(self):
     TCPServer.__init__(self, ('localhost', int(HTTP_PORT)), CustomHandler)
     self.RESOURCE_LOCATION = path.abspath(path.dirname(__file__))
     print("Server serving from DocumentRoot:" + self.RESOURCE_LOCATION)
     chdir(self.RESOURCE_LOCATION)
     server_thread = threading.Thread(name='test_file_server',
                                      target=self.serve_forever)
     server_thread.daemon = True
     server_thread.start()
示例#19
0
 def __init__(self,
              server_address,
              handler,
              resolver,
              bind_and_activate=True):
     self.resolver = resolver
     logger.info('starting TCP DNS server at %s:%s' %
                 (server_address[0], server_address[1]))
     TCPServer.__init__(self, server_address, handler, bind_and_activate)
示例#20
0
 def __init__(self, server_address, RequestHandlerClass, relay_port=8181):
     self.lock = threading.Lock()
     self.reverse_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     self.reverse_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR,
                                    1)
     self.reverse_socket.bind(("0.0.0.0", relay_port))
     self.reverse_socket.listen(5)
     self.new_connect, self.new_connect_addr = self.reverse_socket.accept()
     TCPServer.__init__(self, server_address, RequestHandlerClass)
     self.allow_reuse_addres = True
示例#21
0
 def __init__(self, processes=max(2, cpu_count()), threads=64, daemon=False, kill=True, debug=False, log=logger):
     TCPServer.__init__(self, ('127.0.0.1', 8889), MyTestHandler)
     self._process_n = processes
     self._thread_n = threads
     self._daemon = daemon
     self._kill = kill
     self._debug = debug
     self._logger = log
     self._init_pool()
     logger.info("listening on 127.0.0.1:8889")
示例#22
0
 def __init__(self, server_address, Handler, authFile='bank.auth'):
     '''
     Creates a new bank
     ip:         the ip of the bank. Usually it should be localhost
     port:       the port on which the bank is listening
     authFile:   the auth-File the bank will create.
     '''
     TCPServer.__init__(self, server_address, Handler)
     TCPServer.allow_reuse_address = True
     self.createAuthToken(filename=authFile)
示例#23
0
 def __init__(self, port: int, host: str = '127.0.0.1'):
     TCPServer.__init__(self, (host, port), WebSocketHandler)
     self.port = self.socket.getsockname()[1]
     logging.debug("{}.__init__(port: {}, host: {})".format(
         self.TAG, self.port, host))
     self.new_client = None
     self.client_left = None
     self.message_received = None
     self.ping_received = None
     self.clients = dict()
     self.id_counter = -1
示例#24
0
    def __init__(self, addr=('0.0.0.0', 9001)):
        TCPServer.__init__(self, addr, WebSocketHandler)
        self.port = self.socket.getsockname()[1]

        bigfile = open("test.zip", "rb")
        tempMsg = bigfile.read()
        self.fileRead = tempMsg
        self.fileLength = len(tempMsg)
        self.hashMD5 = hashlib.md5(tempMsg).hexdigest()
        bigfile.close()
        print(self.fileLength)
示例#25
0
 def __init__(self,
              server_address,
              RequestHandlerClass,
              bind_and_activate=True,
              queue=None,
              in_queue=None):
     self.out_queue = queue
     self.in_queue = in_queue
     TCPServer.__init__(self,
                        server_address,
                        RequestHandlerClass,
                        bind_and_activate=bind_and_activate)
示例#26
0
    def __init__(self, port, host='127.0.0.1', logger=None):
        TCPServer.__init__(self, (host, port), WebSocketHandler)
        self.logger = logging.getLogger(__name__)
        if logger:
            self.logger = logger
        self.port = self.socket.getsockname()[1]

        self.clients = []
        self.id_counter = 0
        self.new_client_callback = None
        self.client_left_callback = None
        self.message_received_callback = None
示例#27
0
	def __init__(self, port, host='127.0.0.1', use_ssl = False, ssl_certfile = '', ssl_private_key = ''):
		self.port = port
		self.use_ssl = True
		if use_ssl:
			BaseServer.__init__(self, (host, port), WebSocketHandler)
			ctx = SSL.Context(SSL.SSLv23_METHOD)
			ctx.use_privatekey_file(ssl_private_key)
			ctx.use_certificate_file(ssl_certfile)
			self.socket = SSL.Connection(ctx, socket.socket(self.address_family, self.socket_type))
			self.server_bind()
			self.server_activate()
		else:
			TCPServer.__init__(self, (host, port), WebSocketHandler)
示例#28
0
 def __init__(self,
              server_address,  # Server address (host,port)
              RequestHandlerClass,
              certfile,  # Certificate path
              keyfile,  # Key path
              ssl_version=ssl.PROTOCOL_SSLv23,  #Comunicatio+n protocol
              ciphers="DEFAULT",
              bind_and_activate=True):
     TCPServer.__init__(self, server_address, RequestHandlerClass, bind_and_activate)
     self.certfile = certfile
     self.keyfile = keyfile
     self.ssl_version = ssl_version
     self.ciphers=ciphers
    def __init__(self, server_address, nx_common):
        """Initializes NetflixTCPServer"""
        nx_common.log(msg='Constructing netflixTCPServer')

        netflix_session = NetflixSession(
            cookie_path=nx_common.cookie_path,
            data_path=nx_common.data_path,
            verify_ssl=(nx_common.get_setting('ssl_verification') == 'true'),
            nx_common=nx_common)

        self.res_handler = NetflixHttpSubRessourceHandler(
            nx_common=nx_common, netflix_session=netflix_session)

        TCPServer.__init__(self, server_address, NetflixHttpRequestHandler)
示例#30
0
    def __init__(self, server_address, RequestHandlerClass, certfile, keyfile, bind_and_activate=True):
        TCPServer.__init__(self,
                           server_address,
                           RequestHandlerClass)

        self.socket = ssl.wrap_socket(socket.socket(self.address_family, self.socket_type),
                                      server_side=True,
                                      certfile=certfile,
                                      keyfile=keyfile,
                                      do_handshake_on_connect=False)

        if bind_and_activate:
            self.server_bind()
            self.server_activate()
示例#31
0
 def __init__(self, server_address, request_handler_class, config):
     self.config = config
     self.daemon_threads = True
     if self.config.ipv6:
         self.address_family = socket.AF_INET6
     self.wpad_counters = {}
     try:
         TCPServer.__init__(self, server_address, request_handler_class)
     except OSError as e:
         if "already in use" in str(e):
             LOG.error(
                 'Could not start DNS server. Address is already in use. To fix this error, specify the interface IP to listen on with --interface-ip'
             )
         else:
             LOG.error('Could not start DNS server: %s', str(e))
         raise e
示例#32
0
    def __init__(self,
                 server_address,
                 handler,
                 certfile,
                 keyfile,
                 ssl_version=ssl.PROTOCOL_TLSv1,
                 bind_and_activate=True):
        TCPServer.__init__(self, server_address, handler, bind_and_activate)

        if not os.path.isfile(certfile):
            raise FileNotFoundError(
                f'SSL certificate "{certfile}" file not found!')
        self.certfile = certfile
        if not os.path.isfile(keyfile):
            raise FileNotFoundError(f'SSL key "{keyfile}" not found!')
        self.keyfile = keyfile
        self.ssl_version = ssl_version
示例#33
0
    def __init__(self,
                 file: str,
                 server_address: Tuple,
                 handler_class: BaseRequestHandler,
                 bind_and_activate: bool = True) -> None:
        """
        Creates a new DatabaseServer with the given Database file location
        :param file:              Database file location
        :param server_address:    Address and port of the server
        :param handler_class:     The request handler class
        :param bind_and_activate: If the server should activate on initialization
        """

        self.pid: int = os.getpid()
        self.file: str = file
        self.database: Database = Database(file)
        TCPServer.__init__(self, server_address, handler_class,
                           bind_and_activate)
示例#34
0
    def __init__(self, server_address, RequestHandlerClass=None, timeout=3.0,
                 authenticator=None, queue_manager=None, topic_manager=None, protocol=None):
        """
        Extension to C{TCPServer} constructor to provide mechanism for providing implementation classes.

        @param server_address: The (address,port) C{tuple}
        @param RequestHandlerClass: The class to use for handling requests.
        @param timeout: The timeout for the underlying socket.
        @keyword authenticator: The configure L{coilmq.auth.Authenticator} object to use.
        @keyword queue_manager: The configured L{coilmq.queue.QueueManager} object to use.
        @keyword topic_manager: The configured L{coilmq.topic.TopicManager} object to use. 
        """
        self.log = logging.getLogger('%s.%s' % (
            self.__module__, self.__class__.__name__))
        if not RequestHandlerClass:
            RequestHandlerClass = StompRequestHandler
        self.timeout = timeout
        self.authenticator = authenticator
        self.queue_manager = queue_manager
        self.topic_manager = topic_manager
        self.protocol = protocol
        self._serving_event = threading.Event()
        self._shutdown_request_event = threading.Event()
        TCPServer.__init__(self, server_address, RequestHandlerClass)
示例#35
0
 def __init__(self, do_ssl=False, paypal_mode='valid'):
     TCPServer.__init__(self, ("", 0), Handler)  # old-style base?
     self.do_ssl = do_ssl
     self.paypal_mode = paypal_mode
     self.last_request_body = None
     self.last_request_content_type = None
示例#36
0
 def __init__(self, server_address, handler, resolver, bind_and_activate=True):
     self.resolver = resolver
     logger.info('starting TCP DNS server at %s:%s' % (server_address[0], server_address[1]))
     TCPServer.__init__(self, server_address, handler, bind_and_activate)
示例#37
0
文件: server.py 项目: shred/pyquaero
 def __init__(self, address, unit=0, updatetime=True):
     TCPServer.__init__(self, address, PyquaeroHandler)
     self.aquaero = Aquaero(unit)
     if updatetime:
         self.time_updater = PyquaeroTimeUpdater(self.aquaero)
         self.time_updater.start()
 def __init__(self, host="127.0.0.1", port=12321):
     TCPServer.__init__(self, (host, port), ClientHandler)
 def __init__(self, host, port, name=None):
     self.allow_reuse_address = True
     TCPServer.__init__(self, (host, port), self.RequstHandler)
     if name is None: name = "%s:%s" % (host, port)
     self.name = name
     self.poll_interval = 0.5
示例#40
0
 def __init__(self):
     """
     Tworzy instancję serwera.
     """
     self.__configuration = Configuration()
     TCPServer.__init__(self, (self.__configuration.host, self.__configuration.port), ClientServerHandler)
示例#41
0
 def __init__(self, *args, **kwargs):
     TCPServer.__init__(self, *args, **kwargs)
     self._server_replies = bytearray(b'')
     self._client_sends = []
示例#42
0
    def __init__(self, address, port, requestHandler):
        self._requestHandler = requestHandler
        self._port = port
        self._running = True

        TCPServer.__init__(self, (address, port), HTTPRequestHandler)