mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
django_manage - using list instead of string in run_command() (#3098)
* django_manage - using list instead of string in run_command() * added changelog fragment
This commit is contained in:
parent
5be4adc434
commit
0b70b3baff
2 changed files with 21 additions and 21 deletions
2
changelogs/fragments/3098-django_manage-cmd-list.yaml
Normal file
2
changelogs/fragments/3098-django_manage-cmd-list.yaml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
bugfixes:
|
||||||
|
- django_manage - refactor to call ``run_command()`` passing command as a list instead of string (https://github.com/ansible-collections/community.general/pull/3098).
|
|
@ -256,20 +256,20 @@ def main():
|
||||||
argument_spec=dict(
|
argument_spec=dict(
|
||||||
command=dict(required=True, type='str'),
|
command=dict(required=True, type='str'),
|
||||||
project_path=dict(required=True, type='path', aliases=['app_path', 'chdir']),
|
project_path=dict(required=True, type='path', aliases=['app_path', 'chdir']),
|
||||||
settings=dict(default=None, required=False, type='path'),
|
settings=dict(type='path'),
|
||||||
pythonpath=dict(default=None, required=False, type='path', aliases=['python_path']),
|
pythonpath=dict(type='path', aliases=['python_path']),
|
||||||
virtualenv=dict(default=None, required=False, type='path', aliases=['virtual_env']),
|
virtualenv=dict(type='path', aliases=['virtual_env']),
|
||||||
|
|
||||||
apps=dict(default=None, required=False),
|
apps=dict(),
|
||||||
cache_table=dict(default=None, required=False, type='str'),
|
cache_table=dict(type='str'),
|
||||||
clear=dict(default=False, required=False, type='bool'),
|
clear=dict(default=False, type='bool'),
|
||||||
database=dict(default=None, required=False, type='str'),
|
database=dict(type='str'),
|
||||||
failfast=dict(default=False, required=False, type='bool', aliases=['fail_fast']),
|
failfast=dict(default=False, type='bool', aliases=['fail_fast']),
|
||||||
fixtures=dict(default=None, required=False, type='str'),
|
fixtures=dict(type='str'),
|
||||||
testrunner=dict(default=None, required=False, type='str', aliases=['test_runner']),
|
testrunner=dict(type='str', aliases=['test_runner']),
|
||||||
skip=dict(default=None, required=False, type='bool'),
|
skip=dict(type='bool'),
|
||||||
merge=dict(default=None, required=False, type='bool'),
|
merge=dict(type='bool'),
|
||||||
link=dict(default=None, required=False, type='bool'),
|
link=dict(type='bool'),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -279,8 +279,6 @@ def main():
|
||||||
|
|
||||||
for param in specific_params:
|
for param in specific_params:
|
||||||
value = module.params[param]
|
value = module.params[param]
|
||||||
if param in specific_boolean_params:
|
|
||||||
value = module.boolean(value)
|
|
||||||
if value and param not in command_allowed_param_map[command]:
|
if value and param not in command_allowed_param_map[command]:
|
||||||
module.fail_json(msg='%s param is incompatible with command=%s' % (param, command))
|
module.fail_json(msg='%s param is incompatible with command=%s' % (param, command))
|
||||||
|
|
||||||
|
@ -290,23 +288,23 @@ def main():
|
||||||
|
|
||||||
_ensure_virtualenv(module)
|
_ensure_virtualenv(module)
|
||||||
|
|
||||||
cmd = "./manage.py %s" % (command, )
|
cmd = ["./manage.py", command]
|
||||||
|
|
||||||
if command in noinput_commands:
|
if command in noinput_commands:
|
||||||
cmd = '%s --noinput' % cmd
|
cmd.append("--noinput")
|
||||||
|
|
||||||
for param in general_params:
|
for param in general_params:
|
||||||
if module.params[param]:
|
if module.params[param]:
|
||||||
cmd = '%s --%s=%s' % (cmd, param, module.params[param])
|
cmd.append('--%s=%s' % (param, module.params[param]))
|
||||||
|
|
||||||
for param in specific_boolean_params:
|
for param in specific_boolean_params:
|
||||||
if module.boolean(module.params[param]):
|
if module.params[param]:
|
||||||
cmd = '%s --%s' % (cmd, param)
|
cmd.append('--%s' % param)
|
||||||
|
|
||||||
# these params always get tacked on the end of the command
|
# these params always get tacked on the end of the command
|
||||||
for param in end_of_command_params:
|
for param in end_of_command_params:
|
||||||
if module.params[param]:
|
if module.params[param]:
|
||||||
cmd = '%s %s' % (cmd, module.params[param])
|
cmd.append(module.params[param])
|
||||||
|
|
||||||
rc, out, err = module.run_command(cmd, cwd=project_path)
|
rc, out, err = module.run_command(cmd, cwd=project_path)
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
|
|
Loading…
Reference in a new issue