Python tornado.options.options.config() Examples

The following are 2 code examples of tornado.options.options.config(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module tornado.options.options , or try the search function .
Example #1
Source File: helpers.py    From pyaiot with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
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() 
Example #2
Source File: run.py    From cookiecutter-tornado with GNU General Public License v3.0 5 votes vote down vote up
def main():
    parse_command_line()
    if options.config:
        parse_config_file(options.config)
    app = MainApplication()
    app.listen(options.port)
    tornado.ioloop.IOLoop.current().start()