diff --git a/src/emanesh/emanesh/emaneshell.py b/src/emanesh/emanesh/emaneshell.py index 555f5103..79f3bd90 100644 --- a/src/emanesh/emanesh/emaneshell.py +++ b/src/emanesh/emanesh/emaneshell.py @@ -752,6 +752,17 @@ def do_set(self,args): if len(args) > index: for expression in args[index:]: m = re.match('^([0-9A-Za-z]+)=(.+)', expression) + + def toBool(val): + val = val.lower() + + if val in ('yes','on','enable','true','1'): + return True + elif val in ('no','off','disable','false','0'): + return False + else: + raise ValueError() + convert = {'uint64' : (ControlPortClient.TYPE_UINT64,long), 'uint32' : (ControlPortClient.TYPE_UINT32,long), 'uint16' : (ControlPortClient.TYPE_UINT16,long), @@ -760,7 +771,7 @@ def do_set(self,args): 'int32' : (ControlPortClient.TYPE_INT32,long), 'int16' : (ControlPortClient.TYPE_INT16,long), 'int8' : (ControlPortClient.TYPE_INT8,long), - 'bool' : (ControlPortClient.TYPE_BOOLEAN,bool), + 'bool' : (ControlPortClient.TYPE_BOOLEAN,toBool), 'string': (ControlPortClient.TYPE_STRING,str), 'inetaddr' : (ControlPortClient.TYPE_INETADDR,str), 'float' : (ControlPortClient.TYPE_FLOAT,float),