"""
"""
+DEFAULT_CONFIG_FN = '/opt/planetstack/plstackapi_config'
+
def isbool(v):
return v.lower() in ("true", "false")
class Config:
- def __init__(self, config_file='/opt/planetstack/plstackapi_config'):
+ def __init__(self, config_file=None):
+ if (config_file==None):
+ config_file = self.get_config_fn()
+
self._files = []
self.config_path = os.path.dirname(config_file)
self.config = ConfigParser.ConfigParser()
self.create(self.filename)
self.load(self.filename)
+ def get_config_fn(self):
+ # Look for "-C <something>" to get the
+ # name of the config file. Using a real OptionParser here is
+ # problematic as it will throw 'no such option' errors for options
+ # that it does not understand.
+
+ last = None
+ for arg in sys.argv:
+ if (last=="-C"):
+ return arg
+ last = arg
+
+ return DEFAULT_CONFIG_FN
def _header(self):
header = """