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


Python options.parse_config_file函数代码示例

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


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

示例1: make_app

def make_app():
  parse_config_file('./config.py')
  assert options.db_url, "Need a database URL"

  session_factory = make_session_factory(options.db_url)

  # group is named (?P<name>group)
  handlers = [
        url(r"/", MainHandler),
        url(r"/api/v1", InfoView, name='api'),
        url(r'/api/v1/assets', AssetListView),
        url(r'/api/v1/assets/(?P<asset_id>[0-9]+)', AssetView, name='asset'),
        url(r'/api/v1/layers', LayerListView),
        url(r'/api/v1/wells', WellListView),
        url(r'/api/v1/intersection', IntersectionListView),
    ]

  settings = {
    'session_factory': session_factory,
    'debug': options.debug,
    'template_path': './template/',
    'static_path': './static/',
    'static_url_prefix': '/static/'
  }
  
  return Application(handlers, **settings )
开发者ID:Putnic,项目名称:tornado_edu_app,代码行数:26,代码来源:main.py

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

示例3: make_server

def make_server(config_path):
    root = path.dirname(__file__)
    static_path = path.join(root, 'static')
    template_path = path.join(root, 'template')

    define('port', default=7777, type=int)
    define('production', default=False, type=bool)
    define('mongo_db_name', default='open_wireless_map', type=str)
    define('mongo_host', default='localhost', type=str)
    define('mongo_port', default=27017, type=int)
    define('mongo_user', default=None, type=str)
    define('mongo_password', default=None, type=str)
    define('api_password_hash', default=None, type=str)

    parse_config_file(config_path)

    app_config = dict(static_path=static_path,
                      template_path=template_path)
    if not options.production:
        app_config.update(debug=True)

    server = Application(url_map, **app_config)
    server.settings['api_password_hash'] = options.api_password_hash
    server.settings['mongo'] = get_mongo(db_name=options.mongo_db_name,
                                         host=options.mongo_host,
                                         port=options.mongo_port,
                                         user=options.mongo_user,
                                         password=options.mongo_password)
    return server
开发者ID:charlesthomas,项目名称:open_wireless_map,代码行数:29,代码来源:server.py

示例4: main

def main():
    """Entry point for bitsd."""
    enable_pretty_logging()

    try:
        parse_config_file('/etc/bitsd.conf')
    except IOError:
        LOG.warning('Config file not found, using defaults and command line.')

    try:
        parse_command_line()
    except tornado.options.Error as error:
        sys.stderr.write('{}\n'.format(error))
        sys.exit(0)

    persistence.start()
    server.start()
    listener.start()

    # Add signal handlers...
    signal.signal(signal.SIGTERM, sig_handler)
    signal.signal(signal.SIGINT, sig_handler)

    if not options.log_requests:
        logging.getLogger("tornado.access").setLevel(logging.WARNING)

    tornado.ioloop.IOLoop.instance().start()
开发者ID:BitsDevelopmentTeam,项目名称:bits-server,代码行数:27,代码来源:main.py

示例5: run

    def run(self):
        from tornado import options
                
        control = Control(file_archive='',db_url=self.db_url)
        #control.api_logon(self.ims_user, self.password)
        
        #The config file is reloaded here, as some of the logging options could have been reset
        #when the feeds and filters were loaded
        if os.path.isfile(self.config_file):
            logging.debug("Loading options from: %s" % self.config_file)        
            options.parse_config_file(self.config_file, final=False)
        else:
            logging.warning("The config file was not loaded: %s" % self.config_file)
        

        path, name = os.path.split(self.path)
        for prefix, funcname in self.cash_map.iteritems():
            if name.lower().startswith(prefix.lower()):
                func = getattr(control, funcname)
                break
        else:
            msg = "Unknown file name [%s]" % name
            raise ValueError(msg)
        
        func(self.path,self.ims_user, self.recipents)
        
        
    
        
开发者ID:robertbetts,项目名称:Kew,代码行数:25,代码来源:load_cashbalance_filter.py

示例6: load_settings

def load_settings():
    '''
        Load settings from command line and config file.
    '''

    # Parse command line
    options.logging = 'none' # To turn off logging settings
    options.log_to_stderr = True # Log to stderr
    parse_command_line()

    # Load settings from another config file if given
    if options.config:
        parse_config_file(options.config + '.conf')

    # Log file prefix
    options.log_file_prefix = ''.join((
        'log/',
        options.name,
        '-',
        str(options.port),
        '.log',
    ))

    # Logging settings
    if options.logging == 'none': # There are no logging settings before
        options.logging = 'debug' if options.debug else 'info'
        enable_pretty_logging(options=options)

    pretty_options_output()
开发者ID:InternetDataMiningLaboratory,项目名称:server_demo,代码行数:29,代码来源:settings.py

示例7: run_from_argv

    def run_from_argv(self, prog_name, argv=None, **_kwargs):
        app_settings = settings.APP_SETTINGS
        argv = list(filter(self.flower_option, argv))
        # parse the command line to get --conf option
        parse_command_line([prog_name] + argv)
        try:
            parse_config_file(options.conf, final=False)
            parse_command_line([prog_name] + argv)
        except IOError:
            if options.conf != settings.CONFIG_FILE:
                raise

        app_settings["debug"] = options.debug
        if options.cookie_secret:
            app_settings["cookie_secret"] = options.cookie_secret

        if options.url_prefix:
            prefix = options.url_prefix.strip("/")
            app_settings["static_url_prefix"] = "/{0}/static/".format(prefix)
            app_settings["login_url"] = "/{0}/login".format(prefix)
            settings.URL_PREFIX = prefix
        settings.CELERY_INSPECT_TIMEOUT = options.inspect_timeout
        settings.AUTO_REFRESH = options.auto_refresh

        if options.debug and options.logging == "info":
            options.logging = "debug"
            enable_pretty_logging()

        if options.auth:
            app_settings[GoogleOAuth2Mixin._OAUTH_SETTINGS_KEY] = {
                "key": options.oauth2_key or os.environ.get("GOOGLE_OAUTH2_KEY"),
                "secret": options.oauth2_secret or os.environ.get("GOOGLE_OAUTH2_SECRET"),
                "redirect_uri": options.oauth2_redirect_uri or os.environ.get("GOOGLE_OAUTH2_REDIRECT_URI"),
            }

        # Monkey-patch to support Celery 2.5.5
        self.app.connection = self.app.broker_connection

        self.app.loader.import_default_modules()
        flower = Flower(celery_app=self.app, options=options, **app_settings)
        atexit.register(flower.stop)

        # graceful shutdown on SIGTERM
        def signal_handler(signal, frame):
            logger.info("SIGTERM detected, shutting down")
            sys.exit(0)

        signal.signal(signal.SIGTERM, signal_handler)

        logger.info(
            "Visit me at http%s://%s:%s", "s" if flower.ssl else "", options.address or "localhost", options.port
        )
        logger.info("Broker: %s", self.app.connection().as_uri())
        logger.debug("Registered tasks: \n%s", pformat(sorted(self.app.tasks.keys())))
        logger.debug("Settings: %s", pformat(app_settings))

        try:
            flower.start()
        except (KeyboardInterrupt, SystemExit):
            pass
开发者ID:jgoclawski,项目名称:flower,代码行数:60,代码来源:command.py

示例8: main

def main():
    global http_server

    try:
        signal(SIGTERM, on_signal)

        parse_command_line()
        if options.config != None:
            parse_config_file(options.config)

        path = join(dirname(__file__), "templates")

        application = Application(
            [(r"/", IndexHandler), (r"/stock", StockHandler)],
            template_path=path,
            static_path=join(dirname(__file__), "static"),
        )

        application.db = motor.MotorClient(options.db_host, options.db_port).open_sync()[options.db_name]

        http_server = HTTPServer(application)
        http_server.listen(options.port, options.address)
        log().info("server listening on port %s:%d" % (options.address, options.port))
        if log().isEnabledFor(DEBUG):
            log().debug("autoreload enabled")
            tornado.autoreload.start()
        IOLoop.instance().start()

    except KeyboardInterrupt:
        log().info("exiting...")

    except BaseException as ex:
        log().error("exiting due: [%s][%s]" % (str(ex), str(format_exc().splitlines())))
        exit(1)
开发者ID:irr,项目名称:stock-labs,代码行数:34,代码来源:Server.py

示例9: main

def main():
    # We have settings?
    if os.path.exists('settings.py'):
        parse_config_file('settings.py')
    # What about command line args?
    parse_command_line()
    ssl_options = {}
    # Check SSL options
    if (options.certfile and options.keyfile) and (os.path.exists(
            os.path.abspath(options.certfile)) and os.path.exists(
            os.path.abspath(options.keyfile))):
        ssl_options['certfile'] = os.path.abspath(options.certfile)
        ssl_options['keyfile'] = os.path.abspath(options.keyfile)
    server = HTTPServer(app(), ssl_options=ssl_options or None)
    if options.debug:
        options.address = '127.0.0.1'
        log.debug('Run application in debug mode on %s:%s.' % (options.address,
                                                               options.port))
        server.listen(options.port, options.address)
    else:
        log.debug('Run application in normal mode on %s:%s.' % (options.address,
                                                                options.port))
        server.bind(options.port, options.address)
        server.start(0)
    IOLoop.instance().start()
开发者ID:ComradeDOS,项目名称:tornado_skeleton,代码行数:25,代码来源:run.py

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

示例11: main

def main():
    if os.path.exists(options.config_file):
        parse_config_file(options.config_file)
    parse_command_line()

    app = Application(
        [
            url(r'/token/?', auth.TokenHandler),
            url(r'/tasks/?', tasks.TaskHandler),
            url(r'/tasks/({uuid})/?'.format(uuid=UUID_PATTERN),
                tasks.TaskHandler),
            url(r'/domains/?', vms.DomainHandler),
            url(r'/domains/({uuid})/?'.format(uuid=UUID_PATTERN),
                vms.DomainHandler),
            url(r'/nodes/?', vms.NodeHandler),
            url(r'/nodes/([\d+])/?', vms.NodeHandler)
        ],
        template_path=os.path.join(BASE_DIR, 'templates'),
        static_path=os.path.join(BASE_DIR, 'static'),
        **options.group_dict('application')
    )
    app.listen(options.port)

    logging.info('Listening on http://localhost:%d' % options.port)

    IOLoop.current().add_callback(start_queue, app)
    IOLoop.current().start()
开发者ID:vovanbo,项目名称:vm-manager-proto,代码行数:27,代码来源:app.py

示例12: load_config

def load_config(path=None):
    '''
        This extends the tornado parser to enable use in
        heroku where options are accessed through os.getenv

        Will read file at path if exists

        Will then read environment variables to override

        Will then parse command line to override

    '''
    if path is not None and os.path.isfile(path):
        logging.info("loading config from %s", path)
        parse_config_file(path)

    for k in options.as_dict():
        ''' danger: access of private variables '''
        value = os.getenv(k)
        if value:
            name = options._normalize_name(k)
            option = options._options.get(name)
            option.parse(value)

    parse_command_line()
开发者ID:blueshed,项目名称:blueshed-micro,代码行数:25,代码来源:config.py

示例13: main

def main():
    parse_command_line()
    flagfile = os.path.join(os.path.dirname(__file__), options.flagfile)
    parse_config_file(flagfile)

    settings = dict(
        login_url='/todo/login',
        debug=True,
        template_path=os.path.join(os.path.dirname(__file__), 'templates'),
        static_path=os.path.join(os.path.dirname(__file__), 'static'),

        cookie_secret=options.cookie_secret,
        dropbox_consumer_key=options.dropbox_consumer_key,
        dropbox_consumer_secret=options.dropbox_consumer_secret,
        )
    #print options.dropbox_consumer_key
    #print options.dropbox_consumer_secret
    app = Application([
            ('/', RootHandler),
            ('/todo/?', TodoHandler),
            ('/todo/add', AddHandler),
            ('/delete', DeleteHandler),
            ('/create', CreateHandler),
            ('/todo/login', DropboxLoginHandler),
            ('/todo/logout', LogoutHandler),
            ], **settings)
    app.listen(options.port,address='127.0.0.1',xheaders=True)
    IOLoop.instance().start()
开发者ID:wynemo,项目名称:simpletodo,代码行数:28,代码来源:main.py

示例14: __init__

    def __init__(self):
        define("xmpp_jid", help="XMPP JID. e.g.: [email protected]", type=str)
        define("xmpp_password", help="XMPP Password.", type=str)
        define("xmpp_host", help="XMPP Host", type=str)
        define("xmpp_port", help="XMPP Port", type=int)
        define("xmpp_relay_user", help="XMPP relay user", type=str)
        define("callback_port", help="HTTP callback port.", default=15827, type=int)

        config_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "upstream-config.py")
        parse_config_file(config_path)

        self.relay_user = options["xmpp_relay_user"].value()

        super(XMPPManager, self).__init__("XMPPManager(%s)", options["xmpp_jid"].value())

        start = "http://127.0.0.1:%d/start/" % options["callback_port"].value()
        message = "http://127.0.0.1:%d/message/" % options["callback_port"].value()
        self.xmpp = XMPPProxyBot(options["xmpp_jid"].value(), options["xmpp_password"].value(), start, message)

        self.app = tornado.web.Application(
            [
                (r"/start/", XMPPProxyCallback, {"callback": self.on_start}),
                (r"/message/", XMPPProxyCallback, {"callback": self.on_message}),
            ]
        )

        if self.xmpp.connect((options["xmpp_host"].value(), options["xmpp_port"].value())):
            self.xmpp.process(block=False)

        self.streams = {}
        self.app.listen(options["callback_port"].value())
开发者ID:ccp0101,项目名称:shuttle,代码行数:31,代码来源:upstream.py

示例15: run_from_argv

    def run_from_argv(self, prog_name, argv=None, **_kwargs):
        app_settings = settings.APP_SETTINGS
        argv = list(filter(self.flower_option, argv))
        # parse the command line to get --conf option
        parse_command_line([prog_name] + argv)
        try:
            parse_config_file(options.conf, final=False)
            parse_command_line([prog_name] + argv)
        except IOError:
            if options.conf != settings.CONFIG_FILE:
                raise

        app_settings['debug'] = options.debug
        if options.cookie_secret:
            app_settings['cookie_secret'] = options.cookie_secret

        if options.url_prefix:
            logger.error('url_prefix option is not supported anymore')

        settings.AUTO_REFRESH = options.auto_refresh

        if options.debug and options.logging == 'info':
            options.logging = 'debug'
            enable_pretty_logging()

        if options.auth:
            app_settings[GoogleOAuth2Mixin._OAUTH_SETTINGS_KEY] = {
              'key': options.oauth2_key or os.environ.get('GOOGLE_OAUTH2_KEY'),
              'secret': options.oauth2_secret or os.environ.get('GOOGLE_OAUTH2_SECRET'),
              'redirect_uri': options.oauth2_redirect_uri or os.environ.get('GOOGLE_OAUTH2_REDIRECT_URI'),
            }

        # Monkey-patch to support Celery 2.5.5
        self.app.connection = self.app.broker_connection

        self.app.loader.import_default_modules()
        flower = Flower(celery_app=self.app, options=options,
                        **app_settings)
        atexit.register(flower.stop)

        # graceful shutdown on SIGTERM
        def signal_handler(signal, frame):
            logger.info('SIGTERM detected, shutting down')
            sys.exit(0)
        signal.signal(signal.SIGTERM, signal_handler)

        logger.info('Visit me at http%s://%s:%s',
                    's' if flower.ssl else '',
                    options.address or 'localhost',
                    options.port)
        logger.info('Broker: %s', self.app.connection().as_uri())
        logger.debug('Registered tasks: \n%s',
                     pformat(sorted(self.app.tasks.keys())))
        logger.debug('Settings: %s', pformat(app_settings))

        try:
            flower.start()
        except (KeyboardInterrupt, SystemExit):
            pass
开发者ID:damirazo,项目名称:flower,代码行数:59,代码来源:command.py


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