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


Python options.parse_command_line方法代码示例

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


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

示例1: main

# 需要导入模块: from tornado import options [as 别名]
# 或者: from tornado.options import parse_command_line [as 别名]
def main():
    from tornado.options import define, options, parse_command_line
    define("print_headers", type=bool, default=False)
    define("print_body", type=bool, default=True)
    define("follow_redirects", type=bool, default=True)
    define("validate_cert", type=bool, default=True)
    args = parse_command_line()
    client = HTTPClient()
    for arg in args:
        try:
            response = client.fetch(arg,
                                    follow_redirects=options.follow_redirects,
                                    validate_cert=options.validate_cert,
                                    )
        except HTTPError as e:
            if e.response is not None:
                response = e.response
            else:
                raise
        if options.print_headers:
            print(response.headers)
        if options.print_body:
            print(native_str(response.body))
    client.close() 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:26,代码来源:httpclient.py

示例2: group_dict

# 需要导入模块: from tornado import options [as 别名]
# 或者: from tornado.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

示例3: group_dict

# 需要导入模块: from tornado import options [as 别名]
# 或者: from tornado.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

示例4: main

# 需要导入模块: from tornado import options [as 别名]
# 或者: from tornado.options import parse_command_line [as 别名]
def main():
    from tornado.options import define, options, parse_command_line
    define("print_headers", type=bool, default=False)
    define("print_body", type=bool, default=True)
    define("follow_redirects", type=bool, default=True)
    define("validate_cert", type=bool, default=True)
    args = parse_command_line()
    client = HTTPClient()
    for arg in args:
        try:
            response = client.fetch(arg,
                                    follow_redirects=options.follow_redirects,
                                    validate_cert=options.validate_cert,
                                    )
        except HTTPError as e:
            if e.response is not None:
                response = e.response
            else:
                raise
        if options.print_headers:
            print(response.headers)
        if options.print_body:
            print(response.body)
    client.close() 
开发者ID:viewfinderco,项目名称:viewfinder,代码行数:26,代码来源:httpclient.py

示例5: group_dict

# 需要导入模块: from tornado import options [as 别名]
# 或者: from tornado.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

示例6: __init__

# 需要导入模块: from tornado import options [as 别名]
# 或者: from tornado.options import parse_command_line [as 别名]
def __init__(self, predictors, batch_size=5, debug_charts=False, worker_id=None, neptune_client=None):
        """ :param predictors: a list of OnlinePredictor"""
        assert len(predictors)
        for k in predictors:
            #assert isinstance(k, OnlinePredictor), type(k)
            # TODO use predictors.return_input here
            assert k.return_input == False
            #queue_size=len(predictors)*100
            queue_size=len(predictors)*1
        self.input_queue = queue.Queue(maxsize=queue_size)
        self.threads = [
            PredictorWorkerThread(
                self.input_queue, f, id, batch_size=batch_size,
                debug_charts=debug_charts,
                worker_id=worker_id,
                neptune_client=neptune_client)
            for id, f in enumerate(predictors)]

        if six.PY2:
            # TODO XXX set logging here to avoid affecting TF logging
            import tornado.options as options
            options.parse_command_line(['--logging=debug']) 
开发者ID:anonymous-author1,项目名称:DDRL,代码行数:24,代码来源:concurrency.py

示例7: __init__

# 需要导入模块: from tornado import options [as 别名]
# 或者: from tornado.options import parse_command_line [as 别名]
def __init__(self, predictors, batch_size=5):
        """ :param predictors: a list of OnlinePredictor"""
        for k in predictors:
            #assert isinstance(k, OnlinePredictor), type(k)
            # TODO use predictors.return_input here
            assert k.return_input == False
        self.input_queue = queue.Queue(maxsize=len(predictors)*100)
        self.threads = [
            PredictorWorkerThread(
                self.input_queue, f, id, batch_size=batch_size)
            for id, f in enumerate(predictors)]

        if six.PY2:
            # TODO XXX set logging here to avoid affecting TF logging
            import tornado.options as options
            options.parse_command_line(['--logging=debug']) 
开发者ID:mihahauke,项目名称:VDAIC2017,代码行数:18,代码来源:concurrency.py

示例8: main

# 需要导入模块: from tornado import options [as 别名]
# 或者: from tornado.options import parse_command_line [as 别名]
def main():
    from tornado.options import define, options, parse_command_line
    define("print_headers", type=bool, default=False)
    define("print_body", type=bool, default=True)
    define("follow_redirects", type=bool, default=True)
    define("validate_cert", type=bool, default=True)
    args = parse_command_line()
    client = HTTPClient()
    for arg in args:
        try:
            response = client.fetch(arg,
                                    follow_redirects=options.follow_redirects,
                                    validate_cert=options.validate_cert,
                                    )
        except HTTPError, e:
            if e.response is not None:
                response = e.response
            else:
                raise
        if options.print_headers:
            #print response.headers
            ht.logger.info(response.headers)
        if options.print_body:
            #print response.body
            ht.logger.info(response.body) 
开发者ID:omererdem,项目名称:honeything,代码行数:27,代码来源:httpclient.py

示例9: __init__

# 需要导入模块: from tornado import options [as 别名]
# 或者: from tornado.options import parse_command_line [as 别名]
def __init__(self, predictors, batch_size=5):
        """
        Args:
            predictors (list): a list of OnlinePredictor available to use.
            batch_size (int): the maximum of an internal batch.
        """
        assert len(predictors)
        self._need_default_sess = False
        for k in predictors:
            assert isinstance(k, OnlinePredictor), type(k)
            if k.sess is None:
                self._need_default_sess = True
            # TODO support predictors.return_input here
            assert not k.return_input
        self.input_queue = queue.Queue(maxsize=len(predictors) * 100)
        self.threads = [
            PredictorWorkerThread(
                self.input_queue, f, id, batch_size=batch_size)
            for id, f in enumerate(predictors)]

        if six.PY2:
            # TODO XXX set logging here to avoid affecting TF logging
            import tornado.options as options
            options.parse_command_line(['--logging=debug'])
            logger.warn("MultiThreadAsyncPredictor is inefficient in Python 2! Switch to Python 3 instead.") 
开发者ID:microsoft,项目名称:petridishnn,代码行数:27,代码来源:concurrency.py

示例10: __init__

# 需要导入模块: from tornado import options [as 别名]
# 或者: from tornado.options import parse_command_line [as 别名]
def __init__(self, predictors, batch_size=5):
        """ :param predictors: a list of OnlinePredictor"""
        assert len(predictors)
        for k in predictors:
            #assert isinstance(k, OnlinePredictor), type(k)
            # TODO use predictors.return_input here
            assert k.return_input == False
        self.input_queue = queue.Queue(maxsize=len(predictors)*100)
        self.threads = [
            PredictorWorkerThread(
                self.input_queue, f, id, batch_size=batch_size)
            for id, f in enumerate(predictors)]

        if six.PY2:
            # TODO XXX set logging here to avoid affecting TF logging
            import tornado.options as options
            options.parse_command_line(['--logging=debug']) 
开发者ID:czhu95,项目名称:ternarynet,代码行数:19,代码来源:concurrency.py

示例11: parse_command_line

# 需要导入模块: from tornado import options [as 别名]
# 或者: from tornado.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

示例12: main

# 需要导入模块: from tornado import options [as 别名]
# 或者: from tornado.options import parse_command_line [as 别名]
def main():
    args = parse_command_line()

    if not args:
        args = ['localhost', 'www.google.com',
                'www.facebook.com', 'www.dropbox.com']

    resolvers = [Resolver(), ThreadedResolver()]

    if twisted is not None:
        from tornado.platform.twisted import TwistedResolver
        resolvers.append(TwistedResolver())

    if pycares is not None:
        from tornado.platform.caresresolver import CaresResolver
        resolvers.append(CaresResolver())

    family = {
        'unspec': socket.AF_UNSPEC,
        'inet': socket.AF_INET,
        'inet6': socket.AF_INET6,
        }[options.family]

    for host in args:
        print('Resolving %s' % host)
        for resolver in resolvers:
            addrinfo = yield resolver.resolve(host, 80, family)
            print('%s: %s' % (resolver.__class__.__name__,
                              pprint.pformat(addrinfo)))
        print() 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:32,代码来源:test_resolvers.py

示例13: main

# 需要导入模块: from tornado import options [as 别名]
# 或者: from tornado.options import parse_command_line [as 别名]
def main() -> None:
    from tornado.options import define, options, parse_command_line

    define("print_headers", type=bool, default=False)
    define("print_body", type=bool, default=True)
    define("follow_redirects", type=bool, default=True)
    define("validate_cert", type=bool, default=True)
    define("proxy_host", type=str)
    define("proxy_port", type=int)
    args = parse_command_line()
    client = HTTPClient()
    for arg in args:
        try:
            response = client.fetch(
                arg,
                follow_redirects=options.follow_redirects,
                validate_cert=options.validate_cert,
                proxy_host=options.proxy_host,
                proxy_port=options.proxy_port,
            )
        except HTTPError as e:
            if e.response is not None:
                response = e.response
            else:
                raise
        if options.print_headers:
            print(response.headers)
        if options.print_body:
            print(native_str(response.body))
    client.close() 
开发者ID:opendevops-cn,项目名称:opendevops,代码行数:32,代码来源:httpclient.py

示例14: parse_command_line

# 需要导入模块: from tornado import options [as 别名]
# 或者: from tornado.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

示例15: main

# 需要导入模块: from tornado import options [as 别名]
# 或者: from tornado.options import parse_command_line [as 别名]
def main():
  args = parse_command_line()

  for arg in args:
    for dirpath, dirnames, filenames in os.walk(arg):
      for filename in filenames:
        if filename.lower().endswith('.jpg'):
          qualname = os.path.join(dirpath, filename)
          assert '\t' not in qualname
          fp = FingerprintImage(qualname)
          print '%s\t%s' % (qualname, format_fp(fp)) 
开发者ID:viewfinderco,项目名称:viewfinder,代码行数:13,代码来源:fingerprint_directory.py


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