From: Tony Mack Date: Mon, 6 Aug 2012 00:40:26 +0000 (-0400) Subject: fix bools in output_shell X-Git-Tag: sfa-2.1-14~66 X-Git-Url: http://git.onelab.eu/?p=sfa.git;a=commitdiff_plain;h=de281c102f90bf628b08cadf8490cf11c40fa812 fix bools in output_shell --- diff --git a/sfa/util/config.py b/sfa/util/config.py index 272e49e1..32b95b98 100644 --- 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'): @@ -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] - if 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()) - 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()