Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It appears that different versions of the argument parser handle boolean conversions differently #469

Merged
merged 1 commit into from Sep 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions pylib/Stages/Reporter/IUDatabase.py
Expand Up @@ -277,12 +277,12 @@ def _submit_test_run(self, logger, lg, metadata, s, url, httpauth=None):
data['merge_stdout_stderr'] = None

try:
data['result_stdout'] = trun['stdout']
data['result_stdout'] = '\n'.join(trun['stdout'])
except KeyError:
data['result_stdout'] = None

try:
data['result_stderr'] = trun['stderr']
data['result_stderr'] = '\n'.join(trun['stderr'])
except KeyError:
data['result_stderr'] = None

Expand Down Expand Up @@ -396,12 +396,12 @@ def _submit_test_build(self, logger, lg, metadata, s, url, httpauth=None):
data['merge_stdout_stderr'] = None

try:
data['result_stdout'] = lg['stdout']
data['result_stdout'] = '\n'.join(lg['stdout'])
except KeyError:
data['result_stdout'] = None

try:
data['result_stderr'] = lg['stderr']
data['result_stderr'] = '\n'.join(lg['stderr'])
except KeyError:
data['result_stderr'] = None

Expand Down Expand Up @@ -558,12 +558,12 @@ def _submit_install(self, logger, lg, metadata, s, url, httpauth=None):
data['merge_stdout_stderr'] = None

try:
data['result_stdout'] = lg['stdout']
data['result_stdout'] = '\n'.join(lg['stdout'])
except KeyError:
data['result_stdout'] = None

try:
data['result_stderr'] = lg['stderr']
data['result_stderr'] = '\n'.join(lg['stderr'])
except KeyError:
data['result_stderr'] = None

Expand Down
57 changes: 47 additions & 10 deletions pylib/System/TestDef.py
Expand Up @@ -106,10 +106,21 @@ def parseOptions(self, log, options, keyvals, target):
continue
if type(options[kvkey][0]) is bool:
# convert the input string to bool
if keyvals[kvkey].upper() in ['TRUE', '1', 'T', 'Y', 'YES']:
target[opt] = True
if type(keyvals[kvkey]) is bool:
target[opt] = keyvals[kvkey]
elif type(keyvals[kvkey]) is str:
if keyvals[kvkey].lower() in ['true', '1', 't', 'y', 'yes']:
target[opt] = True
else:
target[opt] = False
elif type(keyvals[kvkey]) is int:
if 0 == keyvals[kvkey]:
target[opt] = False
else:
target[opt] = True
else:
target[opt] = False
# unknown conversion required
print("Unknown conversion required for option " + keyvals[kvkey])
else:
if len(keyvals[kvkey]) == 0:
# this indicates they do not want this option
Expand All @@ -124,21 +135,47 @@ def parseOptions(self, log, options, keyvals, target):
# convert the values to specified type
i=0
for val in newvals:
# if the target is type bool, then we need to ensure
# we properly convert the input to also be bool
if type(opt[0]) is bool:
if val.lower in ['true', '1', 't', 'y', 'yes', 'yeah', 'yup', 'certainly', 'uh-huh']:
newvals[i] = True
if type(val) is bool:
newvals[i] = val
elif type(val) is str:
if val.lower in ['true', '1', 't', 'y', 'yes']:
newvals[i] = True
else:
newvals[i] = False
elif type(val) is int:
if 0 == val:
target[opt] = False
else:
target[opt] = True
else:
newvals[i] = False
# unknown conversion required
print("Unknown conversion required for option " + val)
pass
i = i + 1
target[opt] = newvals
else:
val = keyvals[kvkey]
if type(opt[0]) is bool:
if val.lower in ['true', '1', 't', 'y', 'yes', 'yeah', 'yup', 'certainly', 'uh-huh']:
val = True
if type(val) is bool:
target[opt] = val
elif type(val) is str:
if val.lower in ['true', '1', 't', 'y', 'yes']:
target[opt] = True
else:
target[opt] = False
elif type(val) is int:
if 0 == val:
target[opt] = False
else:
target[opt] = True
else:
val = False
target[opt] = val
# unknown conversion required
print("Unknown conversion required for option " + val)
else:
target[opt] = val
found = True
break
if not found:
Expand Down