示例#1
0
            def topic(self):
                err = expect.error_to_happen(ConfigurationError)

                with err:
                    Config.load(fix('not-existent.conf'))

                return err
示例#2
0
            def topic(self):
                err = expect.error_to_happen(ConfigurationError)

                with err:
                    Config.load(fix('not-existent.conf'))

                return err
示例#3
0
            def topic(self):
                config = Config.load(fix('sample.conf'))
                Config.allow_environment_variables()

                try:
                    os.environ['FOO'] = "baz"
                    return config.FOO
                finally:
                    del os.environ['FOO']
示例#4
0
            def topic(self):
                config = Config.load(fix('sample.conf'))
                Config.allow_environment_variables()

                try:
                    os.environ['FOO'] = "baz"
                    return config.FOO
                finally:
                    del os.environ['FOO']
示例#5
0
    def load(self, config_path=None):
        """
        Load configuration from file. If no config path is given, several
        directories are searched for a file named 'githubsurvivor.conf': the
        current directory, followed by the current user's home directory, then
        finally /etc.
        """
        if not config_path:
            config_path = c.get_conf_file(self.DEFAULT_FILENAME, self.SEARCH_DIRS)

        if not config_path:
            raise Exception(
                'No configuration provided, and none found at any of %s' % \
                    ', '.join(path.join(d, self.DEFAULT_FILENAME) for d in self.SEARCH_DIRS))

        self._config = c.load(config_path or self._default_path())
示例#6
0
    def load(self, config_path=None):
        """
        Load configuration from file. If no config path is given, several
        directories are searched for a file named 'githubsurvivor.conf': the
        current directory, followed by the current user's home directory, then
        finally /etc.
        """
        if not config_path:
            config_path = c.get_conf_file(self.DEFAULT_FILENAME, self.SEARCH_DIRS)

        if not config_path:
            raise Exception(
                'No configuration provided, and none found at any of %s' % \
                    ', '.join(path.join(d, self.DEFAULT_FILENAME) for d in self.SEARCH_DIRS))

        self._config = c.load(config_path or self._default_path())
示例#7
0
 def topic(self):
     return Config.load(fix('sample.conf'))
示例#8
0
def get_handlers(conf):
    DEFAULT_CONF = {'conf': conf, 'middleware_list': get_middleware_list()}

    return [
        url(r"/", HelloTornadoHandler, DEFAULT_CONF),
        url(r"/story/([0-9]+)", StoryHandler, DEFAULT_CONF, name="story"),
        url(r"/login_error",
            LoginErrorHandler,
            DEFAULT_CONF,
            name="login_error"),
    ]


class HelloTornadoApplication(tornado.web.Application):
    def __init__(self, handlers, settings):
        super(HelloTornadoApplication, self).__init__(handlers, settings)


def make_app(conf, handlers):
    return HelloTornadoApplication(
        handlers=handlers,
        settings={'template_path': conf.TEMPLATE_DIR},
    )


if __name__ == '__main__':
    conf = Config.load('settings.conf')
    app = make_app(conf, get_handlers(conf))
    app.listen(conf.PORT)
    tornado.ioloop.IOLoop.current().start()
示例#9
0
 def topic(self):
     return Config.load(None,
                        defaults={'DEFAULT': 'DEFAULTVALUE'})
示例#10
0
 def topic(self):
     Config.load(fix('not-existent.conf'))
示例#11
0
 def topic(self):
     return Config.load(None, defaults={'DEFAULT': 'DEFAULTVALUE'})
示例#12
0
 def topic(self):
     return Config.load(None, conf_name='sample.conf', lookup_paths=['vows/fixtures/'])
示例#13
0
def verify_and_load(config_file):
	verify_config(config_file)
	return Config.load(config_file)
示例#14
0
 def topic(self):
     return Config.load(fix('conf.d'), defaults={
         'PROPER': 'PROPERVALUE'
     })
示例#15
0
 def topic(self):
     Config.define('some_key', 'default', 'test key')
     return Config.load(fix('missing.conf'))
示例#16
0
 def topic(self):
     return Config.load(fix('sample.conf'))
示例#17
0
def init_app(app, path=None):
    conf = Config.load(path)
    for conf_option, _ in conf.items.items():
        app.config[conf_option] = conf[conf_option]

    app.secret_key = app.config['APP_SECRET_KEY']
示例#18
0
 def topic(self):
     return Config.load(fix('conf.d'),
                        defaults={'PROPER': 'PROPERVALUE'})
示例#19
0
import sys
import os

from derpconf.config import Config


BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


if 'test' in sys.argv:
    config_file = os.path.join(BASE_DIR, 'politicos', 'tests.config')
else:
    config_file = os.path.join(BASE_DIR, 'politicos', 'local.config')

if os.path.isfile(config_file):
    conf = Config.load(config_file)
else:
    conf = Config()

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = conf.get('SECRET_KEY', 'REPLACE-THIS-IN-CONFIG-LOCAL')

DEBUG = conf.get('DEBUG', True)

ALLOWED_HOSTS = conf.get('ALLOWED_HOSTS', [])

DEFAULT_INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
示例#20
0
 def topic(self):
     Config.define('some_key', 'default', 'test key')
     return Config.load(fix('missing.conf'))
示例#21
0
def verify_and_load(config_file):
    verify_config(config_file)
    return Config.load(config_file)
示例#22
0
def init_app(app, path=None):
    conf = Config.load(path)
    for conf_option, _ in conf.items.items():
        app.config[conf_option] = conf[conf_option]

    app.secret_key = app.config['APP_SECRET_KEY']
示例#23
0
 def topic(self):
     return Config.load(fix('sample.conf'),
                        defaults={'PROPER': 'PROPERVALUE'})
示例#24
0
 def topic(self):
     return Config.load(fix('sample.conf'), defaults={
         'PROPER': 'PROPERVALUE'
     })
示例#25
0
 def topic(self):
     return Config.load(None,
                        conf_name='sample.conf',
                        lookup_paths=['vows/fixtures/'])
示例#26
0
 def topic(self):
     return Config.load(
         None, conf_name='not-existent.conf',
         lookup_paths=['vows/fixtures/'],
         defaults={'DEFAULT': 'DEFAULTVALUE'}
     )
示例#27
0
 def topic(self):
     return Config.load(None,
                        conf_name='not-existent.conf',
                        lookup_paths=['vows/fixtures/'],
                        defaults={'DEFAULT': 'DEFAULTVALUE'})
示例#28
0
import sys

from derpconf.config import Config


def INSTANCE(x):
    return os.path.join(os.path.dirname(__file__), x)


if 'test' in sys.argv:
    config_file = INSTANCE('tests.config')
else:
    config_file = INSTANCE('local.config')

if os.path.isfile(config_file):
    conf = Config.load(config_file)
else:
    conf = Config()

DEBUG = conf.get('DEBUG', True)

ADMINS = conf.get('ADMINS', ())

MANAGERS = ADMINS

DEAFAULT_DATABASE = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': INSTANCE('db.sqlite3'),
        'USER': '',
        'PASSWORD': '',
示例#29
0
 def topic(self):
     Config.load(fix('not-existent.conf'))