fix bools in output_shell
authorTony Mack <tmack@paris.CS.Princeton.EDU>
Mon, 6 Aug 2012 00:40:26 +0000 (20:40 -0400)
committerTony Mack <tmack@paris.CS.Princeton.EDU>
Mon, 6 Aug 2012 00:40:26 +0000 (20:40 -0400)
sfa/util/config.py

index 272e49e..32b95b9 100644 (file)
@@ -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()