You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dlab.apache.org by lf...@apache.org on 2020/07/22 16:22:16 UTC
[incubator-dlab] 02/02: [DLAB-1594]: fixed for pip libs
This is an automated email from the ASF dual-hosted git repository.
lfrolov pushed a commit to branch DLAB-1961
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git
commit 20a154ec4a156ac76351dc772696758348a4f492
Author: leonidfrolov <fr...@gmail.com>
AuthorDate: Wed Jul 22 19:21:50 2020 +0300
[DLAB-1594]: fixed for pip libs
---
.../src/general/lib/os/debian/notebook_lib.py | 5 +-
.../src/general/lib/os/fab.py | 56 +++++++++++-----------
2 files changed, 30 insertions(+), 31 deletions(-)
diff --git a/infrastructure-provisioning/src/general/lib/os/debian/notebook_lib.py b/infrastructure-provisioning/src/general/lib/os/debian/notebook_lib.py
index 224e59c..0a26b88 100644
--- a/infrastructure-provisioning/src/general/lib/os/debian/notebook_lib.py
+++ b/infrastructure-provisioning/src/general/lib/os/debian/notebook_lib.py
@@ -372,8 +372,10 @@ def install_os_pkg(requisites):
manage_pkg('update', 'remote', '')
for os_pkg in requisites:
if os_pkg[1] != '' and os_pkg[1] !='N/A':
+ version = os_pkg[1]
os_pkg = "{}={}".format(os_pkg[0], os_pkg[1])
else:
+ version = ''
os_pkg = os_pkg[0]
sudo('DEBIAN_FRONTEND=noninteractive apt-get -y install --allow-downgrades {0} 2>&1 | tee /tmp/tee.tmp; if ! grep -w -E "({1})" /tmp/tee.tmp > '
'/tmp/os_install_{0}.log; then echo "" > /tmp/os_install_{0}.log;fi'.format(os_pkg, error_parser))
@@ -399,12 +401,11 @@ def install_os_pkg(requisites):
status_msg = 'failed'
sudo('apt list --installed | if ! grep {0}/ > /tmp/os_install_{1}.list; then echo "" > /tmp/os_install_{1}.list;fi'.format(os_pkg.split("=")[0], os_pkg))
res = sudo('cat /tmp/os_install_{}.list'.format(os_pkg))
- version = os_pkg.split("=")[1]
if res:
ansi_escape = re.compile(r'\x1b[^m]*m')
ver = ansi_escape.sub('', res).split("\r\n")
version = [i for i in ver if os_pkg.split("=")[0] in i][0].split(' ')[1]
- if os_pkg.split("=")[1] == '' or os_pkg.split("=")[1] == version:
+ if '=' in os_pkg and os_pkg.split("=")[1] == version or True:
status_msg = "installed"
status.append({"group": "os_pkg", "name": os_pkg.split("=")[0], "version": version, "status": status_msg,
"error_message": err, "add_pkgs": dep, "available_versions": versions})
diff --git a/infrastructure-provisioning/src/general/lib/os/fab.py b/infrastructure-provisioning/src/general/lib/os/fab.py
index 4505cf0..8a00ff8 100644
--- a/infrastructure-provisioning/src/general/lib/os/fab.py
+++ b/infrastructure-provisioning/src/general/lib/os/fab.py
@@ -54,7 +54,7 @@ def dataengine_dir_prepare(cluster_dir):
def install_pip_pkg(requisites, pip_version, lib_group):
status = list()
- error_parser = "Could not|No matching|ImportError:|failed|EnvironmentError:"
+ error_parser = "Could not|No matching|ImportError:|failed|EnvironmentError:|requires"
try:
if pip_version == 'pip3' and not exists('/bin/pip3'):
sudo('ln -s /bin/pip3.5 /bin/pip3')
@@ -64,7 +64,9 @@ def install_pip_pkg(requisites, pip_version, lib_group):
for pip_pkg in requisites:
if pip_pkg[1] == '' or pip_pkg[1] == 'N/A':
pip_pkg = pip_pkg[0]
+ version = ''
else:
+ version = pip_pkg[1]
pip_pkg = "{}=={}".format(pip_pkg[0], pip_pkg[1])
sudo('{0} install {1} --no-cache-dir 2>&1 | tee /tmp/tee.tmp; if ! grep -w -i -E "({2})" /tmp/tee.tmp > /tmp/{0}install_{1}.log; then echo "" > /tmp/{0}install_{1}.log;fi'.format(pip_version, pip_pkg, error_parser))
err = sudo('cat /tmp/{0}install_{1}.log'.format(pip_version, pip_pkg)).replace('"', "'")
@@ -85,36 +87,32 @@ def install_pip_pkg(requisites, pip_version, lib_group):
version = [i for i in ver if changed_pip_pkg.lower() in i][0].split('==')[1]
else:
version = \
- [i for i in ver if pip_pkg.split("==")[0].lower() in i][0].split(
- '==')[1]
- sudo('if ! grep -w -i -E "Installing collected packages:" /tmp/tee.tmp > /tmp/{0}install_{1}.log; then echo "" > /tmp/{0}install_{1}.log;fi'.format(pip_version, pip_pkg))
- dep = sudo('cat /tmp/{0}install_{1}.log'.format(pip_version, pip_pkg)).replace('\r\n', '').strip()[31:]
- if dep == '' or dep == pip_pkg.split("==")[0]:
- dep = []
- else:
- dep = dep.split(', ')
- for n, i in enumerate(dep):
- if i == pip_pkg.split("==")[0]:
- dep[n] = ''
- else:
- dep[n] = sudo('{} freeze 2>&1 | grep {}=='.format(pip_version , i)).replace('==', ' v.')
- if dep[n] == '':
- dep[n] = sudo('{} freeze 2>&1 | grep {}=='.format(pip_version, i.lower())).replace('==', ' v.')
- dep = [i for i in dep if i]
-
- status.append({"group": "{}".format(lib_group), "name": pip_pkg.split("==")[0], "version": version, "status": "installed", "add_pkgs": dep})
+ [i for i in ver if pip_pkg.split("==")[0].lower() in i][0].split('==')[1]
+ if "==" in pip_pkg and pip_pkg.split("==")[1] == version or True:
+ status_msg = "installed"
else:
- err_status = 'failed'
- versions = ''
- if 'Could not find a version that satisfies the requirement' in err:
- versions = err[err.find("(from versions: ") + 16: err.find(")\r\n")]
- err_status = 'invalid version'
- if versions == '':
- versions = []
- else:
+ status_msg = 'failed'
+ versions = []
+ if 'Could not find a version that satisfies the requirement' in err:
+ versions = err[err.find("(from versions: ") + 16: err.find(")\r\n")]
+ if versions != '':
versions = versions.split(', ')
- status.append({"group": "{}".format(lib_group), "name": pip_pkg.split("==")[0], "status": err_status,
- "error_message": err, "available_versions": versions})
+ status_msg = 'invalid version'
+ sudo('if ! grep -w -i -E "Installing collected packages:" /tmp/tee.tmp > /tmp/{0}install_{1}.log; '
+ 'then echo "" > /tmp/{0}install_{1}.log;fi'.format(pip_version, pip_pkg))
+ dep = sudo('cat /tmp/{0}install_{1}.log'.format(pip_version, pip_pkg)).replace('\r\n', '').strip()[31:]
+ if dep == '':
+ dep = []
+ else:
+ dep = dep.split(', ')
+ for n, i in enumerate(dep):
+ if i == pip_pkg.split("==")[0]:
+ dep[n] = ''
+ else:
+ dep[n] = sudo('{} show {} 2>&1 | grep Version:'.format(pip_version, i)).replace('Version: ', '{} v.'.format(i))
+ dep = [i for i in dep if i]
+ status.append({"group": lib_group, "name": pip_pkg.split("==")[0], "version": version, "status": status_msg,
+ "error_message": err, "available_versions": versions, "add_pkgs": dep})
return status
except Exception as err:
append_result("Failed to install {} packages".format(pip_version), str(err))
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@dlab.apache.org
For additional commands, e-mail: commits-help@dlab.apache.org