当前位置: 首页>>代码示例>>Python>>正文


Python handler.WebSocketHandler方法代码示例

本文整理汇总了Python中geventwebsocket.handler.WebSocketHandler方法的典型用法代码示例。如果您正苦于以下问题:Python handler.WebSocketHandler方法的具体用法?Python handler.WebSocketHandler怎么用?Python handler.WebSocketHandler使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在geventwebsocket.handler的用法示例。


在下文中一共展示了handler.WebSocketHandler方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: work

# 需要导入模块: from geventwebsocket import handler [as 别名]
# 或者: from geventwebsocket.handler import WebSocketHandler [as 别名]
def work(p,rp,nonesym,timec,timebg,btc,btbg,etc,etbg,showetflag,showbtflag):
    global port, static_path, nonesymbol, timecolor, timebackground, btcolor, btbackground, etcolor, etbackground, showbt, showet
    port = p
    static_path = rp
    nonesymbol = nonesym
    timecolor = timec
    timebackground = timebg
    btcolor = btc
    btbackground = btbg
    etcolor = etc
    etbackground = etbg
    showet = showetflag
    showbt = showbtflag
    TEMPLATE_PATH.insert(0,rp)
    s = WSGIServer(("0.0.0.0", p), default_app(), handler_class=WebSocketHandler)
    s.serve_forever() 
开发者ID:artisan-roaster-scope,项目名称:artisan,代码行数:18,代码来源:weblcds.py

示例2: run

# 需要导入模块: from geventwebsocket import handler [as 别名]
# 或者: from geventwebsocket.handler import WebSocketHandler [as 别名]
def run(self):
        pebble_greenlet = self.pebble.connect()
        self.pebble.pebble.register_raw_inbound_handler(self._handle_inbound)
        self.pebble.pebble.register_raw_outbound_handler(self._handle_outbound)
        if self.pebble.timeline_is_supported:
            self.timeline.continuous_sync()
            self.timeline.do_maintenance()
        logging.getLogger().addHandler(WebsocketLogHandler(self, level=logging.WARNING))
        if self.ssl_root is not None:
            ssl_args = {
                'keyfile': '%s/server-key.pem' % self.ssl_root,
                'certfile': '%s/server-cert.pem' % self.ssl_root,
                'ca_certs': '%s/ca-cert.pem' % self.ssl_root,
                'ssl_version': ssl.PROTOCOL_TLSv1,
            }
        else:
            ssl_args = {}
        self.server = pywsgi.WSGIServer(("", self.port), self.handle_ws, handler_class=WebSocketHandler, **ssl_args)
        gevent.spawn(self.server.serve_forever)
        pebble_greenlet.join()
        self.server.close()
        self.pebble.disconnect() 
开发者ID:pebble,项目名称:pypkjs,代码行数:24,代码来源:websocket.py

示例3: configure_flask_logger

# 需要导入模块: from geventwebsocket import handler [as 别名]
# 或者: from geventwebsocket.handler import WebSocketHandler [as 别名]
def configure_flask_logger():
    """
    Unfortunately there is a known issue using geventwebsocket.WebSocketHandler
    and the core logging module. This is a hack to still be able to see the flask logs.
    http://www.gevent.org/gevent.pywsgi.html#gevent.pywsgi.LoggingLogAdapter
    """
    flask_logger = logging.getLogger()
    flask_ch = logging.StreamHandler()
    flask_logger.setLevel(logging.INFO)
    flask_logger.addHandler(flask_ch)
    return flask_logger 
开发者ID:mitre,项目名称:cascade-server,代码行数:13,代码来源:server.py

示例4: run_server

# 需要导入模块: from geventwebsocket import handler [as 别名]
# 或者: from geventwebsocket.handler import WebSocketHandler [as 别名]
def run_server(debug=False):
    global app

    config = settings.load()
    attack.attack_url = config['links']['attack']
    attack.proxies = config['links']['proxies']

    interface = config['server']['interface']
    port = config['server']['port']
    threaded = True if debug else not async.enable_async()

    flask_logger = configure_flask_logger()
    connect_to_database()

    # if not threaded and not debug:
    ssl_context = {}
    https = config['server']['https']
    if https['enabled']:
        ssl_context['certfile'] = https['certfile']
        ssl_context['keyfile'] = https['keyfile']

    app.debug = debug

    print('Running CASCADE via WSGIServer on {url}'.format(url=config['server']['url']))
    wsgi = WSGIServer((interface, port), app, log=flask_logger, handler_class=WebSocketHandler, **ssl_context)
    wsgi.serve_forever() 
开发者ID:mitre,项目名称:cascade-server,代码行数:28,代码来源:server.py

示例5: _get_server

# 需要导入模块: from geventwebsocket import handler [as 别名]
# 或者: from geventwebsocket.handler import WebSocketHandler [as 别名]
def _get_server(self):
        return WSGIServer((self.listen_on, self.port),
                          SioMiddleware(self.sio_app, self.flask_app),
                          handler_class=WebSocketHandler) 
开发者ID:OpenMTC,项目名称:OpenMTC,代码行数:6,代码来源:__init__.py

示例6: run

# 需要导入模块: from geventwebsocket import handler [as 别名]
# 或者: from geventwebsocket.handler import WebSocketHandler [as 别名]
def run():
        global application
        app.debug = True
        application = DebuggedApplication(application, evalex=True)
        server = WSGIServer(('localhost', PORT), application, handler_class=WebSocketHandler)
        server.serve_forever() 
开发者ID:leancloud,项目名称:python-getting-started,代码行数:8,代码来源:wsgi.py

示例7: __init__

# 需要导入模块: from geventwebsocket import handler [as 别名]
# 或者: from geventwebsocket.handler import WebSocketHandler [as 别名]
def __init__(self,
                 session_store,
                 host='localhost',
                 port=8002,
                 route=DEFAULT_ROUTE,
                 auth_fn=None,
                 auth_timeout=60):  # seconds
        """
        The parameters here are the same  for the client server except for
        route, where route is a regular expression (as a string or regex
        object) that defines where to look for connections.
        For example:
            `/(.+)`
        There should be exactly one group in the route, this will be the uuid
        match.
        The auth_timeout is the amount of time to leave a socket open awaiting
        the start_event or first message. This is measured in seconds.
        """
        self.auth_fn = auth_fn or self.NO_AUTH
        self.auth_timeout = auth_timeout
        self.route = re.compile(route, re.IGNORECASE)
        self.session_store = session_store
        if self.route.groups != 1:
            # We need exactly one regex group.
            raise QdbInvalidRoute(self.route)
        self._server = pywsgi.WSGIServer(
            (host, port),
            self.handle_client,
            handler_class=WebSocketHandler,
        ) 
开发者ID:quantopian,项目名称:qdb,代码行数:32,代码来源:client.py

示例8: start_server

# 需要导入模块: from geventwebsocket import handler [as 别名]
# 或者: from geventwebsocket.handler import WebSocketHandler [as 别名]
def start_server(host, port, app, port_lookup, port_lookup_attempts=0):
    server = pywsgi.WSGIServer((host, port), app, handler_class=WebSocketHandler)

    print(
        'Serving on http://{host}:{port} in process {pid}'.format(
            host=host, port=port, pid=os.getpid()
        )
    )

    log_action(START_DAGIT_WEBSERVER)
    with uploading_logging_thread():
        try:
            server.serve_forever()
        except OSError as os_error:
            if 'Address already in use' in str(os_error):
                if port_lookup and (
                    port_lookup_attempts > 0
                    or click.confirm(
                        (
                            'Another process on your machine is already listening on port {port}. '
                            'Would you like to run the app at another port instead?'
                        ).format(port=port)
                    )
                ):
                    port_lookup_attempts += 1
                    start_server(host, port + port_lookup_attempts, app, True, port_lookup_attempts)
                else:
                    six.raise_from(
                        Exception(
                            (
                                'Another process on your machine is already listening on port {port}. '
                                'It is possible that you have another instance of dagit '
                                'running somewhere using the same port. Or it could be another '
                                'random process. Either kill that process or use the -p option to '
                                'select another port.'
                            ).format(port=port)
                        ),
                        os_error,
                    )
            else:
                raise os_error 
开发者ID:dagster-io,项目名称:dagster,代码行数:43,代码来源:cli.py

示例9: run

# 需要导入模块: from geventwebsocket import handler [as 别名]
# 或者: from geventwebsocket.handler import WebSocketHandler [as 别名]
def run(self, handler):
        server = pywsgi.WSGIServer((self.host, self.port), handler, handler_class=WebSocketHandler)

        if not self.quiet:
            server.logger = create_logger('geventwebsocket.logging')
            server.logger.setLevel(logging.INFO)
            server.logger.addHandler(logging.StreamHandler())

        server.serve_forever() 
开发者ID:hyeonsangjeon,项目名称:youtube-dl-nas,代码行数:11,代码来源:server.py

示例10: handle

# 需要导入模块: from geventwebsocket import handler [as 别名]
# 或者: from geventwebsocket.handler import WebSocketHandler [as 别名]
def handle(self, *args, **options):
        if sio.async_mode == 'threading':
            super(Command, self).handle(*args, **options)
        elif sio.async_mode == 'eventlet':
            # deploy with eventlet
            import eventlet
            import eventlet.wsgi
            from django_example.wsgi import application
            eventlet.wsgi.server(eventlet.listen(('', 8000)), application)
        elif sio.async_mode == 'gevent':
            # deploy with gevent
            from gevent import pywsgi
            from django_example.wsgi import application
            try:
                from geventwebsocket.handler import WebSocketHandler
                websocket = True
            except ImportError:
                websocket = False
            if websocket:
                pywsgi.WSGIServer(
                    ('', 8000), application,
                    handler_class=WebSocketHandler).serve_forever()
            else:
                pywsgi.WSGIServer(('', 8000), application).serve_forever()
        elif sio.async_mode == 'gevent_uwsgi':
            print('Start the application through the uwsgi server. Example:')
            print('uwsgi --http :5000 --gevent 1000 --http-websockets '
                  '--master --wsgi-file django_example/wsgi.py --callable '
                  'application')
        else:
            print('Unknown async_mode: ' + sio.async_mode) 
开发者ID:miguelgrinberg,项目名称:python-socketio,代码行数:33,代码来源:runserver.py

示例11: run

# 需要导入模块: from geventwebsocket import handler [as 别名]
# 或者: from geventwebsocket.handler import WebSocketHandler [as 别名]
def run(self, handler):
        server = pywsgi.WSGIServer((self.host, self.port), handler, handler_class=WebSocketHandler, **self.options)

        if not self.quiet:
            server.logger = create_logger('geventwebsocket.logging')
            server.logger.setLevel(logging.INFO)
            server.logger.addHandler(logging.StreamHandler())

        server.serve_forever() 
开发者ID:julesontheroad,项目名称:NSC_BUILDER,代码行数:11,代码来源:server.py

示例12: runserver

# 需要导入模块: from geventwebsocket import handler [as 别名]
# 或者: from geventwebsocket.handler import WebSocketHandler [as 别名]
def runserver(port, ip, debug):

    if debug is None:
        server = WSGIServer((ip, port), app, handler_class=WebSocketHandler)
        server.serve_forever()

    click.echo(u'OpenMining start server at: {}:{}'.format(ip, port))
    run(app=app, host=ip, port=port, debug=debug,
        reloader=True, server=GeventWebSocketServer) 
开发者ID:mining,项目名称:mining,代码行数:11,代码来源:manage.py

示例13: _serve_wsgi

# 需要导入模块: from geventwebsocket import handler [as 别名]
# 或者: from geventwebsocket.handler import WebSocketHandler [as 别名]
def _serve_wsgi(self):
        with self.worksheet_fd:
            app = manuskript_server.InitializeApp(
                plugins=self.PLUGINS,
                config=dict(
                    worksheet=self.worksheet_fd,
                ))

            # Use blueprint as an easy way to serve static files.
            bp = Blueprint('rekall-webconsole', __name__,
                           static_url_path="/rekall-webconsole",
                           static_folder=STATIC_PATH)

            @bp.after_request
            def add_header(response):  # pylint: disable=unused-variable
                response.headers['Cache-Control'] = 'no-cache, no-store'
                return response

            app.register_blueprint(bp)

            # Use blueprint as an easy way to serve static files.
            bp = Blueprint('worksheet', __name__,
                           static_url_path="/worksheet",
                           static_folder=self.worksheet_path)

            @bp.after_request
            def add_header_2(response):  # pylint: disable=unused-variable
                response.headers['Cache-Control'] = 'no-cache, no-store'
                return response

            app.register_blueprint(bp)

            server = pywsgi.WSGIServer(
                (self.host, self.port), app,
                environ={'wsgi.multithread': True},
                handler_class=WebSocketHandler)

            t = threading.Thread(target=self.server_post_activate_callback,
                                 args=(server,))
            t.start()

            server.serve_forever() 
开发者ID:google,项目名称:rekall,代码行数:44,代码来源:webconsole_plugin.py


注:本文中的geventwebsocket.handler.WebSocketHandler方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。