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


Python tornado.options方法代码示例

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


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

示例1: get

# 需要导入模块: import tornado [as 别名]
# 或者: from tornado import options [as 别名]
def get(self, *path):
        token = path[0].split("/")
        logging.warning("DISPLAY ACTION> %s", token)
        try:
            tag = token[0]
            if tag == "ONE_NODE":
                tag += ":" + token[1]
            out = GetUpdate(token)
            SendToSocketJson(tag + ":", out)
        except Exception as e:
            logging.error("cannot processed: %s", path[0])
            print("-" * 60)
            traceback.print_exc(file=sys.stdout)
            print("-" * 60)
        self.finish()


# use --logging=none
# to disable the tornado logging overrides caused by
# tornado.options.parse_command_line( 
开发者ID:robertmuth,项目名称:PyZwaver,代码行数:22,代码来源:example_webserver.py

示例2: main

# 需要导入模块: import tornado [as 别名]
# 或者: from tornado import options [as 别名]
def main():
    """
    Main function to start the webserver application and listen on the specified port.
    """
    tornado.options.parse_command_line()
    application = Application(tornado.options.options.domain,
                              tornado.options.options.salt,
                              tornado.options.options.redis_namespace,
                              tornado.options.options.redis_host,
                              int(tornado.options.options.redis_port),
                              tornado.options.options.redis_db,
                              tornado.options.options.redis_password,
                              int(tornado.options.options.ttl))
    if tornado.options.options.localhostonly:
        address = '127.0.0.1'
        logging.info('Listening to localhost only')
    else:
        address = ''
        logging.info('Listening to all addresses on all interfaces')
    application.listen(tornado.options.options.port, address=address, xheaders=True)
    tornado.ioloop.IOLoop.instance().start()


# Run main method if script is run from command line. 
开发者ID:nellessen,项目名称:tornado-shortener,代码行数:26,代码来源:app.py

示例3: __init__

# 需要导入模块: import tornado [as 别名]
# 或者: from tornado import options [as 别名]
def __init__(self, opt):
        """
        Create a WebsocketManager using the given setup options.
        """
        super().__init__(opt)
        self.opt = opt
        self.port = opt.get('port')
        self.subs = {}

        self.app = None
        self.debug = opt.get('is_debug', False)

        self.message_sender = WebsocketManager.MessageSender()

        self.service_reference_id = None

        self._parse_config(opt)
        self._complete_setup() 
开发者ID:facebookresearch,项目名称:ParlAI,代码行数:20,代码来源:websocket_manager.py

示例4: _make_app

# 需要导入模块: import tornado [as 别名]
# 或者: from tornado import options [as 别名]
def _make_app(self):
        """
        Starts the tornado application.
        """
        message_callback = self._on_new_message

        options['log_to_stderr'] = True
        tornado.options.parse_command_line([])

        return tornado.web.Application(
            [
                (
                    r"/websocket",
                    MessageSocketHandler,
                    {'subs': self.subs, 'message_callback': message_callback},
                )
            ],
            debug=self.debug,
        ) 
开发者ID:facebookresearch,项目名称:ParlAI,代码行数:21,代码来源:websocket_manager.py

示例5: startTornado

# 需要导入模块: import tornado [as 别名]
# 或者: from tornado import options [as 别名]
def startTornado(IP,PORT,log):
    try:
        server.bind(int(PORT), address=IP)
        # Useful for using custom loggers because of relative paths in secure requests
        # http://www.joet3ch.com/blog/2011/09/08/alternative-tornado-logging/
        server.start(int(1))
    except:
        print "\n[INFO] WebProxy Socket is already in use"
        pass
    #Clean Up
    rmfiles = [os.path.join(log,"requestdb"),os.path.join(log,"urls"),os.path.join(log,"WebTraffic.txt")]
    for fil in rmfiles:
        if os.path.exists(fil):
            os.remove(fil)
    logp = os.path.join(settings.LOG_DIR, 'webproxy.log')
    tornado.options.parse_command_line(args=["dummy_arg","--log_file_prefix="+logp,"--logging=info"])
    tornado.ioloop.PeriodicCallback(try_exit, 100).start()
    tornado.ioloop.IOLoop.instance().start() 
开发者ID:HackingLab,项目名称:MobileSF,代码行数:20,代码来源:pywebproxy.py

示例6: inject_options

# 需要导入模块: import tornado [as 别名]
# 或者: from tornado import options [as 别名]
def inject_options(**kwargs):
    """Add extra options programmatically.

    dokomoforms.options.parse_options reads from sys.argv if
    dokomoforms.options._arg is None. Calling
    dokomoforms.options.inject_options(name1='value1', name2='value2', ...) at
    the top of a file injects the given options instead.

    :param kwargs: name='value' arguments like the ones that would be passed
                   to webapp.py as --name=value or set in local_config.py as
                   name = 'value'
    """
    global _arg
    # The first element doesn't get read by tornado.options.parse_command_line,
    # so we might as well set it to None
    new_arg = [None]
    new_arg.extend(
        '--{name}={value}'.format(name=k, value=kwargs[k]) for k in kwargs
    )
    _arg = new_arg 
开发者ID:SEL-Columbia,项目名称:dokomoforms,代码行数:22,代码来源:options.py

示例7: __init__

# 需要导入模块: import tornado [as 别名]
# 或者: from tornado import options [as 别名]
def __init__(self):
        self._nodes = {}
        if options.debug:
            logger.setLevel(logging.DEBUG)

        handlers = [
            (r'/', DashboardHandler),
        ]
        settings = {'debug': True,
                    "cookie_secret": "MY_COOKIE_ID",
                    "xsrf_cookies": False,
                    'static_path': options.static_path,
                    'template_path': options.static_path
                    }
        super().__init__(handlers, **settings)
        logger.info('Application started, listening on port {0}'
                    .format(options.web_port)) 
开发者ID:pyaiot,项目名称:pyaiot,代码行数:19,代码来源:dashboard.py

示例8: parse_command_line

# 需要导入模块: import tornado [as 别名]
# 或者: from tornado import options [as 别名]
def parse_command_line(extra_args_func=None):
    """Parse command line arguments for any Pyaiot application."""
    if not hasattr(options, "config"):
        define("config", default=None, help="Config file")
    if not hasattr(options, "broker_host"):
        define("broker_host", default="localhost", help="Broker host")
    if not hasattr(options, "broker_port"):
        define("broker_port", default=8000, help="Broker websocket port")
    if not hasattr(options, "debug"):
        define("debug", default=False, help="Enable debug mode.")
    if not hasattr(options, "key_file"):
        define("key_file", default=DEFAULT_KEY_FILENAME,
               help="Secret and private keys filename.")
    if extra_args_func is not None:
        extra_args_func()

    options.parse_command_line()
    if options.config:
        options.parse_config_file(options.config)
    # Parse the command line a second time to override config file options
    options.parse_command_line() 
开发者ID:pyaiot,项目名称:pyaiot,代码行数:23,代码来源:helpers.py

示例9: main

# 需要导入模块: import tornado [as 别名]
# 或者: from tornado import options [as 别名]
def main():
    asyncio.set_event_loop(asyncio.new_event_loop())
    define("port", default=8011, type=int, help="服务器监听端口号")

    define("address", default='0.0.0.0', type=str, help='服务器地址')
    define("content", default=[], type=str, multiple=True, help="控制台输出内容")
    parse_command_line()
    apps = Application(
        handlers=handlers,
        debug=True,
        autoreload=True,
        compress_response=True
    )
    port = options.port

    # stock_coll = QARTC_Stock(username='quantaxis', password='quantaxis')

    # threading.Thread(target=)

    http_server = tornado.httpserver.HTTPServer(apps)
    http_server.bind(port=options.port, address=options.address)
    """增加了对于非windows下的机器多进程的支持
    """
    http_server.start(1)
    tornado.ioloop.IOLoop.current().start() 
开发者ID:yutiansut,项目名称:QUANTAXIS_RealtimeCollector,代码行数:27,代码来源:webserver.py

示例10: main

# 需要导入模块: import tornado [as 别名]
# 或者: from tornado import options [as 别名]
def main():
    ''' main 函数
    '''
    # 开启 search_engin_server
    ioloop = tornado.ioloop.IOLoop.instance()
    server = tornado.httpserver.HTTPServer(Application(), xheaders=True)
    server.listen(options.port)

    def sig_handler(sig, _):
        ''' 信号接收函数
        '''
        logging.warn("Caught signal: %s", sig)
        shutdown(ioloop, server)

    signal.signal(signal.SIGTERM, sig_handler)
    signal.signal(signal.SIGINT, sig_handler)
    ioloop.start() 
开发者ID:JK-River,项目名称:RobotAIEngine,代码行数:19,代码来源:init.py

示例11: run

# 需要导入模块: import tornado [as 别名]
# 或者: from tornado import options [as 别名]
def run():
    """Main entry point for model runtime api."""

    # Register signal handlers.
    logging.info("Preparing signal handlers..")
    signal.signal(signal.SIGINT, signal_handler)
    signal.signal(signal.SIGTERM, signal_handler)

    # Set up model cache.
    # If containerizing, suggest initializing the directories (and associated
    # file downloads) be performed during container build time.
    logging.info("Initializing model directories:")
    logging.info("    bert  : %s", options.bert_model_dir)
    logging.info("    bidaf : %s", options.bidaf_model_dir)

    language_helper = LanguageHelper()
    if (
        language_helper.initialize_models(
            options.bert_model_dir, options.bidaf_model_dir
        )
        is False
    ):
        logging.error("Could not initilize model directories.  Exiting..")
        return

    # Build the configuration
    logging.info("Building config..")
    ref_obj = {"language_helper": language_helper}
    app_config = ModelHandler.build_config(ref_obj)

    logging.info("Starting Tornado model runtime service..")
    application = tornado.web.Application(app_config)
    application.listen(options.port)

    # Protect the loop with a try/catch
    try:
        # Start the app and wait for a close
        tornado.ioloop.IOLoop.instance().start()
    finally:
        # handle error with shutting down loop
        tornado.ioloop.IOLoop.instance().stop() 
开发者ID:microsoft,项目名称:botbuilder-python,代码行数:43,代码来源:main.py

示例12: options

# 需要导入模块: import tornado [as 别名]
# 或者: from tornado import options [as 别名]
def options(self):
        # no body
        self.set_status(204)
        self.finish() 
开发者ID:robertmuth,项目名称:PyZwaver,代码行数:6,代码来源:example_webserver.py

示例13: main

# 需要导入模块: import tornado [as 别名]
# 或者: from tornado import options [as 别名]
def main():
    tornado.options.parse_command_line()
    application = tornado.web.Application([
        (r"/", MainHandler),
    ])
    http_server = tornado.httpserver.HTTPServer(application)
    http_server.listen(options.port)
    tornado.ioloop.IOLoop.instance().start() 
开发者ID:omererdem,项目名称:honeything,代码行数:10,代码来源:helloworld.py

示例14: options

# 需要导入模块: import tornado [as 别名]
# 或者: from tornado import options [as 别名]
def options(self):
        return self.get() 
开发者ID:HackingLab,项目名称:MobileSF,代码行数:4,代码来源:pywebproxy.py

示例15: parse_options

# 需要导入模块: import tornado [as 别名]
# 或者: from tornado import options [as 别名]
def parse_options():
    """tornado.options.parse_command_line doesn't cut it.

    Tells Tornado to read from the config.py file (which in turn reads from
    the local_config.py file), then from options specified by
    dokomoforms.options._arg (sys.argv if _arg is None, or the list of
    options in _arg otherwise).

    See dokomoforms.options.inject_options
    """
    tornado.options.parse_config_file(
        os.path.join(os.path.dirname(__file__), '..', 'config.py')
    )
    tornado.options.parse_command_line(_arg) 
开发者ID:SEL-Columbia,项目名称:dokomoforms,代码行数:16,代码来源:options.py


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