diff --git a/src/scripts/blah.py b/src/scripts/blah.py index 4f53795..9f0a3b5 100755 --- a/src/scripts/blah.py +++ b/src/scripts/blah.py @@ -1,11 +1,21 @@ """Common functions for BLAH python scripts""" +import os from configparser import RawConfigParser from io import StringIO class BlahConfigParser(RawConfigParser, object): - def __init__(self, path='/etc/blah.config', defaults=None): + def __init__(self, path=None, defaults=None): + if path is None: + if "BLAHPD_CONFIG_LOCATION" in os.environ: + path = os.environ['BLAHPD_CONFIG_LOCATION'] + elif "BLAHPD_LOCATION" in os.environ and os.path.isfile("%s/etc/blah.config" % os.environ['BLAHPD_LOCATION']): + path = "%s/etc/blah.config" % os.environ['BLAHPD_LOCATION'] + elif "GLITE_LOCATION" in os.environ and os.path.isfile("%s/etc/blah.config" % os.environ['GLITE_LOCATION']): + path = "%s/etc/blah.config" % os.environ['GLITE_LOCATION'] + else: + path = "/etc/blah.config" # RawConfigParser requires ini-style [section headers] but since # blah.config is also used as a shell script we need to fake one self.header = 'blahp'