git://git.onelab.eu
/
plstackapi.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
45fb7a1
)
support command line option to specify config file name
author
Scott Baker
<smbaker@gmail.com>
Tue, 31 Dec 2013 08:56:41 +0000
(
00:56
-0800)
committer
Scott Baker
<smbaker@gmail.com>
Tue, 31 Dec 2013 08:56:41 +0000
(
00:56
-0800)
planetstack/planetstack/config.py
patch
|
blob
|
history
diff --git
a/planetstack/planetstack/config.py
b/planetstack/planetstack/config.py
index
b9abd3a
..
86e3bbd
100644
(file)
--- a/
planetstack/planetstack/config.py
+++ b/
planetstack/planetstack/config.py
@@
-7,11
+7,14
@@
import tempfile
import codecs
from StringIO import StringIO
from util.xml import Xml
import codecs
from StringIO import StringIO
from util.xml import Xml
+from optparse import OptionParser
default_config = \
"""
"""
default_config = \
"""
"""
+DEFAULT_CONFIG_FN = '/opt/planetstack/plstackapi_config'
+
def isbool(v):
return v.lower() in ("true", "false")
def isbool(v):
return v.lower() in ("true", "false")
@@
-20,7
+23,10
@@
def str2bool(v):
class Config:
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._files = []
self.config_path = os.path.dirname(config_file)
self.config = ConfigParser.ConfigParser()
@@
-29,6
+35,16
@@
class Config:
self.create(self.filename)
self.load(self.filename)
self.create(self.filename)
self.load(self.filename)
+ def get_config_fn(self):
+ parser = OptionParser(usage="%s [options]" % sys.argv[0],
+ description="The planetstack observer")
+
+ parser.add_option("-C", "--config-file", dest="config_fn",
+ help="name of observer config file", metavar="FILENAME", default=DEFAULT_CONFIG_FN)
+
+ (options, args) = parser.parse_args(sys.argv[1:])
+
+ return options.config_fn
def _header(self):
header = """
def _header(self):
header = """