This is an automated email from the ASF dual-hosted git repository.

lfrolov pushed a commit to branch DLAB-1997
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git

commit 6f84d4d700da3cfd796018726ec7bd6caa908ff1
Author: leonidfrolov <frolovl...@gmail.com>
AuthorDate: Fri Aug 14 17:17:32 2020 +0300

    [DLAB-1997]: fixed yum package installation error for EMR
---
 .../src/general/lib/os/redhat/notebook_lib.py              | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git 
a/infrastructure-provisioning/src/general/lib/os/redhat/notebook_lib.py 
b/infrastructure-provisioning/src/general/lib/os/redhat/notebook_lib.py
index 9926ee0..b5b64d4 100644
--- a/infrastructure-provisioning/src/general/lib/os/redhat/notebook_lib.py
+++ b/infrastructure-provisioning/src/general/lib/os/redhat/notebook_lib.py
@@ -378,17 +378,16 @@ def install_os_pkg(requisites):
             versions = []
             res = sudo(
                 'python -c "import os,sys,yum; yb = yum.YumBase(); pl = 
yb.doPackageLists(); print [pkg.vr for pkg in pl.installed if pkg.name == 
\'{0}\']"'.format(
-                    name))
-            if res != []:
-                res = res[0]
+                    name)).split('\r\n')[1]
             if err:
                 status_msg = 'installation_error'
-            elif res:
-                version = res.split('\r\n')[1].replace("'", "\"")
+            elif res != []:
+                version = res.split("'")[1].split("-")[0]
                 status_msg = "installed"
             if 'No package {} available'.format(os_pkg) in install_output:
-                versions = sudo ('yum --showduplicates list ' + name + ' | 
expand | grep -A 10 "Available Packages" | grep -v "Available Packages"| awk 
\'{print $2}\'').replace('\r\n', '').split(' ')
-                if versions != '':
+                versions = sudo ('yum --showduplicates list ' + name + ' | 
expand | grep -A 10 "Available Packages" | grep -v "Available Packages"| awk 
\'{print $2}\'').replace('\r\n', '')
+                if versions and versions != 'Error: No matching Packages to 
list':
+                    versions = versions.split(' ')
                     status_msg = 'invalid_version'
                     for n, i in enumerate(versions):
                         if ':' in i:
@@ -396,6 +395,7 @@ def install_os_pkg(requisites):
                         else:
                             versions[n] = i.split('-')[0]
                 else:
+                    versions = []
                     status_msg = 'invalid_name'
             status.append({"group": "os_pkg", "name": name, "version": 
version, "status": status_msg,
                            "error_message": err, "add_pkgs": dep, 
"available_versions": versions})


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@dlab.apache.org
For additional commands, e-mail: commits-h...@dlab.apache.org

Reply via email to