mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 21:32:49 +00:00
Migrate remaining modules to use get_bin_path in module_common.py
* Migraed easy_install, pip, service, setup, and user. * Updated fail_json message in apt_repository * Fixed easy_install to not hardcode location of virtualenv in /usr/local/bin/. * Made handling of virtualenv more consistent between easy_install and pip.
This commit is contained in:
@@ -19,18 +19,6 @@
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
def _find_easy_install(env):
|
||||
if env:
|
||||
return os.path.join(env, 'bin', 'easy_install')
|
||||
|
||||
paths = ['/usr/local/bin', '/usr/bin']
|
||||
|
||||
for p in paths:
|
||||
e = p + '/easy_install'
|
||||
if os.path.exists(e):
|
||||
return e
|
||||
|
||||
|
||||
def _ensure_virtualenv(env, virtualenv):
|
||||
if os.path.exists(os.path.join(env, 'bin', 'activate')):
|
||||
return 0, '', ''
|
||||
@@ -62,14 +50,20 @@ def main():
|
||||
|
||||
name = module.params['name']
|
||||
env = module.params['virtualenv']
|
||||
easy_install = _find_easy_install(env)
|
||||
easy_install = module.get_bin_path('easy_install', ['%s/bin' % env])
|
||||
if easy_install is None:
|
||||
module.fail_json(msg='easy_install is not installed')
|
||||
|
||||
rc = 0
|
||||
err = ''
|
||||
out = ''
|
||||
|
||||
if env:
|
||||
rc_venv, out_venv, err_venv = _ensure_virtualenv(env, '/usr/local/bin/virtualenv')
|
||||
virtualenv = module.get_bin_path('virtualenv')
|
||||
if virtualenv is None:
|
||||
module.fail_json(msg='virtualenv is not installed')
|
||||
|
||||
rc_venv, out_venv, err_venv = _ensure_virtualenv(env, virtualenv)
|
||||
|
||||
rc += rc_venv
|
||||
out += out_venv
|
||||
|
||||
Reference in New Issue
Block a user