From b3469b44a6e6056e3efa422efcba829c5eac3f9e Mon Sep 17 00:00:00 2001 From: Mattia Mancini <mancini@astron.nl> Date: Wed, 15 Nov 2017 15:24:18 +0000 Subject: [PATCH] Task #11487: update of files --- LCS/PyCommon/defaultmailaddresses.py | 50 +++++++++++++++++++++++++++- LCS/PyCommon/test/CMakeLists.txt | 1 + 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/LCS/PyCommon/defaultmailaddresses.py b/LCS/PyCommon/defaultmailaddresses.py index ba1798899e7..c00fe99087e 100644 --- a/LCS/PyCommon/defaultmailaddresses.py +++ b/LCS/PyCommon/defaultmailaddresses.py @@ -24,5 +24,53 @@ This package contains the default mail addresses used in the LOFAR software """ +from ConfigParser import ConfigParser + +# obtain the environment, and add USER and HOME if needed (since supervisord does not) +environ = os.environ +user_info = pwd.getpwuid(os.getuid()) +environ.setdefault("HOME", user_info.pw_dir) +environ.setdefault("USER", user_info.pw_name) + + + +def findfiles(pattern): + """ Returns a list of files matched by `pattern'. + The pattern can include environment variables using the + {VAR} notation. + """ + try: + return glob(pattern.format(**environ)) + except KeyError: + return [] + + # Addresses used for the pipelines -pipelines = {"error-sender":"softwaresupport@lofar.eu"} +class PipelineConfig(): + """ + Pipeline configuration class + """ + + def __init__(self, filepatterns = None): + if self.pattern: + self.pattern = ["{LOFARROOT}/etc/pipeline/*.ini", + "{HOME}/.lofar/pipeline/*.ini"]# TODO correct the pattern here + self.configfiles = sum([findfiles(p) for p in self.pattern],[]) + self.config = None + + ## Load the config files + self.load_config() + + def load_config(self): + self.config = ConfigParser() + + def get(self, key): + return self.config.getstring("Pipeline",key) + + def __getitem__(self, what): + return get(what) +#pipelines = {"error-sender":"softwaresupport@lofar.eu"} + + + + diff --git a/LCS/PyCommon/test/CMakeLists.txt b/LCS/PyCommon/test/CMakeLists.txt index 1f219cba046..cfdbe99b2d3 100644 --- a/LCS/PyCommon/test/CMakeLists.txt +++ b/LCS/PyCommon/test/CMakeLists.txt @@ -8,6 +8,7 @@ file(COPY lofar_add_test(t_cache) lofar_add_test(t_dbcredentials) +lofar_add_test(t_defaultpipelineconfig) lofar_add_test(t_methodtrigger) lofar_add_test(t_util) lofar_add_test(t_test_utils) -- GitLab