本文整理汇总了Python中tornado.options.parse_command_line函数的典型用法代码示例。如果您正苦于以下问题:Python parse_command_line函数的具体用法?Python parse_command_line怎么用?Python parse_command_line使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parse_command_line函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: main
def main(args=None):
if args is None:
args = sys.argv
options.define('root', default='.', help='document root')
options.define('proxy', default='', help='http proxy')
options.parse_command_line()
log.enable_pretty_logging()
main_loop = ioloop.IOLoop.instance()
pool = cf.ThreadPoolExecutor(max_workers=4)
application = web.Application([
(r'/(.*)', IndexHandler, {
'root': options.options.root,
'pool': pool,
'proxy': options.options.proxy,
}),
], debug=True)
application.listen(8000)
main_loop.start()
pool.shutdown()
main_loop.close()
return 0
开发者ID:legnaleurc,项目名称:autoindex,代码行数:30,代码来源:autoindex.py
示例2: main
def main():
""" Main. """
logging_level = logging.INFO
if hermes_constants.DEBUG:
logging_level = logging.DEBUG
logging.getLogger().setLevel(logging_level)
signal.signal(signal.SIGTERM, signal_handler)
signal.signal(signal.SIGINT, signal_handler)
parse_command_line()
app = tornado.web.Application([
(MainHandler.PATH, MainHandler),
(TaskHandler.PATH, TaskHandler),
], debug=False)
try:
app.listen(options.port)
except socket.error:
logging.error("ERROR on Hermes initialization: Port {0} already in use.".
format(options.port))
shutdown()
return
logging.info("Hermes is up and listening on port: {0}.".
format(options.port))
# Start loop for accepting http requests.
IOLoop.instance().start()
开发者ID:madytyoo,项目名称:appscale,代码行数:31,代码来源:hermes.py
示例3: main
def main():
parse_command_line()
app = tornado.web.Application(
[
(r"/", MainHandler),
(r"/control/action/on_off" , control_action_on_off ),
(r"/control/action/all" , control_action_all ),
(r"/control/action/roll" , control_action_roll ),
(r"/control/action/pitch" , control_action_pitch ),
(r"/control/action/throttle" , control_action_throttle ),
(r"/control/action/yaw" , control_action_yaw ),
(r"/control/action/fly_mode" , control_action_fly_mode ),
(r"/control/action/accessory_0" , control_action_accessory_0 ),
(r"/control/action/interrumpir" , control_action_interrumpir ),
(r"/control/action/reiniciar" , control_action_reiniciar ),
(r"/control/action/resetear_valores" , control_action_resetear_valores ),
(r"/websocket" , control_drone_socket )
],
cookie_secret="__TODO:_GENERATE_YOUR_OWN_RANDOM_VALUE_HERE__",
template_path=os.path.join(os.path.dirname(__file__), "templates"),
static_path=os.path.join(os.path.dirname(__file__), "static"),
xsrf_cookies=False,
debug=options.debug,
)
app.listen(options.port)
tornado.ioloop.IOLoop.current().start()
tornado.autoreload.wait()
开发者ID:DroneSimon,项目名称:drone_control,代码行数:33,代码来源:server.py
示例4: run_tornado
def run_tornado(addr, port, reload=False):
# Don't try to read the command line args from openslides
parse_command_line(args=[])
# Print listening address and port to command line
if addr == '0.0.0.0':
url_string = _("the machine's local ip address")
else:
url_string = 'http://%s:%s' % (addr, port)
print _("Starting OpenSlides' tornado webserver listening to %(url_string)s") % {'url_string': url_string}
socket_js_router = SockJSRouter(ProjectorSocketHandler, '/projector/socket')
# Start the application
app = WSGIContainer(Django_WSGIHandler())
tornado_app = Application(socket_js_router.urls + [
(r"%s(.*)" % settings.STATIC_URL, DjangoStaticFileHandler),
(r'%s(.*)' % settings.MEDIA_URL, StaticFileHandler, {'path': settings.MEDIA_ROOT}),
('.*', FallbackHandler, dict(fallback=app))
], debug=reload)
server = HTTPServer(tornado_app)
server.listen(port=port,
address=addr)
IOLoop.instance().start()
开发者ID:HengeSense,项目名称:OpenSlides,代码行数:25,代码来源:tornado_webserver.py
示例5: parse_configs
def parse_configs(config_files):
"""Reads command line options / config file and bootstraps logging.
"""
parse_command_line(final=False)
if options.config:
configs_to_read = options.config
else:
configs_to_read = config_files
configs_to_read = filter(
None, [configs_to_read] if not isinstance(configs_to_read, (list, tuple)) else configs_to_read
)
for config in configs_to_read:
parse_config_file(config, final=False)
# override options from config with command line options
parse_command_line(final=False)
bootstrap_core_logging()
for config in configs_to_read:
log.debug('using config: %s', config)
if options.autoreload:
tornado.autoreload.watch(config)
开发者ID:hhru,项目名称:frontik,代码行数:27,代码来源:server.py
示例6: main
def main():
options.logging = "warning"
parse_command_line()
for version in options.versions:
elapsed = yield benchmark(int(version))
print_result(version, elapsed)
开发者ID:bdarnell,项目名称:tornado_http2,代码行数:7,代码来源:benchmark.py
示例7: main
def main():
options.logging = None
parse_command_line()
options.subpath = options.subpath.strip('/')
if options.subpath:
options.subpath = '/' + options.subpath
# Connect to mongodb
io_loop = ioloop.IOLoop.instance()
connect(config.DB_NAME, host=config.DB_HOST, port=config.DB_PORT, io_loop=io_loop)
# username=config.DB_USER, password=config.DB_PWD)
# Star application
from application import app
if options.unix_socket:
server = tornado.httpserver.HTTPServer(app)
socket = tornado.netutil.bind_unix_socket(options.unix_socket, 0o666)
server.add_socket(socket)
print('Server is running at %s' % options.unix_socket)
print('Quit the server with Control-C')
else:
http_server = tornado.httpserver.HTTPServer(app)
http_server.listen(options.port)
print('Server is running at http://127.0.0.1:%s%s' % (options.port, options.subpath))
print('Quit the server with Control-C')
io_loop.start()
开发者ID:INAP-LABS,项目名称:noc-orchestrator,代码行数:29,代码来源:server.py
示例8: main
def main():
"""Test/Exercise ServerEnvironment on EC2 instance.
Initializes AMI Metadata and initializes ServerEnvironment object followed by output of results.
"""
query_ip = Metadata._QUERY_IP
options.parse_command_line()
def _OnInitSecrets():
ServerEnvironment.InitServerEnvironment()
if ServerEnvironment.IsDevBox():
print "IsDevBox environment"
if ServerEnvironment.IsStaging():
print "IsStaging environment"
else:
print "IsProduction environment"
ioloop.IOLoop.current().stop()
def _MetadataCallback(metadata):
SetAMIMetadata(metadata)
InitSecrets(_OnInitSecrets, False)
Metadata(callback=_MetadataCallback, query_ip=query_ip)
ioloop.IOLoop.current().start()
return 0
开发者ID:00zhengfu00,项目名称:viewfinder,代码行数:27,代码来源:environ.py
示例9: main
def main():
parse_command_line()
http_server = tornado.httpserver.HTTPServer(Application())
http_server.listen(options.port)
ioloop = tornado.ioloop.IOLoop().instance()
autoreload.start(ioloop)
ioloop.start()
开发者ID:ErDmKo,项目名称:pyparser,代码行数:7,代码来源:server.py
示例10: run
def run(start_callback, stop_callback=None, **kwargs):
options.parse_command_line()
io_loop = ioloop.IOLoop.current()
def _on_signal(signum, frame):
try:
stop_callback()
except:
io_loop.stop()
signal.signal(signal.SIGHUP, _on_signal)
signal.signal(signal.SIGINT, _on_signal)
signal.signal(signal.SIGQUIT, _on_signal)
signal.signal(signal.SIGTERM, _on_signal)
@gen.coroutine
def _invoke_callback(wrapped_callback, **stts):
yield gen.Task(wrapped_callback, **stts)
shutdown_by_exception = False
try:
level = logging.DEBUG if options.options.debug else logging.INFO
logging.getLogger().setLevel(level)
logging.getLogger().handlers[0].setLevel(level)
io_loop.run_sync(partial(_initializer, **kwargs))
io_loop.run_sync(partial(_invoke_callback, start_callback))
if stop_callback is not None:
func = partial(_invoke_callback, stop_callback)
io_loop.run_sync(func)
except ioloop.TimeoutError:
pass
except Exception, e:
shutdown_by_exception = True
logging.error('Unhandled exception in %s' % sys.argv[0])
logging.error('Error: %s' % e)
开发者ID:alejandrobernardis,项目名称:heroku-tornado,代码行数:35,代码来源:main.py
示例11: main
def main():
parse_command_line()
application.listen(options.port)
try:
tornado.ioloop.IOLoop.instance().start()
except KeyboardInterrupt:
print "bye!"
开发者ID:zakandrewking,项目名称:theseus,代码行数:7,代码来源:server.py
示例12: main
def main():
parse_command_line()
enable_pretty_logging()
wsgi_app = wsgi.WSGIContainer(django.core.handlers.wsgi.WSGIHandler())
staticpath = [
_HERE + "/static/",
_HERE + "/deb/",
"/usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/",
"/usr/local/lib/python2.7/dist-packages/django_admin_bootstrapped/static/",
"/usr/local/lib/python2.7/dist-packages/bootstrap_markdown/static/",
]
mapping = [
(r"/(favicon.ico)", web.StaticFileHandler, {"path": _HERE + "/static"}),
(r"/static/(.*)", MultiStaticFileHandler, {"paths": staticpath}),
(r"/deb/(.*)", MultiStaticFileHandler, {"paths": staticpath}),
(".*", web.FallbackHandler, dict(fallback=wsgi_app)),
]
tornado_app = web.Application(mapping, debug=True)
server = httpserver.HTTPServer(tornado_app)
server.listen(options.port)
print "http://{}:{}".format(LOCALIP, options.port)
try:
ioloop.IOLoop.instance().start()
except KeyboardInterrupt:
ioloop.IOLoop.instance().stop()
print "Finished"
开发者ID:henrywoo,项目名称:qblog,代码行数:26,代码来源:tornado_django.py
示例13: main
def main():
options.define('port', default=9005,
help="Port for the REST API"
)
options.define('ip', default='127.0.0.1',
help="IP address for the REST API"
)
options.define('host_mount', default='',
help='Path where the host root is mounted in this container'
)
options.define('pool_prefix', default='',
help='Prefix assigned by tmpnb to its pooled containers'
)
options.define('registration_key', default='',
help='Registration key required to create new volumes'
)
options.parse_command_line()
opts = options.options
# regex from docker volume create
api_handlers = [
(r'/api/mounts(/([a-zA-Z0-9][a-zA-Z0-9_.-])+)?', MountsHandler),
(r'/api/volumes', VolumesHander),
]
api_app = web.Application(api_handlers)
api_app.listen(opts.port, opts.ip, xheaders=True)
app_log.info("Listening on {}:{}".format(opts.ip, opts.port))
ioloop.IOLoop.instance().start()
开发者ID:data-exp-lab,项目名称:mostly-tmpnb,代码行数:31,代码来源:main.py
示例14: main
def main():
parse_command_line()
loop = tornado.ioloop.IOLoop.current()
app = make_app(make_handlers(loop, options), get_app_settings(options))
app.listen(options.port, options.address)
logging.info('Listening on {}:{}'.format(options.address, options.port))
loop.start()
开发者ID:wyl316430,项目名称:webssh,代码行数:7,代码来源:main.py
示例15: main
def main():
"""""
Start up the server and register the necessary handlers and web socket
interfaces.
"""
# Register the handlers and web socket interfaces
server = tornado.web.Application(
[
(r"/", HomeHandler),
(r"/java/", JavaHandler),
(r"/python/", PythonHandler),
(r"/javafuntime", JavaWebsocket),
(r"/pythonfuntime", PythonWebSocket)
],
title="LaHacks Server",
template_path=os.path.join(os.path.dirname(__file__), "templates"),
static_path=os.path.join(os.path.dirname(__file__), "static"),
login_url="/",
cookie_secret="sooper secure, obviously",
debug=True
)
# Starts the tornado server
parse_command_line()
server.listen(options.port)
tornado.ioloop.IOLoop.instance().start()
开发者ID:jano017,项目名称:LaHacks,代码行数:26,代码来源:main.py
示例16: main
def main():
# options
parse_command_line()
# Locale
load_gettext_translations(settings.I18N_PATH, "luoyun")
set_default_locale('zh_CN')
logging.info("starting torando web server")
if settings.IPV4_ONLY:
import socket
sockets = bind_sockets(options.port, family=socket.AF_INET)
else:
sockets = bind_sockets(options.port)
if not settings.DEBUG:
import tornado.process
tornado.process.fork_processes(0)
application = Application()
server = HTTPServer(application, xheaders=True)
server.add_sockets(sockets)
IOLoop.instance().start()
开发者ID:hominlinx,项目名称:LuoYunCloud,代码行数:25,代码来源:site.py
示例17: run_tornado
def run_tornado(addr, port, *args, **kwargs):
"""
Starts the tornado webserver as wsgi server for OpenSlides.
It runs in one thread.
"""
# Save the port and the addr in a global var
global RUNNING_HOST, RUNNING_PORT
RUNNING_HOST = addr
RUNNING_PORT = port
# Don't try to read the command line args from openslides
parse_command_line(args=[])
# Setup WSGIContainer
app = WSGIContainer(get_wsgi_application())
# Collect urls
sock_js_router = SockJSRouter(OpenSlidesSockJSConnection, '/sockjs')
other_urls = [
(r'%s(.*)' % settings.STATIC_URL, DjangoStaticFileHandler),
(r'%s(.*)' % settings.MEDIA_URL, StaticFileHandler, {'path': settings.MEDIA_ROOT}),
('.*', FallbackHandler, dict(fallback=app))]
# Start the application
debug = settings.DEBUG
tornado_app = Application(sock_js_router.urls + other_urls, autoreload=debug, debug=debug)
server = HTTPServer(tornado_app)
server.listen(port=port, address=addr)
IOLoop.instance().start()
# Reset the global vars
RUNNING_HOST = None
RUNNING_PORT = None
开发者ID:chyka-dev,项目名称:OpenSlides,代码行数:34,代码来源:autoupdate.py
示例18: run_tornado
def run_tornado(addr, port):
# Don't try to read the command line args from openslides
parse_command_line(args=[])
# Print listening address and port to command line
if addr == '0.0.0.0':
url_string = "the machine's local ip address"
else:
url_string = 'http://%s:%s' % (addr, port)
# TODO: don't use print, use django logging
print("Starting OpenSlides' tornado webserver listening to %(url_string)s" % {'url_string': url_string})
# Setup WSGIContainer
app = WSGIContainer(get_wsgi_application())
# Collect urls
projectpr_socket_js_router = SockJSRouter(ProjectorSocketHandler, '/projector/socket')
from openslides.core.chatbox import ChatboxSocketHandler
chatbox_socket_js_router = SockJSRouter(ChatboxSocketHandler, '/core/chatbox')
other_urls = [
(r"%s(.*)" % settings.STATIC_URL, DjangoStaticFileHandler),
(r'%s(.*)' % settings.MEDIA_URL, StaticFileHandler, {'path': settings.MEDIA_ROOT}),
('.*', FallbackHandler, dict(fallback=app))]
# Start the application
debug = settings.DEBUG
tornado_app = Application(projectpr_socket_js_router.urls + chatbox_socket_js_router.urls + other_urls, debug=debug)
server = HTTPServer(tornado_app)
server.listen(port=port, address=addr)
IOLoop.instance().start()
开发者ID:patrickhanft,项目名称:OpenSlides,代码行数:30,代码来源:tornado_webserver.py
示例19: main
def main():
parse_command_line()
app=tornado.web.Application(
[(r'/',SearchPage),(r'/s',SearchResult)],
)
app.listen(options.port)
tornado.ioloop.IOLoop.instance().start()
开发者ID:ytf513,项目名称:simple_addressbook,代码行数:7,代码来源:address-20141224.py
示例20: main
def main():
options.parse_command_line()
http_server = httpserver.HTTPServer(application)
http_server.listen(options.port)
print 'Development server is running at http://127.0.0.1:%s/' % options.port
print 'Quit the server with Control-C'
ioloop.IOLoop.instance().start()
开发者ID:tanghanzxp,项目名称:Picture_Database,代码行数:7,代码来源:server.py
注:本文中的tornado.options.parse_command_line函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论