mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-04-19 02:11:32 +00:00
Reformat everything.
This commit is contained in:
parent
3f2213791a
commit
340ff8586d
1008 changed files with 61301 additions and 58309 deletions
|
|
@ -95,15 +95,15 @@ def install_package(module, name, easy_install, executable_arguments):
|
|||
def _is_package_installed(module, name, easy_install, executable_arguments):
|
||||
# Copy and add to the arguments
|
||||
executable_arguments = executable_arguments[:]
|
||||
executable_arguments.append('--dry-run')
|
||||
executable_arguments.append("--dry-run")
|
||||
rc, out, err = install_package(module, name, easy_install, executable_arguments)
|
||||
if rc:
|
||||
module.fail_json(msg=err)
|
||||
return 'Downloading' not in out
|
||||
return "Downloading" not in out
|
||||
|
||||
|
||||
def _get_easy_install(module, env=None, executable=None):
|
||||
candidate_easy_inst_basenames = ['easy_install']
|
||||
candidate_easy_inst_basenames = ["easy_install"]
|
||||
easy_install = None
|
||||
if executable is not None:
|
||||
if os.path.isabs(executable):
|
||||
|
|
@ -115,7 +115,7 @@ def _get_easy_install(module, env=None, executable=None):
|
|||
opt_dirs = []
|
||||
else:
|
||||
# Try easy_install with the virtualenv directory first.
|
||||
opt_dirs = [f'{env}/bin']
|
||||
opt_dirs = [f"{env}/bin"]
|
||||
for basename in candidate_easy_inst_basenames:
|
||||
easy_install = module.get_bin_path(basename, False, opt_dirs)
|
||||
if easy_install is not None:
|
||||
|
|
@ -131,39 +131,37 @@ def _get_easy_install(module, env=None, executable=None):
|
|||
def main():
|
||||
arg_spec = dict(
|
||||
name=dict(required=True),
|
||||
state=dict(default='present',
|
||||
choices=['present', 'latest'],
|
||||
type='str'),
|
||||
state=dict(default="present", choices=["present", "latest"], type="str"),
|
||||
virtualenv=dict(),
|
||||
virtualenv_site_packages=dict(default=False, type='bool'),
|
||||
virtualenv_command=dict(default='virtualenv'),
|
||||
executable=dict(default='easy_install'),
|
||||
virtualenv_site_packages=dict(default=False, type="bool"),
|
||||
virtualenv_command=dict(default="virtualenv"),
|
||||
executable=dict(default="easy_install"),
|
||||
)
|
||||
|
||||
module = AnsibleModule(argument_spec=arg_spec, supports_check_mode=True)
|
||||
|
||||
name = module.params['name']
|
||||
env = module.params['virtualenv']
|
||||
executable = module.params['executable']
|
||||
site_packages = module.params['virtualenv_site_packages']
|
||||
virtualenv_command = module.params['virtualenv_command']
|
||||
name = module.params["name"]
|
||||
env = module.params["virtualenv"]
|
||||
executable = module.params["executable"]
|
||||
site_packages = module.params["virtualenv_site_packages"]
|
||||
virtualenv_command = module.params["virtualenv_command"]
|
||||
executable_arguments = []
|
||||
if module.params['state'] == 'latest':
|
||||
executable_arguments.append('--upgrade')
|
||||
if module.params["state"] == "latest":
|
||||
executable_arguments.append("--upgrade")
|
||||
|
||||
rc = 0
|
||||
err = ''
|
||||
out = ''
|
||||
err = ""
|
||||
out = ""
|
||||
|
||||
if env:
|
||||
virtualenv = module.get_bin_path(virtualenv_command, True)
|
||||
|
||||
if not os.path.exists(os.path.join(env, 'bin', 'activate')):
|
||||
if not os.path.exists(os.path.join(env, "bin", "activate")):
|
||||
if module.check_mode:
|
||||
module.exit_json(changed=True)
|
||||
command = f'{virtualenv} {env}'
|
||||
command = f"{virtualenv} {env}"
|
||||
if site_packages:
|
||||
command += ' --system-site-packages'
|
||||
command += " --system-site-packages"
|
||||
cwd = tempfile.gettempdir()
|
||||
rc_venv, out_venv, err_venv = module.run_command(command, cwd=cwd)
|
||||
|
||||
|
|
@ -191,9 +189,8 @@ def main():
|
|||
if rc != 0:
|
||||
module.fail_json(msg=err, cmd=cmd)
|
||||
|
||||
module.exit_json(changed=changed, binary=easy_install,
|
||||
name=name, virtualenv=env)
|
||||
module.exit_json(changed=changed, binary=easy_install, name=name, virtualenv=env)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue