當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。