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


Python options.parse_command_line函数代码示例

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


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

示例1: main

def main():
    define("port", default=8000, help="run on the port", type=int)
    define("debug", default=False, help="run in debug mode", type=bool)
    options.parse_command_line()
    # =====
    global_scope = globals()
    handlers = []
    for key in global_scope:
        if key.endswith("_handlers"):
            handlers.extend(global_scope[key])

    # =====
    class Main(tornado.web.Application):
        def __init__(self, *args, **kwargs):
            super(Main, self).__init__(*args, **kwargs)
            self.config = config

        @property
        def db(self):
            return DbHelper()

    app = Main(
        handlers,
        cookie_secret="config.COOKIE_SECRET",
        login_url="/login",
        static_path=os.path.join(os.path.dirname(__file__), "static"),
        xsrf_cookies=True,
        debug=options.debug,
        gzip=True,
    )
    server = HTTPServer(app)
    server.listen(options.port)
    print "tornado launched!"
    IOLoop.current().start()
开发者ID:edwardw1987,项目名称:studys,代码行数:34,代码来源:main.py

示例2: run_app

def run_app():
    options.parse_command_line()

    # 1. Create sync router
    sync_router = sockjs.tornado.SockJSRouter(SyncConnection, '/sync')

    # 2. Create Tornado application
    app = Application(
        [
            (r'/', IndexHandler),
            (r'/(?P<pad_id>[0-9a-z\-]+)', PadHandler),
            (r'/static/(.*)', tornado.web.StaticFileHandler, {'path': STATIC_ROOT})
        ] + sync_router.urls,
        cookie_secret=options.cookie_secret,
        static_url_prefix='/static/',
        template_path=TEMPLATES_ROOT,
        pad_lifetime=options.pad_lifetime,
    )

    # 3. Make Tornado app listen on port 8080
    app.listen(options.port)
    logging.info("App started, visit http://localhost:%s" % options.port)
    logging.info("App started with options: %r" % options.as_dict())

    # 4. Start IOLoop
    tornado.ioloop.IOLoop.instance().start()
开发者ID:kulapard,项目名称:Gorinich,代码行数:26,代码来源:run.py

示例3: main

def main():
    print("starting web.py on port %s" % options.port)
    options.parse_command_line()
    application = _create_tornado_app()
    server = HTTPServer(application)
    server.listen(options.port)
    IOLoop.instance().start()
开发者ID:ymeng-think,项目名称:awayday-2012,代码行数:7,代码来源:web.py

示例4: main

def main() -> None:
    '''Runs server'''

    # Parse options
    define('production',
               default = False,
               help = 'run in production mode',
               type = bool)
    options.parse_command_line()

    # Set server name
    pname = settings.process_name if settings.process_name else None
    if pname:
        setproctitle(pname)

    # Register IRC server
    server = IRCServer(settings = ircdsettings)
    for address, port in ircdsettings['listen']:
        server.listen(port, address = address)

    # Start profiling
    if settings.profiling:
        import yappi
        yappi.start()

    # Setup autoreload
    autoreload.start()

    # Run application
    IOLoop.instance().start()
开发者ID:leandropls,项目名称:tornadoirc,代码行数:30,代码来源:server.py

示例5: run

def run():
    define('day', help="The base date",default=None)
    define('f', help="From date", default=None)
    define('t', help="To date", default=None)
    options.parse_command_line()
    
    bday = options.day and datetime.strptime(options.day, config.DATE_FORMAT) or datetime.today()
    fday = options.f and datetime.strptime(options.f, config.DATE_FORMAT) or 0
    tday = options.t and datetime.strptime(options.t, config.DATE_FORMAT) or 0
    redis_cli = get_redis_client()

  
    filters = dwarf.daux.Filter(redis_cli).expand(gender=1).overlap(regu=2)
    filters = filters.filter(dwarf.daux.Filter(redis_cli).expand(gender=2).overlap(regu=2))
    filters = None
    au = dwarf.daux.AUstat(bday, redis_cli, filters= filters)

    print "baseDay:", bday , "from:" , fday, "to:", tday

    # s = time.time()
    # print "dau:", au.get_dau(), time.time()-s
    # s = time.time()
    # print "dnu:", au.get_dnu(bday), time.time()-s
    # s = time.time()
    # print "listdau:", au.list_dau(fday=fday, tday=tday), time.time()-s
    s = time.time()
    print "listdnu:", au.list_dnu(fday=fday, tday=tday), time.time()-s
    # s = time.time()
    # print "mau:", au.mau(fday=fday, tday=tday), time.time()-s
    # s = time.time()
    # print "retained:" , au.get_month_retained(fday=fday, tday=tday), time.time()-s
    s = time.time()
    print "new user retained:", au.get_retained_nu(fday=fday, tday=tday), time.time()-s
开发者ID:Camelsky,项目名称:dwarf,代码行数:33,代码来源:au_test.py

示例6: main

def main():
	options.parse_command_line()
	# set up database connection
	client = pymongo.MongoClient(options.dbhost, options.dbport)
	database = client[options.dbname]
	# list of handlers
	handlers = []
	# generate list
	for handler in settings.handlers:
		# import the handler we need
		handler_class = __import__(handler)
		# register the URLS with the handler
		for routes in handler_class.routes:
			# each handler exports a urls list and class
			endpoint, class_name = routes
			url = ('/api' + endpoint, class_name, dict(database=database))
			# append to our handlers list
			handlers.append(url)

	ioloop = tornado.ioloop.IOLoop.instance()
	# register our handlers with our application and give it our settings
	application = tornado.web.Application(handlers, **settings.settings)
	http_server = tornado.httpserver.HTTPServer(application)
	# listen on port defined in options
	http_server.listen(options.port)
	#start ioloop
	ioloop.start()
开发者ID:mattgen88,项目名称:tornado-demo,代码行数:27,代码来源:app.py

示例7: run

def run():
    options.parse_command_line()
    http_server = HTTPServer(SiteApplication())
    http_server.listen(options.port)

    print "running on %s:%d" % (options.host, options.port)
    IOLoop.instance().start()
开发者ID:tuhuayuan,项目名称:gobangme,代码行数:7,代码来源:runserver.py

示例8: main

def main():
    define("port", default=Config.data['web']['port'], help="run on the given port", type=int)
    options.parse_command_line()
    logger.set_logger('web-{}.log'.format(options.port))
    http_server = tornado.httpserver.HTTPServer(Application())
    http_server.listen(options.port)
    tornado.ioloop.IOLoop.instance().start()
开发者ID:thomaserlang,项目名称:TLog,代码行数:7,代码来源:app.py

示例9: __init__

    def __init__(self, extra_handlers):
        '''Expects a list of tuple handlers like:
                [(r"/", MainHandler), (r"/chatsocket", ChatSocketHandler),]
        '''
        url = settings._server_str % (settings.PROTOCOL, settings.HOSTNAME, settings.AUTHSERVERPORT)

        app_settings = {
                "cookie_secret": settings.COOKIE_SECRET,
                "login_url": ''.join((url, "/login")),
                }

        handlers = []
        handlers.append((r"/version", VersionHandler))
        handlers.append((r"/source", SelfServe))
        handlers.append((r"/ping", PingHandler))
        handlers.append((r"/", PingHandler))

        handlers.extend(extra_handlers)

        options.parse_command_line()
        dburi = options.dburi

        # Connect to the elixir db
        setup(db_uri=dburi)

        Application.__init__(self, handlers, debug=True, **app_settings)
开发者ID:cnelsonsic,项目名称:SimpleMMO,代码行数:26,代码来源:baseserver.py

示例10: boreas

def boreas():
    from tornado.options import define, options    
    from boreas import server
    
    define("config", help="Configuration module", type=str)
    
    define("debug", default=True, help="Enable debugging urls", type=bool)
    define("api_port", default=8001, help="API port", type=int)
    define("api_host", default='127.0.0.1', help="API host", type=str)
    define("ws_port", default=8002, help="Websocket port", type=int)
    define("ws_host", default='127.0.0.1', help="Websocket host", type=str)
    define("token_provider", default='boreas.utils.tokens:no_tokens', help="Function providing initial tokens", type=str)
    define("require_auth", default=True, help="Flag indicating if user has to authenticate", type=bool)
    
    options.parse_command_line()
    
    if options.config is None:
        # assume boreas.conf in working directory
        conf_file = 'boreas.conf'
        try:
            options.parse_config_file(conf_file)
        except IOError:
            pass # just use defaults
    else:
        conf_file = options.config
        options.parse_config_file(conf_file)
    
    server.run(options)
开发者ID:Sigmapoint,项目名称:boreas,代码行数:28,代码来源:commands.py

示例11: main

def main():

    # Get the Port and Debug mode from command line options or default in settings.py
    options.parse_command_line()

    # logging.config.dictConfig(LOG_SETTINGS)
    logger = logging.getLogger("app")

    # Load ML Models
    logger.info("Loading IRIS Prediction Model...")
    MODELS["iris"] = load_model(os.path.join(MODEL_DIR, "iris", "model.pkl"))

    urls = [
        (r"/live$", handler.LiveHandler),
        (r"/api/iris/(?P<action>[a-zA-Z]+)?",
            handler.IrisPredictionHandler, { "model": MODELS["iris"]}),
    ]

    application = tornado.web.Application(
        urls,
        debug=options.debug,
        autoreload=options.debug)

    logger.info("Starting App on Port: {} with Debug Mode: {}".format(options.port, options.debug))
    application.listen(options.port)
    tornado.ioloop.IOLoop.current().start()
开发者ID:sampathweb,项目名称:ml-api-sample-app,代码行数:26,代码来源:server.py

示例12: main

def main():

    # Defines
    define("port", default=8082, help="run on the given port", type=int)
    define("log_level", default="INFO", type=str,
           help="[NOTSET, DEBUG, INFO, WARNING, ERROR, CRITICAL]")
    define("dbconf", default="sqlite:///vanzilla.db", type=str,
           help="sqlalchemy db config string")
    define("mail_server", default="localhost", help="server mail", type=str)
    define("mail_from", default="", help="sender address for mail error reports", type=str)
    define("mail_to", default="", help="recipient addresses for mail error reports", type=str)
    define("root_ips", default=[], help="IPs with global access", type=list)
    define("promiscuous_load", default=False,
           help="load all apps, whether they are enabled or not", type=bool)

    options.parse_config_file("vanzilla.conf")
    options.parse_command_line()
    logging.debug(options.logging)

    # Initalising applications
    apps = AppsLoader(options)

    # Starting tornado server
    http_server = tornado.httpserver.HTTPServer(apps)
    http_server.listen(options.port)
    ioloop = tornado.ioloop.IOLoop.instance()
    tornado.autoreload.add_reload_hook(apps.reload_tasks)
    tornado.autoreload.start(ioloop)
    ioloop.start()
开发者ID:jbchouinard,项目名称:vanzilla-open,代码行数:29,代码来源:main.py

示例13: main

def main():
    options.parse_command_line()
    app = Application()
    server = tornado.httpserver.HTTPServer(app, xheaders=True)
    server.bind(options.port)
    server.start()
    tornado.ioloop.IOLoop.current().start()
开发者ID:bitnic028,项目名称:EGRProduction,代码行数:7,代码来源:app.py

示例14: run_server

def run_server():
    parse_configure_file(options, define, join_path(__file__, './chat.conf'))
    options.parse_command_line()
    http_server = tornado.httpserver.HTTPServer(
        Application(), xheaders=options.xheaders)
    http_server.listen(options.port)
    tornado.ioloop.IOLoop.instance().start()
开发者ID:sajjadgolchin,项目名称:Chat-Room,代码行数:7,代码来源:app.py

示例15: main

def main():
    options.define("port", default="8888")
    options.define("watch", type=str, multiple=True, default=".",
                   help="watch file or directory")
    options.define("htdoc", type=str, default=".", help="root directory of HTML documents")
    options.define("command", type=str, multiple=True, metavar="COMMAND",
                   help="run COMMAND when file or directory is changed")
    options.parse_command_line()

    mypath = os.path.dirname(os.path.abspath(__file__))
    assets_path = os.path.join(mypath, 'assets')

    for f in options.watch:
        watcher.watch(f)

    watcher.add_hook(_run_cmd)
    watcher.start()

    application = tornado.web.Application([
        (r"/ws", WebSocketHandler),
        (r"/assets/(.*)", tornado.web.StaticFileHandler, {"path": assets_path}),
        (r"/(.*\.html)", MainHandler),
        (r"/(.*)", tornado.web.StaticFileHandler, {"path": options.htdoc}),
    ])
    application.listen(8888)

    logging.info('starting application')
    try:
        tornado.ioloop.IOLoop.instance().start()
    except KeyboardInterrupt:
        logging.info('bye')
开发者ID:zakkie,项目名称:sphinx-liveview,代码行数:31,代码来源:server.py


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