本文整理汇总了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()
示例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)
示例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
)
示例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()
示例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)
示例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'])
示例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'])
示例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)
示例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.")
示例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'])
示例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)
示例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()
示例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()
示例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)
示例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))