git://git.onelab.eu
/
sfa.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
d35bea5
)
fix bools in output_shell
author
Tony Mack
<tmack@paris.CS.Princeton.EDU>
Mon, 6 Aug 2012 00:40:26 +0000
(20:40 -0400)
committer
Tony Mack
<tmack@paris.CS.Princeton.EDU>
Mon, 6 Aug 2012 00:40:26 +0000
(20:40 -0400)
sfa/util/config.py
patch
|
blob
|
history
diff --git
a/sfa/util/config.py
b/sfa/util/config.py
index
272e49e
..
32b95b9
100644
(file)
--- a/
sfa/util/config.py
+++ b/
sfa/util/config.py
@@
-12,6
+12,12
@@
default_config = \
"""
"""
"""
"""
+def isbool(v):
+ return v.lower() in ("true", "false")
+
+def str2bool(v):
+ return v.lower() in ("true", "1")
+
class Config:
def __init__(self, config_file='/etc/sfa/sfa_config'):
class Config:
def __init__(self, config_file='/etc/sfa/sfa_config'):
@@
-107,7
+113,6
@@
DO NOT EDIT. This file was automatically generated at
for item in self.config.items(section):
name = "%s_%s" % (section, item[0])
value = item[1]
for item in self.config.items(section):
name = "%s_%s" % (section, item[0])
value = item[1]
- if
setattr(self, name, value)
setattr(self, name.upper(), value)
setattr(self, name, value)
setattr(self, name.upper(), value)
@@
-163,7
+168,9
@@
DO NOT EDIT. This file was automatically generated at
# bash does not have the concept of NULL
if value:
option = "%s_%s" % (section.upper(), name.upper())
# bash does not have the concept of NULL
if value:
option = "%s_%s" % (section.upper(), name.upper())
- if not isinstance(value, bool) and not value.isdigit():
+ if isbool(value):
+ value = str(str2bool(value))
+ elif not value.isdigit():
value = '"%s"' % value
buf.write(option + "=" + value + os.linesep)
return buf.getvalue()
value = '"%s"' % value
buf.write(option + "=" + value + os.linesep)
return buf.getvalue()