Skip to content

Commit

Permalink
Addressed bug in re-ordering of vars/cli options ordering for Pyton 2.x
Browse files Browse the repository at this point in the history
Inadvertently set the value for an intermediary variable to result of a dict.update() action, which resulted in None, as this is the default return
value for a dictionary update
  • Loading branch information
Tejeda, Engelbert committed Sep 23, 2019
1 parent 4244faf commit dc82860
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions ansible_taskrunner/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,20 +336,24 @@ def run(args=None, **kwargs):
# which they were called
if sys.version_info[0] < 3:
# First we build a mapping of cli variables to corresponding yaml variables
parameter_mapping = {}
req_parameters = yaml_vars.get('required_parameters', {}) or {}
opt_parameters = yaml_vars.get('optional_parameters', {}) or {}
# We need to 'inject' built-in cli options
# since we're artificially re-ordering things
opt_parameters['---make|---m'] = 'make_mode_engage'
opt_parameters['---raw'] = '_raw'
opt_parameters['---echo'] = '_echo'
# We're working with the optional
# parameter set in either case
if req_parameters:
parameter_mapping = dict(opt_parameters).update(dict(req_parameters))
dict(opt_parameters).update(dict(req_parameters))
parameter_mapping = opt_parameters
else:
parameter_mapping = dict(opt_parameters)
dict(opt_parameters)
parameter_mapping = opt_parameters
# Next, we create a dictionary that holds cli arguments
# in the order they were called, as per the parameter mapping
ordered_args = {}
for k, v in parameter_mapping.items():
for a in sys.argv:
if re.search(k, a):
Expand Down

0 comments on commit dc82860

Please sign in to comment.