當前位置: 首頁>>代碼示例>>Python>>正文


Python options.parse_command_line方法代碼示例

本文整理匯總了Python中tornado.options.options.parse_command_line方法的典型用法代碼示例。如果您正苦於以下問題:Python options.parse_command_line方法的具體用法?Python options.parse_command_line怎麽用?Python options.parse_command_line使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在tornado.options.options的用法示例。


在下文中一共展示了options.parse_command_line方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: group_dict

# 需要導入模塊: from tornado.options import options [as 別名]
# 或者: from tornado.options.options import parse_command_line [as 別名]
def group_dict(self, group):
        """The names and values of options in a group.

        Useful for copying options into Application settings::

            from tornado.options import define, parse_command_line, options

            define('template_path', group='application')
            define('static_path', group='application')

            parse_command_line()

            application = Application(
                handlers, **options.group_dict('application'))

        .. versionadded:: 3.1
        """
        return dict(
            (opt.name, opt.value()) for name, opt in self._options.items()
            if not group or group == opt.group_name) 
開發者ID:tao12345666333,項目名稱:tornado-zh,代碼行數:22,代碼來源:options.py

示例2: group_dict

# 需要導入模塊: from tornado.options import options [as 別名]
# 或者: from tornado.options.options import parse_command_line [as 別名]
def group_dict(self, group: str) -> Dict[str, Any]:
        """The names and values of options in a group.

        Useful for copying options into Application settings::

            from tornado.options import define, parse_command_line, options

            define('template_path', group='application')
            define('static_path', group='application')

            parse_command_line()

            application = Application(
                handlers, **options.group_dict('application'))

        .. versionadded:: 3.1
        """
        return dict(
            (opt.name, opt.value())
            for name, opt in self._options.items()
            if not group or group == opt.group_name
        ) 
開發者ID:opendevops-cn,項目名稱:opendevops,代碼行數:24,代碼來源:options.py

示例3: group_dict

# 需要導入模塊: from tornado.options import options [as 別名]
# 或者: from tornado.options.options import parse_command_line [as 別名]
def group_dict(self, group):
        """The names and values of options in a group.

        Useful for copying options into Application settings::

            from tornado.options import define, parse_command_line, options

            define('template_path', group='application')
            define('static_path', group='application')

            parse_command_line()

            application = Application(
                handlers, **options.group_dict('application'))

        .. versionadded:: 3.1
        """
        return dict(
            (name, opt.value()) for name, opt in self._options.items()
            if not group or group == opt.group_name) 
開發者ID:viewfinderco,項目名稱:viewfinder,代碼行數:22,代碼來源:options.py

示例4: parse_command_line

# 需要導入模塊: from tornado.options import options [as 別名]
# 或者: from tornado.options.options import parse_command_line [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

示例5: parse_command_line

# 需要導入模塊: from tornado.options import options [as 別名]
# 或者: from tornado.options.options import parse_command_line [as 別名]
def parse_command_line(args=None, final=True):
    """Parses global options from the command line.

    See `OptionParser.parse_command_line`.
    """
    return options.parse_command_line(args, final=final) 
開發者ID:tao12345666333,項目名稱:tornado-zh,代碼行數:8,代碼來源:options.py

示例6: parse_options

# 需要導入模塊: from tornado.options import options [as 別名]
# 或者: from tornado.options.options import parse_command_line [as 別名]
def parse_options():
    define("host", default=server.DEFAULT_HOST, help="Server run on the given host", type=str)
    define("port", default=server.DEFAULT_PORT, help="Server run on the given port", type=int)
    define("rpc_host", default=rpc.DEFAULT_RPC_HOST, help="RPC Server run on the given host", type=str)
    define("rpc_port", default=rpc.DEFAULT_RPC_PORT, help="RPC Server run on the given port", type=int)

    define("debug", default=server.DEBUG_MODE, help="Debug mode")
    define("database", default=settings.DEFAULT_DATABASE, help="Debug mode")

    options.parse_command_line()
    return options 
開發者ID:LTD-Beget,項目名稱:sprutio,代碼行數:13,代碼來源:console.py

示例7: parse_command_line

# 需要導入模塊: from tornado.options import options [as 別名]
# 或者: from tornado.options.options import parse_command_line [as 別名]
def parse_command_line(args: List[str] = None, final: bool = True) -> List[str]:
    """Parses global options from the command line.

    See `OptionParser.parse_command_line`.
    """
    return options.parse_command_line(args, final=final) 
開發者ID:opendevops-cn,項目名稱:opendevops,代碼行數:8,代碼來源:options.py

示例8: main

# 需要導入模塊: from tornado.options import options [as 別名]
# 或者: from tornado.options.options import parse_command_line [as 別名]
def main():
    options.parse_command_line()
    check_encoding_setting(options.encoding)
    loop = tornado.ioloop.IOLoop.current()
    app = make_app(make_handlers(loop, options), get_app_settings(options))
    ssl_ctx = get_ssl_context(options)
    server_settings = get_server_settings(options)
    app_listen(app, options.port, options.address, server_settings)
    if ssl_ctx:
        server_settings.update(ssl_options=ssl_ctx)
        app_listen(app, options.sslport, options.ssladdress, server_settings)
    loop.start() 
開發者ID:huashengdun,項目名稱:webssh,代碼行數:14,代碼來源:main.py

示例9: parse_command_line

# 需要導入模塊: from tornado.options import options [as 別名]
# 或者: from tornado.options.options import parse_command_line [as 別名]
def parse_command_line(self, args=None):
        if args is None:
            args = sys.argv
        remaining = []
        for i in xrange(1, len(args)):
            # All things after the last option are command line arguments
            if not args[i].startswith("-"):
                remaining = args[i:]
                break
            if args[i] == "--":
                remaining = args[i + 1:]
                break
            arg = args[i].lstrip("-")
            name, equals, value = arg.partition("=")
            name = name.replace('-', '_')
            if not name in self:
                print_help()
                raise Error('Unrecognized command line option: %r' % name)
            option = self[name]
            if not equals:
                if option.type == bool:
                    value = "true"
                else:
                    raise Error('Option %r requires a value' % name)
            option.parse(value)
        if self.help:
            print_help()
            sys.exit(0)

        # Set up log level and pretty console logging by default
        if self.logging != 'none':
            logging.getLogger().setLevel(getattr(logging, self.logging.upper()))
            enable_pretty_logging()

        return remaining 
開發者ID:omererdem,項目名稱:honeything,代碼行數:37,代碼來源:options.py

示例10: define

# 需要導入模塊: from tornado.options import options [as 別名]
# 或者: from tornado.options.options import parse_command_line [as 別名]
def define(name, default=None, type=None, help=None, metavar=None,
           multiple=False, group=None):
    """Defines a new command line option.

    If type is given (one of str, float, int, datetime, or timedelta)
    or can be inferred from the default, we parse the command line
    arguments based on the given type. If multiple is True, we accept
    comma-separated values, and the option value is always a list.

    For multi-value integers, we also accept the syntax x:y, which
    turns into range(x, y) - very useful for long integer ranges.

    help and metavar are used to construct the automatically generated
    command line help string. The help message is formatted like::

       --name=METAVAR      help string

    group is used to group the defined options in logical groups. By default,
    command line options are grouped by the defined file.

    Command line option names must be unique globally. They can be parsed
    from the command line with parse_command_line() or parsed from a
    config file with parse_config_file.
    """
    return options.define(name, default=default, type=type, help=help,
                          metavar=metavar, multiple=multiple, group=group) 
開發者ID:omererdem,項目名稱:honeything,代碼行數:28,代碼來源:options.py

示例11: enable_pretty_logging

# 需要導入模塊: from tornado.options import options [as 別名]
# 或者: from tornado.options.options import parse_command_line [as 別名]
def enable_pretty_logging(options=options):
    """Turns on formatted logging output as configured.

    This is called automatically by `parse_command_line`.
    """
    root_logger = logging.getLogger()
    if options.log_file_prefix:
        channel = logging.handlers.RotatingFileHandler(
            filename=options.log_file_prefix,
            maxBytes=options.log_file_max_size,
            backupCount=options.log_file_num_backups)
        channel.setFormatter(_LogFormatter(color=False))
        root_logger.addHandler(channel)

    if (options.log_to_stderr or
        (options.log_to_stderr is None and not root_logger.handlers)):
        # Set up color if we are in a tty and curses is installed
        color = False
        if curses and sys.stderr.isatty():
            try:
                curses.setupterm()
                if curses.tigetnum("colors") > 0:
                    color = True
            except Exception:
                pass
        channel = logging.StreamHandler()
        channel.setFormatter(_LogFormatter(color=color))
        root_logger.addHandler(channel) 
開發者ID:omererdem,項目名稱:honeything,代碼行數:30,代碼來源:options.py

示例12: main

# 需要導入模塊: from tornado.options import options [as 別名]
# 或者: from tornado.options.options import parse_command_line [as 別名]
def main():
    options.parse_command_line()
    loop = tornado.ioloop.IOLoop.current()
    app = make_app(make_handlers(loop, options), get_app_settings(options))
    ssl_ctx = get_ssl_context(options)
    server_settings = get_server_settings(options)
    app_listen(app, options.port, options.address, server_settings)
    if ssl_ctx:
        server_settings.update(ssl_options=ssl_ctx)
        app_listen(app, options.sslport, options.ssladdress, server_settings)
    loop.start() 
開發者ID:guohongze,項目名稱:adminset,代碼行數:13,代碼來源:main.py

示例13: start

# 需要導入模塊: from tornado.options import options [as 別名]
# 或者: from tornado.options.options import parse_command_line [as 別名]
def start(cap):
    """啟動服務器"""
    options.parse_command_line()
    server = EchoServer(cap)
    server.listen(options.port)
    logger.info("Listening on TCP port %d", options.port)
    IOLoop.current().start() 
開發者ID:PyQt5,項目名稱:PyQt,代碼行數:9,代碼來源:server.py


注:本文中的tornado.options.options.parse_command_line方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。