From de281c102f90bf628b08cadf8490cf11c40fa812 Mon Sep 17 00:00:00 2001 From: Tony Mack Date: Sun, 5 Aug 2012 20:40:26 -0400 Subject: [PATCH] fix bools in output_shell --- sfa/util/config.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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() -- 2.43.0