Exemplo n.º 1
0
    def app_config(self):
        cx = loadwsgi.loadcontext(SERVER, self.cfgurl, relative_to=self.relpath)
        gc, lc = cx.global_conf.copy(), cx.local_conf.copy()
        cfg = {}

        host, port = lc.pop('host', ''), lc.pop('port', '')
        if host and port:
            cfg['bind'] = '%s:%s' % (host, port)
        elif host:
            cfg['bind'] = host.split(',')

        cfg['workers'] = int(lc.get('workers', 1))
        cfg['umask'] = int(lc.get('umask', 0))
        cfg['default_proc_name'] = gc.get('__file__')

        for k, v in gc.items():
            if k not in self.cfg.settings:
                continue
            cfg[k] = v

        for k, v in lc.items():
            if k not in self.cfg.settings:
                continue
            cfg[k] = v

        return cfg
Exemplo n.º 2
0
def paste_config(gconfig, config_url, relative_to, global_conf=None):
    # add entry to pkg_resources
    sys.path.insert(0, relative_to)
    pkg_resources.working_set.add_entry(relative_to)

    config_url = config_url.split('#')[0]
    cx = loadwsgi.loadcontext(SERVER, config_url, relative_to=relative_to,
                              global_conf=global_conf)
    gc, lc = cx.global_conf.copy(), cx.local_conf.copy()
    cfg = {}

    host, port = lc.pop('host', ''), lc.pop('port', '')
    if host and port:
        cfg['bind'] = '%s:%s' % (host, port)
    elif host:
        cfg['bind'] = host.split(',')

    cfg['default_proc_name'] = gc.get('__file__')

    # init logging configuration
    config_file = config_url.split(':')[1]
    if _has_logging_config(config_file):
        cfg.setdefault('logconfig', config_file)

    for k, v in gc.items():
        if k not in gconfig.settings:
            continue
        cfg[k] = v

    for k, v in lc.items():
        if k not in gconfig.settings:
            continue
        cfg[k] = v

    return cfg
Exemplo n.º 3
0
def paste_config(gconfig, config_url, relative_to, global_conf=None):
    # add entry to pkg_resources
    sys.path.insert(0, relative_to)
    pkg_resources.working_set.add_entry(relative_to)

    cx = loadwsgi.loadcontext(SERVER, config_url, relative_to=relative_to,
            global_conf=global_conf)
    gc, lc = cx.global_conf.copy(), cx.local_conf.copy()
    cfg = {}

    host, port = lc.pop('host', ''), lc.pop('port', '')
    if host and port:
        cfg['bind'] = '%s:%s' % (host, port)
    elif host:
        cfg['bind'] = host.split(',')

    cfg['workers'] = int(lc.get('workers', 1))
    cfg['umask'] = int(lc.get('umask', 0))
    cfg['default_proc_name'] = gc.get('__file__')

    for k, v in gc.items():
        if k not in gconfig.settings:
            continue
        cfg[k] = v

    for k, v in lc.items():
        if k not in gconfig.settings:
            continue
        cfg[k] = v

    return cfg
Exemplo n.º 4
0
 def open_browser():
     context = loadcontext(
         SERVER, app_spec, name=server_name, relative_to=base,
         global_conf=vars)
     url = 'http://127.0.0.1:{port}/'.format(**context.config())
     time.sleep(1)
     webbrowser.open(url)
Exemplo n.º 5
0
def paste_config(gconfig, config_url, relative_to, global_conf=None):
    # add entry to pkg_resources
    sys.path.insert(0, relative_to)
    pkg_resources.working_set.add_entry(relative_to)

    config_url = config_url.split('#')[0]
    cx = loadwsgi.loadcontext(SERVER, config_url, relative_to=relative_to,
                              global_conf=global_conf)
    gc, lc = cx.global_conf.copy(), cx.local_conf.copy()
    cfg = {}

    host, port = lc.pop('host', ''), lc.pop('port', '')
    if host and port:
        cfg['bind'] = '%s:%s' % (host, port)
    elif host:
        cfg['bind'] = host.split(',')

    cfg['default_proc_name'] = gc.get('__file__')

    # init logging configuration
    config_file = config_url.split(':')[1]
    if _has_logging_config(config_file):
        cfg.setdefault('logconfig', config_file)

    for k, v in gc.items():
        if k not in gconfig.settings:
            continue
        cfg[k] = v

    for k, v in lc.items():
        if k not in gconfig.settings:
            continue
        cfg[k] = v

    return cfg
Exemplo n.º 6
0
def paste_config(gconfig, config_url, relative_to, global_conf=None):
    # add entry to pkg_resources
    sys.path.insert(0, relative_to)
    pkg_resources.working_set.add_entry(relative_to)

    cx = loadwsgi.loadcontext(SERVER,
                              config_url,
                              relative_to=relative_to,
                              global_conf=global_conf)
    gc, lc = cx.global_conf.copy(), cx.local_conf.copy()
    cfg = {}

    host, port = lc.pop('host', ''), lc.pop('port', '')
    if host and port:
        cfg['bind'] = '%s:%s' % (host, port)
    elif host:
        cfg['bind'] = host.split(',')

    cfg['workers'] = int(lc.get('workers', 1))
    cfg['umask'] = int(lc.get('umask', 0))
    cfg['default_proc_name'] = gc.get('__file__')

    for k, v in gc.items():
        if k not in gconfig.settings:
            continue
        cfg[k] = v

    for k, v in lc.items():
        if k not in gconfig.settings:
            continue
        cfg[k] = v

    return cfg
Exemplo n.º 7
0
    def app_config(self):
        cx = loadwsgi.loadcontext(SERVER, self.cfgurl, relative_to=self.relpath)
        gc, lc = cx.global_conf.copy(), cx.local_conf.copy()
        cfg = {}

        host, port = lc.pop("host", ""), lc.pop("port", "")
        if host and port:
            cfg["bind"] = "%s:%s" % (host, port)
        elif host:
            cfg["bind"] = host

        cfg["workers"] = int(lc.get("workers", 1))
        cfg["umask"] = int(lc.get("umask", 0))
        cfg["default_proc_name"] = gc.get("__file__")

        for k, v in gc.items():
            if k not in self.cfg.settings:
                continue
            cfg[k] = v

        for k, v in lc.items():
            if k not in self.cfg.settings:
                continue
            cfg[k] = v

        return cfg
Exemplo n.º 8
0
 def open_browser():
     context = loadcontext(
         SERVER, app_spec, name=server_name, relative_to=base,
         global_conf=vars)
     url = 'http://127.0.0.1:{port}/'.format(**context.config())
     time.sleep(1)
     webbrowser.open(url)
Exemplo n.º 9
0
    def app_config(self):
        cx = loadwsgi.loadcontext(SERVER,
                                  self.cfgurl,
                                  relative_to=self.relpath,
                                  global_conf=self.gcfg)
        gc, lc = cx.global_conf.copy(), cx.local_conf.copy()
        cfg = {}

        host, port = lc.pop('host', ''), lc.pop('port', '')
        if host and port:
            cfg['bind'] = '%s:%s' % (host, port)
        elif host:
            cfg['bind'] = host.split(',')

        cfg['workers'] = int(lc.get('workers', 1))
        cfg['umask'] = int(lc.get('umask', 0))
        cfg['default_proc_name'] = gc.get('__file__')

        for k, v in gc.items():
            if k not in self.cfg.settings:
                continue
            cfg[k] = v

        for k, v in lc.items():
            if k not in self.cfg.settings:
                continue
            cfg[k] = v

        return cfg
Exemplo n.º 10
0
def loadcontext(object_type,
                uri,
                name=None,
                relative_to=None,
                global_conf=None):
    add_conf_type = wrap_conf_type(lambda x: x)
    return loadwsgi.loadcontext(object_type,
                                add_conf_type(uri),
                                name=name,
                                relative_to=relative_to,
                                global_conf=global_conf)
Exemplo n.º 11
0
def loadcontext(object_type, uri, name=None, relative_to=None, global_conf=None):
    if isinstance(uri, loadwsgi.ConfigLoader):
        # bypass loadcontext's uri parsing and loader routing and
        # just directly return the context
        if global_conf:
            uri.update_defaults(global_conf, overwrite=False)
        return uri.get_context(object_type, name, global_conf)
    add_conf_type = wrap_conf_type(lambda x: x)
    return loadwsgi.loadcontext(
        object_type, add_conf_type(uri), name=name, relative_to=relative_to, global_conf=global_conf
    )
Exemplo n.º 12
0
def loadcontext(object_type, uri, name=None, relative_to=None,
                global_conf=None):
    if isinstance(uri, loadwsgi.ConfigLoader):
        # bypass loadcontext's uri parsing and loader routing and
        # just directly return the context
        if global_conf:
            uri.update_defaults(global_conf, overwrite=False)
        return uri.get_context(object_type, name, global_conf)
    add_conf_type = wrap_conf_type(lambda x: x)
    return loadwsgi.loadcontext(object_type, add_conf_type(uri), name=name,
                                relative_to=relative_to,
                                global_conf=global_conf)
Exemplo n.º 13
0
    def create_filter(self, entry_point_name):
        """
        Creates a context for a filter that can subsequently be added
        to a pipeline context.

        :param entry_point_name: entry point of the middleware (Swift only)

        :returns: a filter context
        """
        spec = "egg:swift#" + entry_point_name
        ctx = loadwsgi.loadcontext(loadwsgi.FILTER, spec, global_conf=self.context.global_conf)
        ctx.protocol = "paste.filter_factory"
        return ctx
Exemplo n.º 14
0
def config_factory(args):
    if 'config_url' in args:
        config_url = args['config_url']
        relative_to = args['relative_to']
        global_conf = args['global_conf']
    else:
        config_file = os.path.abspath(args['args'][0])
        config_url = 'config:%s' % (os.path.basename(config_file), )
        relative_to = os.path.dirname(config_file)
        global_conf = {}
        for arg in args['args'][1:]:
            key, value = arg.split('=')
            global_conf[key] = value

    ctx = loadwsgi.loadcontext(
        loadwsgi.SERVER,
        config_url,
        relative_to=relative_to,
        global_conf=global_conf)

    watch = args.get('watch', None)
    if watch is None:
        watch = []
    if ctx.global_conf['__file__'] not in watch:
        watch.append(ctx.global_conf['__file__'])
    args['watch'] = watch

    args['app_factory'] = 'spawning.paste_factory.app_factory'
    args['config_url'] = config_url
    args['relative_to'] = relative_to
    args['source_directories'] = [relative_to]
    args['global_conf'] = ctx.global_conf

    debug = ctx.global_conf.get('debug', None)
    if debug is not None:
        args['dev'] = (debug == 'true')
    host = ctx.local_conf.get('host', None)
    if host is not None:
        args['host'] = host
    port = ctx.local_conf.get('port', None)
    if port is not None:
        args['port'] = int(port)
    num_processes = ctx.local_conf.get('num_processes', None)
    if num_processes is not None:
        args['num_processes'] = int(num_processes)
    threadpool_workers = ctx.local_conf.get('threadpool_workers', None)
    if threadpool_workers is not None:
        args['threadpool_workers'] = int(threadpool_workers)

    return args
Exemplo n.º 15
0
def loadapp(conf_file, global_conf=None, relative_to='.', name=None, allow_modify_pipeline=True):
    """
    Loads a context from a config file, and if the context is a pipeline
    then presents the app with the opportunity to modify the pipeline.
    """
    global_conf = global_conf or {}
    ctx = loadwsgi.loadcontext(loadwsgi.APP, conf_file, name=name, relative_to=relative_to, global_conf=global_conf)
    # if ctx.object_type.name == 'pipeline':
    #     # give app the opportunity to modify the pipeline context
    #     app = ctx.app_context.create()
    #     func = getattr(app, 'modify_wsgi_pipeline', None)
    #     if func and allow_modify_pipeline:
    #         func(PipelineWrapper(ctx))
    return ctx.create()
Exemplo n.º 16
0
    def get_app(parser, opts, args):
        if len(args) != 1:
            parser.error("No application name specified.")

        config_file = os.path.abspath(os.path.normpath(
                            os.path.join(os.getcwd(), args[0])))

        if not os.path.exists(config_file):
            parser.error("Config file not found.")

        config_url = 'config:%s' % config_file
        relative_to = os.path.dirname(config_file)

        # load module in sys path
        sys.path.insert(0, relative_to)

        # add to eggs
        pkg_resources.working_set.add_entry(relative_to)
        ctx = loadwsgi.loadcontext(loadwsgi.SERVER, config_url,
                                relative_to=relative_to)

        if not opts.workers:
            opts.workers = ctx.local_conf.get('workers', 1)

        if not opts.umask:
            opts.umask = int(ctx.local_conf.get('umask', UMASK))
            
        if not opts.group:
            opts.group = ctx.local_conf.get('group')
        
        if not opts.user:
            opts.user = ctx.local_conf.get('user')
     
        if not opts.bind:
            host = ctx.local_conf.get('host')
            port = ctx.local_conf.get('port')
            if host:
                if port:
                    bind = "%s:%s" % (host, port)
                else:
                    bind = host
                opts.bind = bind

        if not opts.debug:
            opts.debug = (ctx.global_conf.get('debug') == "true")
            
        opts.default_proc_name= ctx.global_conf.get('__file__')

        app = loadapp(config_url, relative_to=relative_to)
        return app
Exemplo n.º 17
0
def config_factory(args):
    if 'config_url' in args:
        config_url = args['config_url']
        relative_to = args['relative_to']
        global_conf = args['global_conf']
    else:
        config_file = os.path.abspath(args['args'][0])
        config_url = 'config:%s' % (os.path.basename(config_file), )
        relative_to = os.path.dirname(config_file)
        global_conf = {}
        for arg in args['args'][1:]:
            key, value = arg.split('=')
            global_conf[key] = value

    ctx = loadwsgi.loadcontext(loadwsgi.SERVER,
                               config_url,
                               relative_to=relative_to,
                               global_conf=global_conf)

    watch = args.get('watch', None)
    if watch is None:
        watch = []
    if ctx.global_conf['__file__'] not in watch:
        watch.append(ctx.global_conf['__file__'])
    args['watch'] = watch

    args['app_factory'] = 'spawning.paste_factory.app_factory'
    args['config_url'] = config_url
    args['relative_to'] = relative_to
    args['source_directories'] = [relative_to]
    args['global_conf'] = ctx.global_conf

    debug = ctx.global_conf.get('debug', None)
    if debug is not None:
        args['dev'] = (debug == 'true')
    host = ctx.local_conf.get('host', None)
    if host is not None:
        args['host'] = host
    port = ctx.local_conf.get('port', None)
    if port is not None:
        args['port'] = int(port)
    num_processes = ctx.local_conf.get('num_processes', None)
    if num_processes is not None:
        args['num_processes'] = int(num_processes)
    threadpool_workers = ctx.local_conf.get('threadpool_workers', None)
    if threadpool_workers is not None:
        args['threadpool_workers'] = int(threadpool_workers)

    return args
Exemplo n.º 18
0
def synchronize(conf_file, filter_section):
    """
    Process schema synchronization.

    :param conf_file: Filename of configuration path.
    :param filter_section: Name of key_management filter section.
    """
    context = loadwsgi.loadcontext(loadwsgi.FILTER, "config:%s" % (conf_file,), name=filter_section)
    conf = context.config()
    driver = conf.get("crypto_keystore_driver")
    if driver:
        # NOTE(ikharin): The operation of data schema synchronization is
        #               not required for the default driver if it's not
        #               specified into configuration.
        migrate(conf, driver)
Exemplo n.º 19
0
    def create_filter(self, entry_point_name):
        """
        Creates a context for a filter that can subsequently be added
        to a pipeline context.

        :param entry_point_name: entry point of the middleware (Swift only)

        :returns: a filter context
        """
        spec = 'egg:swift#' + entry_point_name
        ctx = loadwsgi.loadcontext(loadwsgi.FILTER,
                                   spec,
                                   global_conf=self.context.global_conf)
        ctx.protocol = 'paste.filter_factory'
        return ctx
Exemplo n.º 20
0
def synchronize(conf_file, filter_section):
    """
    Process schema synchronization.

    :param conf_file: Filename of configuration path.
    :param filter_section: Name of key_management filter section.
    """
    context = loadwsgi.loadcontext(loadwsgi.FILTER,
                                   "config:%s" % (conf_file, ),
                                   name=filter_section)
    conf = context.config()
    driver = conf.get('crypto_keystore_driver')
    if driver:
        #NOTE(ikharin): The operation of data schema synchronization is
        #               not required for the default driver if it's not
        #               specified into configuration.
        migrate(conf, driver)
Exemplo n.º 21
0
def pytest_configure():
    os.environ['TZ'] = 'UTC'
    if not kallithea.is_windows:
        time.tzset()  # only available on Unix

    path = os.getcwd()
    sys.path.insert(0, path)
    pkg_resources.working_set.add_entry(path)

    # Disable INFO logging of test database creation, restore with NOTSET
    logging.disable(logging.INFO)

    context = loadwsgi.loadcontext(loadwsgi.APP,
                                   'config:kallithea/tests/test.ini',
                                   relative_to=path)

    if os.environ.get('TEST_DB'):
        # swap config if we pass environment variable
        context.local_conf['sqlalchemy.url'] = os.environ.get('TEST_DB')

    from kallithea.tests.fixture import create_test_env, create_test_index

    # set KALLITHEA_NO_TMP_PATH=1 to disable re-creating the database and test repos
    if not int(os.environ.get('KALLITHEA_NO_TMP_PATH', 0)):
        create_test_env(TESTS_TMP_PATH, context.config())

    # set KALLITHEA_WHOOSH_TEST_DISABLE=1 to disable whoosh index during tests
    if not int(os.environ.get('KALLITHEA_WHOOSH_TEST_DISABLE', 0)):
        create_test_index(TESTS_TMP_PATH, context.config(), True)

    kallithea.tests.base.testapp = context.create()
    # do initial repo scan
    repo2db_mapper(ScmModel().repo_scan(TESTS_TMP_PATH))

    logging.disable(logging.NOTSET)

    kallithea.tests.base.url = URLGenerator(RootController().mapper,
                                            {'HTTP_HOST': 'example.com'})

    # set fixed language for form messages, regardless of environment settings
    formencode.api.set_stdtranslation(languages=[])
Exemplo n.º 22
0
def pytest_configure():
    os.environ['TZ'] = 'UTC'
    if not kallithea.is_windows:
        time.tzset() # only available on Unix

    path = os.getcwd()
    sys.path.insert(0, path)
    pkg_resources.working_set.add_entry(path)

    # Disable INFO logging of test database creation, restore with NOTSET
    logging.disable(logging.INFO)

    context = loadwsgi.loadcontext(loadwsgi.APP, 'config:kallithea/tests/test.ini', relative_to=path)

    if os.environ.get('TEST_DB'):
        # swap config if we pass environment variable
        context.local_conf['sqlalchemy.url'] = os.environ.get('TEST_DB')

    from kallithea.tests.fixture import create_test_env, create_test_index

    # set KALLITHEA_NO_TMP_PATH=1 to disable re-creating the database and test repos
    if not int(os.environ.get('KALLITHEA_NO_TMP_PATH', 0)):
        create_test_env(TESTS_TMP_PATH, context.config())

    # set KALLITHEA_WHOOSH_TEST_DISABLE=1 to disable whoosh index during tests
    if not int(os.environ.get('KALLITHEA_WHOOSH_TEST_DISABLE', 0)):
        create_test_index(TESTS_TMP_PATH, context.config(), True)

    kallithea.tests.base.testapp = context.create()
    # do initial repo scan
    repo2db_mapper(ScmModel().repo_scan(TESTS_TMP_PATH))

    logging.disable(logging.NOTSET)

    kallithea.tests.base.url = URLGenerator(RootController().mapper, {'HTTP_HOST': 'example.com'})

    # set fixed language for form messages, regardless of environment settings
    formencode.api.set_stdtranslation(languages=[])
Exemplo n.º 23
0
def paste_config(gconfig, config_url, relative_to, global_conf=None):
    # add entry to pkg_resources
    sys.path.insert(0, relative_to)
    pkg_resources.working_set.add_entry(relative_to)

    config_url = config_url.split("#")[0]
    cx = loadwsgi.loadcontext(SERVER,
                              config_url,
                              relative_to=relative_to,
                              global_conf=global_conf)
    gc, lc = cx.global_conf.copy(), cx.local_conf.copy()
    cfg = {}

    host, port = lc.pop("host", ""), lc.pop("port", "")
    if host and port:
        cfg["bind"] = "%s:%s" % (host, port)
    elif host:
        cfg["bind"] = host.split(",")

    cfg["default_proc_name"] = gc.get("__file__")

    # init logging configuration
    config_file = config_url.split(":")[1]
    if _has_logging_config(config_file):
        cfg.setdefault("logconfig", config_file)

    for k, v in gc.items():
        if k not in gconfig.settings:
            continue
        cfg[k] = v

    for k, v in lc.items():
        if k not in gconfig.settings:
            continue
        cfg[k] = v

    return cfg
Exemplo n.º 24
0
 def get_context(self, object_type, name=None, global_conf=None):
     if self.absolute_name(name):
         return loadcontext(object_type, name,
                            relative_to=os.path.dirname(self.filename),
                            global_conf=global_conf)
     section = self.find_config_section(
         object_type, name=name)
     if global_conf is None:
         global_conf = {}
     else:
         global_conf = global_conf.copy()
     defaults = self.parser.defaults()
     global_conf.update(defaults)
     local_conf = {}
     global_additions = {}
     get_from_globals = {}
     for option in self.parser.options(section):
         if option.startswith('set '):
             name = option[4:].strip()
             global_additions[name] = global_conf[name] = (
                 self.parser.get(section, option))
         elif option.startswith('get '):
             name = option[4:].strip()
             get_from_globals[name] = self.parser.get(section, option)
         else:
             if option in defaults:
                 # @@: It's a global option (?), so skip it
                 continue
             local_conf[option] = self.parser.get(section, option)
     for local_var, glob_var in get_from_globals.items():
         local_conf[local_var] = global_conf[glob_var]
     if object_type in (APP, FILTER) and 'filter-with' in local_conf:
         filter_with = local_conf.pop('filter-with')
     else:
         filter_with = None
     if 'require' in local_conf:
         for spec in local_conf['require'].split():
             pkg_resources.require(spec)
         del local_conf['require']
     # Additional sections
     is_section_func = False
     for sect, parser in self.SECTION_PASTER:
         parser_func = getattr(self, parser)
         if callable(parser_func):
             if section.startswith(sect):
                 context = parser_func(
                     object_type, section, name=name,
                     global_conf=global_conf, local_conf=local_conf,
                     global_additions=global_additions)
                 is_section_func = True
                 break
     if not is_section_func:
         if 'use' in local_conf:
             context = self._context_from_use(
                 object_type, local_conf, global_conf, global_additions,
                 section)
         else:
             context = self._context_from_explicit(
                 object_type, local_conf, global_conf, global_additions,
                 section)
     if filter_with is not None:
         filter_with_context = LoaderContext(
             obj=None,
             object_type=FILTER_WITH,
             protocol=None,
             global_conf=global_conf, local_conf=local_conf,
             loader=self)
         filter_with_context.filter_context = self.filter_context(
             name=filter_with, global_conf=global_conf)
         filter_with_context.next_context = context
         return filter_with_context
     return context
Exemplo n.º 25
0
def pytest_configure():
    os.environ['TZ'] = 'UTC'
    if not kallithea.is_windows:
        time.tzset()  # only available on Unix

    path = os.getcwd()
    sys.path.insert(0, path)
    pkg_resources.working_set.add_entry(path)

    # Disable INFO logging of test database creation, restore with NOTSET
    logging.disable(logging.INFO)

    ini_settings = {
        '[server:main]': {
            'port': '4999',
        },
        '[app:main]': {
            'ssh_enabled': 'true',
            # Mainly to safeguard against accidentally overwriting the real one:
            'ssh_authorized_keys': os.path.join(TESTS_TMP_PATH,
                                                'authorized_keys'),
            #'ssh_locale': 'C',
            'app_instance_uuid': 'test',
            'show_revision_number': 'true',
            'session.secret': '{74e0cd75-b339-478b-b129-07dd221def1f}',
            #'i18n.lang': '',
        },
        '[handler_console]': {
            'formatter': 'color_formatter',
        },
        # The 'handler_console_sql' block is very similar to the one in
        # development.ini, but without the explicit 'level=DEBUG' setting:
        # it causes duplicate sqlalchemy debug logs, one through
        # handler_console_sql and another through another path.
        '[handler_console_sql]': {
            'formatter': 'color_formatter_sql',
        },
    }
    if os.environ.get('TEST_DB'):
        ini_settings['[app:main]']['sqlalchemy.url'] = os.environ.get(
            'TEST_DB')

    test_ini_file = os.path.join(TESTS_TMP_PATH, 'test.ini')
    inifile.create(test_ini_file, None, ini_settings)

    context = loadwsgi.loadcontext(loadwsgi.APP, 'config:%s' % test_ini_file)
    from kallithea.tests.fixture import create_test_env, create_test_index

    # set KALLITHEA_NO_TMP_PATH=1 to disable re-creating the database and test repos
    if not int(os.environ.get('KALLITHEA_NO_TMP_PATH', 0)):
        create_test_env(TESTS_TMP_PATH, context.config())

    # set KALLITHEA_WHOOSH_TEST_DISABLE=1 to disable whoosh index during tests
    if not int(os.environ.get('KALLITHEA_WHOOSH_TEST_DISABLE', 0)):
        create_test_index(TESTS_TMP_PATH, context.config(), True)

    kallithea.tests.base.testapp = context.create()
    # do initial repo scan
    repo2db_mapper(ScmModel().repo_scan(TESTS_TMP_PATH))

    logging.disable(logging.NOTSET)

    kallithea.tests.base.url = URLGenerator(RootController().mapper,
                                            {'HTTP_HOST': 'example.com'})

    # set fixed language for form messages, regardless of environment settings
    formencode.api.set_stdtranslation(languages=[])
Exemplo n.º 26
0
def loadcontext(object_type, uri, name=None, relative_to=None, global_conf=None):
    add_conf_type = wrap_conf_type(lambda x: x)
    return loadwsgi.loadcontext(
        object_type, add_conf_type(uri), name=name, relative_to=relative_to, global_conf=global_conf
    )
Exemplo n.º 27
0
def loadcontext(object_type, uri, name=None, relative_to=None,
                global_conf=None):
    conf_file = uri
    relative_to = '.'
    return loadwsgi.loadcontext(loadwsgi.APP, 'config:'+conf_file, name=name, relative_to=relative_to, global_conf=global_conf)