• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python options.parse_command_line函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tornado.options.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():
    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


示例16: main

def main():

    global NODES_DATABASE

    ###--log_file_prefix=./server.log
    ###--logging=debug
    enable_pretty_logging()
    options.parse_command_line()

    cur_dir = os.path.split(os.path.realpath(__file__))[0]

    if options.mode == 'online':
        fetch_node_info()
    else:
        db_file_path = '%s/nodes_db_lean.json' % cur_dir

        if not os.path.exists(db_file_path):
            fetch_node_info()
        else:
            NODES_DATABASE = json.load(open(db_file_path))
            gen_log.info('load nodes database from json done!')
            gen_log.debug(NODES_DATABASE)


    app = myApplication()
    http_server = HTTPServer(app)
    http_server.listen(8080)


    tcp_server = DeviceServer()
    tcp_server.listen(8000)

    gen_log.info("server's running in lean mode ...")

    ioloop.IOLoop.current().start()
开发者ID:scitechindia,项目名称:Wio_Link,代码行数:35,代码来源:server_lean.py


示例17: main

def main():
    server_path   = path.dirname(__file__)
    template_path = path.join(server_path, 'templates')
    static_path   = path.normpath(path.join(server_path, '..', 'client'))
    
    settings = {
                  'static_path': static_path,
                'template_path': template_path,
                 'xsrf_cookies': False, # TODO: Enable
                    'login_url': '/',
                           'db': motor.MotorClient().chessrank,
                }

    app_settings = load_app_settings()
    settings.update(app_settings)

    handlers = [
                (r'/api/tournaments(?:/([0-9a-fA-F]{24}))?.*', TournamentHandler),
                (r'/api/sections(?:/([0-9a-fA-F]{24}))?.*', SectionHandler),
                (r'/api/players(?:/([0-9a-fA-F]{24}))?.*', PlayerHandler),
                (r'/api/users(?:/([0-9a-fA-F]{24}))?.*', UserHandler),
                (r'/api/session', SessionHandler),
                (r'/api/lookups', LookupsHandler),
                (r'/api.*', ApiHandler),
                (r'/verify/(.+)', VerifyPageHandler),
                (r'/', IndexPageHandler)
               ]

    options.parse_command_line()
    app = CustomApp(handlers, 'localhost', **settings)
    app.listen(options.port)
    IOLoop.instance().start()
开发者ID:rmoritz,项目名称:chessrank,代码行数:32,代码来源:main.py


示例18: start_with_options

    def start_with_options(self):
        """
        从命令行参数启动
        """
        from tornado.options import options, define

        define("includes", default="", help="specify tasks and tickers to run")
        define("excludes", default="", help="specify tasks and tickers not to run")
        options.parse_command_line()
        tasks = {}
        tickers = []
        if options.includes:
            tps = options.includes.split(",")
            for tp in tps:
                pair = tp.split(":")
                if len(pair) == 2:
                    tasks[pair[0]] = int(pair[1])
                else:
                    tickers.append(pair[0])
            tasks[IdleTask.name] = 1
        else:
            tasks = {name: num for name, (task_cls, num, standalone) in self.tasks_cls.items() if not standalone}
            tickers = self.all_tickers.keys()
        if options.excludes:
            tps = options.excludes.split(",")
            for tp in tps:
                tasks.pop(tp, None)
                if tp in tickers:
                    tickers.remove(tp)
        self.start_all(tasks, tickers)
开发者ID:pyloque,项目名称:cotask,代码行数:30,代码来源:cotask.py


示例19: main

def main():
    options.parse_command_line()
    App().listen(options.port, options.host, xheaders=True)
    print "VANELLOPE running on %s:%d" % (options.host, options.port)
    schedule = ioloop.PeriodicCallback(scan_session_store, 1000 * 5)
    schedule.start()
    ioloop.IOLoop.instance().start()
开发者ID:qar,项目名称:vanellope,代码行数:7,代码来源:app.py


示例20: parse_options

def parse_options(args, err_func):
    define('ports', multiple=True, type=int, help='listen ports (one or more)', metavar='PORT[,PORT,...]',
           default=[8001])
    define('config', type=str, help='zaglushka config path')
    define('watch', type=bool, help='watch config and stubs for changes', default=True)

    from tornado.options import options
    options.logging = 'debug'
    enable_pretty_logging(options)
    script_name = args[0]
    simple_args = list(takewhile(lambda i: not i.startswith('--'), args[1:]))
    other_args = args[len(simple_args) + 1:]
    other_args.insert(0, script_name)
    if simple_args:
        if len(simple_args) > 2:
            err_func('More than two simple args')
            return None
        elif len(simple_args) == 2:
            config, ports = simple_args
        else:
            config = simple_args[0]
            ports = None
        options.config = config
        if ports:
            ports = (i.strip() for i in ports.split(','))
            try:
                ports = map(int, ports)
            except (TypeError, ValueError):
                err_func('Wrong port value')
                return None
            options.ports = ports

    options.logging = 'debug'
    options.parse_command_line(args=other_args)
    return options
开发者ID:maizy,项目名称:zaglushka,代码行数:35,代码来源:zaglushka.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python options.parse_config_file函数代码示例发布时间:2022-05-27
下一篇:
Python options.define函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap