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

Python options.define函数代码示例

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

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



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

示例1: config_app

def config_app(config, default_options_file, replace_options):
    init_env()
    app_log.set_logging_level(app_common_const.LOG_LEVEL)

    with open(default_options_file, 'r') as f:
        default_options = json.load(f)
        if default_options:
            for option in default_options.get('global_option', {}):
                if option:
                    define(option[0], default=option[1],
                           help=option[2], type=get_builtin_type(option[3]))

    options.parse_config_file(config)

    if not check_server_config():
        raise EnvironmentError('app server config')

    if app_common_const.OPTION_LOG_PATH in options:
        app_log.define_file_logging()

    options.template_path = str(os.path.join(app_common_const.PROJECT_BASE_FOLDER, options.template_path))
    options.static_path = str(os.path.join(app_common_const.PROJECT_BASE_FOLDER, options.static_path))

    if replace_options and replace_options['port']:
        options.port = int(replace_options['port'])

    config_jinja2()
开发者ID:LordRoad,项目名称:little,代码行数:27,代码来源:app_config.py


示例2: __init__

 def __init__(self, handlers, **settings):
   define('poolsize', default=10, type=int)
   settings['session_secret'] = options.sessionsecret
   settings['cookie_secret'] = options.cookiesecret
   self.pool = database.Pool.instance()
   self.session_manager = session.SessionManager(session.DatabaseSessionStorage, self.pool, secret=options.sessionsecret)
   super(BaseApplication, self).__init__(handlers, **settings)
开发者ID:jdsieci,项目名称:engine,代码行数:7,代码来源:application.py


示例3: main

def main():
    define("sslcheck", default=1, help="Verify SSL hostname, on by default")
    define("use_simple_http_client", default=0,
           help="Use Tornado SimpleHTTPClient instead of CurlAsyncHTTPClient")
    args = parse_command_line()
    skip_ssl_validation = False
    use_simple_http_client = False

    if unicode(options.sslcheck) == u"0":
        skip_ssl_validation = True

    if unicode(options.use_simple_http_client) == u"1":
        use_simple_http_client = True

    # If we don't have any arguments, run the server.
    if not args:
        app = init_forwarder(skip_ssl_validation, use_simple_http_client=use_simple_http_client)
        try:
            app.run()
        finally:
            ForwarderStatus.remove_latest_status()

    else:
        usage = "%s [help|info]. Run with no commands to start the server" % (sys.argv[0])
        command = args[0]
        if command == 'info':
            logging.getLogger().setLevel(logging.ERROR)
            return ForwarderStatus.print_latest_status()
        elif command == 'help':
            print(usage)
        else:
            print("Unknown command: %s" % command)
            print(usage)
            return -1
    return 0
开发者ID:bluejayKR,项目名称:monasca-agent,代码行数:35,代码来源:daemon.py


示例4: init_define

def init_define():
    define("flag", default=False, help="when system is first time,flag should be set True", type=bool)
    # log
    define("log_file_prefix", default="./log/analysis.log")
    define("log_rotate_mode", default='time')  # 轮询模式: time or size
    define("log_rotate_when", default='H')  # 单位: S / M / H / D / W0 - W6
    define("log_rotate_interval", default=24)  # 间隔: 24小时
开发者ID:alatting,项目名称:smartposter,代码行数:7,代码来源:analysis_server.py


示例5: main

def main():
    define("pycurl", default=1, help="Use pycurl")
    args = parse_command_line()

    if options.pycurl == 0 or options.pycurl == "0":
        os.environ['USE_SIMPLE_HTTPCLIENT'] = '1'

    # If we don't have any arguments, run the server.
    if not args:
        import tornado.httpclient
        app = init()
        try:
            app.run()
        finally:
            ForwarderStatus.remove_latest_status()
            
    else:
        usage = "%s [help|info]. Run with no commands to start the server" % (
                                        sys.argv[0])
        command = args[0]
        if command == 'info':
            return ForwarderStatus.print_latest_status()
        elif command == 'help':
            print usage
        else:
            print "Unknown command: %s" % command
            print usage
            return -1
    return 0
开发者ID:shawnsmith,项目名称:dd-agent,代码行数:29,代码来源:ddagent.py


示例6: parse_config

    def parse_config(self):
        """Parses the command line arguments, and assign their
        values to our local traits.
        """

        if not self.command_line_options_inited:
            for traitlet_name, traitlet in self.traits().items():
                    define(
                        traitlet_name,
                        default=traitlet.default_value,
                        type=type(traitlet.default_value),
                        help=traitlet.help)

        self.__class__.command_line_options_inited = True

        tornado.options.parse_command_line()

        # Workaround for change in jupyterhub 0.7.0.
        # Args are passed with quotes, that are preserved in the arguments when
        # we retrieve them. We just get rid of the quotes, until a better
        # solution comes along.
        # See jupyterhub/jupyterhub#836 for details.
        opts = {k: remove_quotes(v) for k, v in options.as_dict().items()}
        set_traits_from_dict(self, opts)

        # Normalize the base_urlpath to end with a slash
        self.base_urlpath = with_end_slash(self.base_urlpath)
开发者ID:simphony,项目名称:simphony-remote,代码行数:27,代码来源:command_line_config.py


示例7: 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


示例8: start

def start():
    #tornado.options.parse_command_line()

    # 定义Tornado url
    urls = \
        [
            (r'/login', LoginHandler),
            (r'/logout', LogoutHandler),
            (r'/main', MainHandler),
            #(r'/assets[/]?(.*)', TestHandler),
            (r'/assets/test.html', TestHandler),
            (r'/assets/user_list.html', UserListHandler),
            (r'/assets/user_list_add.html', UserListAddHandler),

            (r'/getdata', API2MysqlHandler),
            #(r'/assets/asset_children/(.*)', tornado.web.StaticFileHandler, {"path": settings['asset_children']}),    # 后台文件路径
        ]

    #Tornado监听IP/端口
    define("host", default=LISTEN_HOST, help="run on the given host", type=str)
    define("port", default=LISTEN_PORT, help="run on the given port", type=int)

    application = tornado.web.Application(urls,**settings)

    try:
        http_server = tornado.httpserver.HTTPServer(application,xheaders=True)
        http_server.listen(port=options.port, address=options.host)
        print 'Tornado load config finished,run at %s:%d; locate test url http://127.0.0.1:%d' % (LISTEN_HOST,LISTEN_PORT,LISTEN_PORT)

        tornado.ioloop.IOLoop.instance().start()
    except Exception,err:
        print 'Tornado 启动失败'
        raise err
开发者ID:Drizztx,项目名称:giter,代码行数:33,代码来源:server.py


示例9: 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


示例10: __init__

    def __init__(self, defines):
        for setting_define in defines:
            if setting_define.name.upper() != setting_define.name:
                raise ValueError("Setting name must be uppercase.")
            if setting_define.content_type not in self._setting_parsers:
                raise ValueError("Unknown setting content type.")
            if setting_define.name in self.__dict__:
                raise ValueError("Invalid setting name.")

            default = os.getenv(
                '{prefix}_{attr}'.format(
                    prefix=self.ENV_PREFIX,
                    attr=setting_define.name),
                setting_define.default
            )

            parser = self._setting_parsers[setting_define.content_type]

            options.define(
                setting_define.name,
                type=parser.OPTIONS_TYPE,
                default=parser.decode(value=default),
                help=setting_define.description
            )

        options.parse_command_line()
开发者ID:nanvel,项目名称:tornado-boilerplate,代码行数:26,代码来源:models.py


示例11: main

def main():
    define('port', default=1013, help='run on the given port', type=int)
    
    tornado.options.parse_command_line()
    http_server = tornado.httpserver.HTTPServer(Application())
    http_server.listen(options.port)
    tornado.ioloop.IOLoop.instance().start()
开发者ID:lucienzhu,项目名称:TornadoPhotoExplorer,代码行数:7,代码来源:main.py


示例12: main

def main():
    define("console", default=False, type=bool)
    define("mongo_host", default="localhost")

    parse_command_line()
    basicConfig(options=options)
    db = Connection(options.mongo_host)["crunch"]["company_stats"]
开发者ID:daniyalzade,项目名称:crunchviz,代码行数:7,代码来源:handler.py


示例13: main

def main():
    global config
    global dm

    with open('dm-config.json', 'r') as f:
        config = json.load(f)

    logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s',
                        level=logging.getLevelName(config['config']['log_level']),
                        stream=sys.stderr)

    define("port", default=5000, help="run on the given port", type=int)
    tornado.options.parse_command_line()

    logging.info("Starting up...")

    deployer_utils.fill_hadoop_env(config['environment'])

    package_repository = PackageRepoRestClient(config['config']["package_repository"], config['config']['stage_root'])
    dm = deployment_manager.DeploymentManager(package_repository,
                                              package_registrar.HbasePackageRegistrar(
                                                  config['environment']['hbase_thrift_server'],
                                                  config['environment']['webhdfs_host'],
                                                  'hdfs',
                                                  config['environment']['webhdfs_port'],
                                                  config['config']['stage_root']),
                                              application_registrar.HbaseApplicationRegistrar(
                                                  config['environment']['hbase_thrift_server']),
                                              config['environment'],
                                              config['config'])

    http_server = tornado.httpserver.HTTPServer(Application())
    http_server.listen(options.port)

    tornado.ioloop.IOLoop.instance().start()
开发者ID:pndaproject,项目名称:platform-deployment-manager,代码行数:35,代码来源:app.py


示例14: main

def main():
    try:
        """
        defining/parsing the options
        """
        define("port", default=8082, help="run on the given port", type=int)
        define("debug", default=False, help="run in debug mode", type=bool)
        tornado.options.parse_command_line()        
        logging.debug(options.logging)
        """
        initalising applications
        """ 
        app = MyApplication(options)

        """
        starting tornado server
        """
        http_server = tornado.httpserver.HTTPServer(app)
        http_server.listen(options.port)
        ioloop = tornado.ioloop.IOLoop.instance()
        tornado.autoreload.add_reload_hook(app.reloadTasks)
        tornado.autoreload.start(ioloop)
        ioloop.start()

    except KeyboardInterrupt:
        pass
    except:
        print traceback.format_exc()
开发者ID:louhibi,项目名称:tornado_app_squeleton,代码行数:28,代码来源:main.py


示例15: mainloop

def mainloop():
    """
    get options configure application and start io loop
    """
    topt.define("alligator", default="tcp://localhost:5555", help="Alligator command server ZMQ endpoint")
    topt.define("port", type=int, default=4444, help="webserver port")
    
    topt.parse_command_line()
    port = topt.options.port

    application = tw.Application([
        (r"/", MainHandler),
        (r"/workbench/(.*)", tw.StaticFileHandler, dict(path="../www")),
        (r"/alligator", AlligatorWsHandler, dict(endpoint=topt.options.alligator)) 
        ])

    log.info('bridge ws to alligator: %s', topt.options.alligator)
    
    application.listen(port)
    log.info('server listening on:    %d', port)

    
    try:
        tio.IOLoop.instance().start()
    except KeyboardInterrupt as u:
        log.info("user interrupted")
    except Exception as e:
        log.error(e)
开发者ID:krystofa,项目名称:alligator,代码行数:28,代码来源:alligator_websocket_bridge.py


示例16: SvcDoRun

    def SvcDoRun(self):
        import servicemanager      
        servicemanager.LogMsg(servicemanager.EVENTLOG_INFORMATION_TYPE,servicemanager.PYS_SERVICE_STARTED,(self._svc_name_, '')) 
      
        self.timeout = 3000
        self.run = True
        
        while self.run:
            rc = win32event.WaitForSingleObject(self.hWaitStop, self.timeout)
            # Check to see if self.hWaitStop happened
            if rc == win32event.WAIT_OBJECT_0:
                # Stop signal encountered
                servicemanager.LogInfoMsg("Stephano_Meditech - STOPPED")
                break
            else:
                from tornado.options import parse_command_line, parse_config_file, define, options
                from application import create_db_instance

                define('dir')

                #parse_config_file('./GISMOH.conf')
                parse_command_line(final=True)


                importer = MeditechImport(create_db_instance(options.db_type, options.db_constr), options.dir)
                importer.scan_dir()
开发者ID:ImperialCollegeLondon,项目名称:GISMOH_BE,代码行数:26,代码来源:MeditechService.py


示例17: __init__

    def __init__(self):
        Configuration()
        DeviceManager()
        ThreadPoolManager()

        define('port', 80, None, int)
        define("debug", default=True, help="Debug Mode", type=bool)
开发者ID:five3,项目名称:wireless-testing-platform,代码行数:7,代码来源:TornadoProcessor.py


示例18: parser

def parser():
    define('script', default='/var/maple/')
    define('dbhost', default='localhost')
    define('dbuser', default='root')
    define('dbpass', default='')
    define('db', default='maple')
    parse_config_file('/etc/maple/default.conf')
开发者ID:smaplee,项目名称:maple,代码行数:7,代码来源:parse.py


示例19: main

def main():
    define("port", default=8000, help="run on the given port", type=int)
    tornado.options.parse_command_line()
    http_server = tornado.httpserver.HTTPServer(Application(), xheaders=True)
    http_server.listen(options.port)
    print("Application started. Listening on port %d." % options.port)
    tornado.ioloop.IOLoop.instance().start()
开发者ID:Madimo,项目名称:RLookingServer,代码行数:7,代码来源:main.py


示例20: main

def main():
    from tornado.options import define, options
    define("port", default=8001, help="run on the given port", type=int)
    define("debug", default=True, help="debug mode", type=bool)

    tornado.options.parse_command_line()

    # also send logs through syslog to get them into graylog
    if not options.debug:
        """
        This will send things through syslogd, and into /var/log/syslog by default.
        to get them into graylog, you probably need to tinker with rsyslog or syslog-ng
        settings. see: http://dev.nuclearrooster.com/2011/04/05/forwarding-rsyslog-to-graylog2/
        for simple examples
        """
        import logging
        import logging.handlers
        logger = logging.getLogger() 
        handler = logging.handlers.SysLogHandler(address='/dev/log')
        handler.setFormatter(tornado.log.LogFormatter(color=False))
        logger.addHandler(handler)

    http_server = tornado.httpserver.HTTPServer( App(options.debug) )
    http_server.listen(options.port)
    info( 'Serving on port %d' % options.port )
    tornado.ioloop.IOLoop.instance().start()
开发者ID:edgeflip,项目名称:analytics_and_reporting,代码行数:26,代码来源:main.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python options.parse_command_line函数代码示例发布时间:2022-05-27
下一篇:
Python netutil.ThreadedResolver类代码示例发布时间: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