diff --git a/vcsserver/config/settings_maker.py b/vcsserver/config/settings_maker.py --- a/vcsserver/config/settings_maker.py +++ b/vcsserver/config/settings_maker.py @@ -54,6 +54,9 @@ def aslist(obj, sep=None, strip=True): :param strip: """ if isinstance(obj, (basestring,)): + if obj in ['', ""]: + return [] + lst = obj.split(sep) if strip: lst = [v.strip() for v in lst] @@ -116,11 +119,12 @@ class SettingsMaker(object): def _key_transformator(cls, key): return "{}_{}".format('RC'.upper(), key.upper().replace('.', '_').replace('-', '_')) - def enable_logging(self, logging_conf=None): + def enable_logging(self, logging_conf=None, level='INFO', formatter='generic'): """ Helper to enable debug on running instance :return: """ + if not str2bool(self.settings.get('logging.autoconfigure')): log.info('logging configuration based on main .ini file') return @@ -135,6 +139,14 @@ class SettingsMaker(object): with open(logging_conf, 'rb') as f: ini_template = textwrap.dedent(f.read()) ini_template = string.Template(ini_template).safe_substitute( + RC_LOGGING_LEVEL=os.environ.get('RC_LOGGING_LEVEL', '') or level, + RC_LOGGING_FORMATTER=os.environ.get('RC_LOGGING_FORMATTER', '') or formatter + ) + + + with open(logging_conf, 'rb') as f: + ini_template = textwrap.dedent(f.read()) + ini_template = string.Template(ini_template).safe_substitute( RC_LOGGING_LEVEL=os.environ.get('RC_LOGGING_LEVEL', '') or 'INFO', RC_LOGGING_FORMATTER=os.environ.get('RC_LOGGING_FORMATTER', '') or 'generic' ) @@ -159,6 +171,7 @@ class SettingsMaker(object): 'int': self._int_func, 'list': self._list_func, 'list:newline': functools.partial(self._list_func, sep='/n'), + 'list:spacesep': functools.partial(self._list_func, sep=' '), 'string': functools.partial(self._string_func, lower=lower), 'dir': self._dir_func, 'dir:ensured': functools.partial(self._dir_func, ensure_dir=True), diff --git a/vcsserver/tests/test_http_performance.py b/vcsserver/tests/test_http_performance.py --- a/vcsserver/tests/test_http_performance.py +++ b/vcsserver/tests/test_http_performance.py @@ -14,7 +14,10 @@ def vcs_app(): 'dev.use_echo_app': 'true', 'locale': 'en_US.UTF-8', } - vcs_app = main({}, **stub_settings) + stub_global_conf = { + '__file__': '' + } + vcs_app = main(stub_global_conf, **stub_settings) app = webtest.TestApp(vcs_app) return app diff --git a/vcsserver/tests/test_main_http.py b/vcsserver/tests/test_main_http.py --- a/vcsserver/tests/test_main_http.py +++ b/vcsserver/tests/test_main_http.py @@ -25,7 +25,7 @@ from vcsserver.base import obfuscate_qs @mock.patch('vcsserver.http_main.VCS', mock.Mock()) @mock.patch('vcsserver.hgpatches.patch_largefiles_capabilities') def test_applies_largefiles_patch(patch_largefiles_capabilities): - http_main.main({}) + http_main.main({'__file__': ''}) patch_largefiles_capabilities.assert_called_once_with() @@ -35,7 +35,7 @@ def test_applies_largefiles_patch(patch_ 'vcsserver.hgpatches.patch_largefiles_capabilities', mock.Mock(side_effect=Exception("Must not be called"))) def test_applies_largefiles_patch_only_if_mercurial_is_available(): - http_main.main({}) + http_main.main({'__file__': ''}) @pytest.mark.parametrize('given, expected', [