You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datalab.apache.org by lf...@apache.org on 2021/02/17 14:54:35 UTC

[incubator-datalab] branch DATALAB-2091 updated: [DATALAB-2091]: changed error variable assignment in manage_pkg

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

lfrolov pushed a commit to branch DATALAB-2091
in repository https://gitbox.apache.org/repos/asf/incubator-datalab.git


The following commit(s) were added to refs/heads/DATALAB-2091 by this push:
     new 24fc542  [DATALAB-2091]: changed error variable assignment in manage_pkg
24fc542 is described below

commit 24fc54229188de78fdb490fdf218c20dfd23812b
Author: leonidfrolov <fr...@gmail.com>
AuthorDate: Wed Feb 17 16:54:24 2021 +0200

    [DATALAB-2091]: changed error variable assignment in manage_pkg
---
 .../src/general/lib/os/debian/common_lib.py             | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/infrastructure-provisioning/src/general/lib/os/debian/common_lib.py b/infrastructure-provisioning/src/general/lib/os/debian/common_lib.py
index 80c8cfa..421ed88 100644
--- a/infrastructure-provisioning/src/general/lib/os/debian/common_lib.py
+++ b/infrastructure-provisioning/src/general/lib/os/debian/common_lib.py
@@ -43,16 +43,15 @@ def manage_pkg(command, environment, requisites):
                 print('Package manager is:')
                 if environment == 'remote':
                     if datalab.fab.conn.sudo('pgrep "^apt" -a && echo "busy" || echo "ready"') == 'busy' or datalab.fab.conn.sudo('pgrep "^dpkg" -a && echo "busy" || echo "ready"') == 'busy':
-                        print('----------- manager not ready')
                         counter += 1
                         time.sleep(10)
                     else:
                         try:
-                            print('----------- install 1')
                             error_parser = "frontend is locked|locked"
-                            datalab.fab.conn.sudo('hostname')
-                            datalab.fab.conn.sudo('dpkg --configure -a 2>&1 | tee /tmp/tee.tmp; if ! grep -w -E "(frontend is locked|locked)" /tmp/tee.tmp > /tmp/dpkg.log; then echo "" > /tmp/dpkg.log;fi'.format(error_parser))
-                            err = ''
+                            datalab.fab.conn.sudo('dpkg --configure -a 2>&1 | tee /tmp/tee.tmp; if ! grep -w -E '
+                                                  '"(frontend is locked|locked)" /tmp/tee.tmp > /tmp/dpkg.log; then '
+                                                  'touch /tmp/dpkg.log;fi'.format(error_parser))
+                            err = datalab.fab.conn.sudo('cat /tmp/dpkg.log')
                             print('=========cat /tmp/dpkg.log')
                             datalab.fab.conn.sudo('cat /tmp/dpkg.log')
                             print('=========xxd /tmp/dpkg.log')
@@ -73,7 +72,7 @@ def manage_pkg(command, environment, requisites):
                                     datalab.fab.conn.sudo('kill -9 {}'.format(pid))
                                     datalab.fab.conn.sudo('rm -f /var/lib/dpkg/lock')
                                 datalab.fab.conn.sudo('dpkg --configure -a 2>&1 | tee /tmp/tee.tmp; if ! grep -w -E "({0})" /tmp/tee.tmp > '
-                                     '/tmp/dpkg.log; then echo "" > /tmp/dpkg.log;fi'.format(error_parser))
+                                     '/tmp/dpkg.log; then touch /tmp/dpkg.log;fi'.format(error_parser))
                                 err = datalab.fab.conn.sudo('cat /tmp/dpkg.log')
                                 print('----------- install 5 err ' + err)
                                 count = count + 1
@@ -81,10 +80,10 @@ def manage_pkg(command, environment, requisites):
                             datalab.fab.conn.sudo('apt update')
                             print('----------- install 7')
                             datalab.fab.conn.sudo('apt-get {0} {1} 2>&1 | tee /tmp/tee.tmp; if ! grep -w -E "({2})" /tmp/tee.tmp > '
-                                 '/tmp/apt.log; then echo "" > /tmp/apt.log;fi'.format(command, requisites, error_parser))
+                                 '/tmp/apt.log; then touch /tmp/apt.log;fi'.format(command, requisites, error_parser))
                             print('----------- install 8')
                             datalab.fab.conn.sudo('ls -la /tmp/')
-                            err = ''#datalab.fab.conn.sudo('cat /tmp/apt.log')
+                            err = datalab.fab.conn.sudo('cat /tmp/apt.log')
                             print('=========cat /tmp/apt.log')
                             datalab.fab.conn.sudo('cat /tmp/apt.log')
                             print('=========xxd /tmp/apt.log')
@@ -143,7 +142,7 @@ def ensure_pkg(user, requisites='linux-headers-generic python3-pip python3-dev p
                         datalab.fab.conn.sudo('unattended-upgrades -v')
                         datalab.fab.conn.sudo(
                             'sed -i \'s|APT::Periodic::Unattended-Upgrade "1"|APT::Periodic::Unattended-Upgrade "0"|\' /etc/apt/apt.conf.d/20auto-upgrades')
-                        datalab.fab.conn.sudo('export LC_ALL=C')
+                        datalab.fab.conn.run('export LC_ALL=C')
                         datalab.fab.conn.sudo('touch /home/{}/.ensure_dir/pkg_upgraded'.format(user))
                         datalab.fab.conn.sudo('systemctl enable haveged')
                         datalab.fab.conn.sudo('systemctl start haveged')


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datalab.apache.org
For additional commands, e-mail: commits-help@datalab.apache.org