From 33a900ea0fddd57168adcc732fffb6c05e3dfc79 Mon Sep 17 00:00:00 2001 From: Matheus Faria Date: Mon, 7 Sep 2015 15:21:03 -0300 Subject: [PATCH] Fix widget import path --- colab/utils/conf.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/colab/utils/conf.py b/colab/utils/conf.py index df6d892..dbf31db 100644 --- a/colab/utils/conf.py +++ b/colab/utils/conf.py @@ -142,30 +142,38 @@ def load_widgets_settings(): '/etc/colab/widgets_settings.py') settings_module = settings_file.split('.')[-2].split('/')[-1] py_path = "/".join(settings_file.split('/')[:-1]) - logger.info('Widgets Settings file: %s', settings_file) if not os.path.exists(py_path): msg = "The py file {} does not exist".format(py_path) raise InaccessibleSettings(msg) - py_settings = _load_py_file(settings_module, py_path) + original_path = sys.path + sys.path.append(py_path) + importlib.import_module(settings_module) - # Read settings from settings.d + # Read settings from widgets.d settings_dir = '/etc/colab/widgets.d' logger.info('Widgets Settings directory: %s', settings_dir) + sys.path = original_path if not os.path.exists(settings_dir): - return py_settings + return for file_name in os.listdir(settings_dir): if not file_name.endswith('.py'): continue + original_path = sys.path + sys.path.append(settings_dir) + file_module = file_name.split('.')[0] - _load_py_file(file_module, settings_dir) + importlib.import_module(file_module) logger.info('Loaded %s/%s', settings_dir, file_name) + sys.path = original_path + + def validate_database(database_dict, default_db, debug): db_name = database_dict.get('default', {}).get('NAME') if not debug and db_name == default_db: -- libgit2 0.21.2