diff --git a/LCS/PyCommon/defaultmailaddresses.py b/LCS/PyCommon/defaultmailaddresses.py index ba1798899e71fc79c71b16167ee3a9d29da4f38b..c00fe99087e097418b38e548022876bd2487541e 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 1f219cba046fd9c580029cace58ee1248dca5c86..cfdbe99b2d385aa153f3df20e0221e283c5b2600 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)