From d47e1ac330d27ba363e5594b029f0ef5ce368792 Mon Sep 17 00:00:00 2001 From: "Chinmay D. Pai" Date: Thu, 20 Feb 2020 19:46:40 +0530 Subject: [PATCH 1/5] chore: fix easy_install import print from __future__ for python2 to use print's file param Signed-off-by: Chinmay D. Pai --- playbooks/install.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/playbooks/install.py b/playbooks/install.py index 0da571b5..c40aa579 100644 --- a/playbooks/install.py +++ b/playbooks/install.py @@ -1,5 +1,16 @@ #!/usr/bin/env python3 -import os, sys, subprocess, getpass, json, multiprocessing, shutil, platform, warnings, datetime +from __future__ import print_function +import os +import sys +import subprocess +import getpass +import json +import multiprocessing +import shutil +import platform +import warnings +import datetime + tmp_bench_repo = os.path.join('/', 'tmp', '.bench') tmp_log_folder = os.path.join('/', 'tmp', 'logs') From 0b3feb1f7b93462267f7f593a19799b5aa9bb0e3 Mon Sep 17 00:00:00 2001 From: "Chinmay D. Pai" Date: Thu, 20 Feb 2020 19:55:50 +0530 Subject: [PATCH 2/5] chore: add check for CI Signed-off-by: Chinmay D. Pai --- playbooks/install.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/playbooks/install.py b/playbooks/install.py index c40aa579..174004df 100644 --- a/playbooks/install.py +++ b/playbooks/install.py @@ -405,7 +405,7 @@ def parse_commandline_args(): return args if __name__ == '__main__': - if sys.version[0] == '2': + if sys.version[0] == '2' and not os.environ.get('CI'): if not raw_input("It is recommended to run this script with Python 3\nDo you still wish to continue? [Y/n]: ").lower() == "y": sys.exit() From 986015c13cf5b3ba4612280a232d5de4e890da0b Mon Sep 17 00:00:00 2001 From: "Chinmay D. Pai" Date: Thu, 20 Feb 2020 20:02:35 +0530 Subject: [PATCH 3/5] chore: substitute shutil.which with find_executable on py2 Signed-off-by: Chinmay D. Pai --- playbooks/install.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/playbooks/install.py b/playbooks/install.py index 174004df..614a2087 100644 --- a/playbooks/install.py +++ b/playbooks/install.py @@ -405,9 +405,12 @@ def parse_commandline_args(): return args if __name__ == '__main__': - if sys.version[0] == '2' and not os.environ.get('CI'): - if not raw_input("It is recommended to run this script with Python 3\nDo you still wish to continue? [Y/n]: ").lower() == "y": - sys.exit() + if sys.version[0] == '2': + from disutils.spawn import find_executable + shutil.which = find_executable + if not os.environ.get('CI'): + if not raw_input("It is recommended to run this script with Python 3\nDo you still wish to continue? [Y/n]: ").lower() == "y": + sys.exit() if not is_sudo_user(): log("Please run this script as a non-root user with sudo privileges", level=3) From 0a9effdfb40e57bbba2020977884f3a76d0efeb4 Mon Sep 17 00:00:00 2001 From: "Chinmay D. Pai" Date: Thu, 20 Feb 2020 20:12:28 +0530 Subject: [PATCH 4/5] chore: setup distutils inside travis Signed-off-by: Chinmay D. Pai --- .travis.yml | 2 +- playbooks/install.py | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9df3b6d4..a44f466b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ python: - "2.7" install: - - sudo pip install urllib3 pyOpenSSL ndg-httpsclient pyasn1 + - sudo pip install urllib3 pyOpenSSL ndg-httpsclient pyasn1 distutils - sudo apt-get purge -y mysql-common mysql-server mysql-client - sudo apt-get install --only-upgrade -y git - sudo apt-get install hhvm && rm -rf /home/travis/.kiex/ diff --git a/playbooks/install.py b/playbooks/install.py index 614a2087..bc9e4170 100644 --- a/playbooks/install.py +++ b/playbooks/install.py @@ -406,7 +406,12 @@ def parse_commandline_args(): if __name__ == '__main__': if sys.version[0] == '2': - from disutils.spawn import find_executable + try: + from disutils.spawn import find_executable + except ImportError: + print("Please install distutils or use Python3 to run the script") + print("$ pip install distutils") + sys.exit(1) shutil.which = find_executable if not os.environ.get('CI'): if not raw_input("It is recommended to run this script with Python 3\nDo you still wish to continue? [Y/n]: ").lower() == "y": From bf47661f3ed82e381c914eedbff80137818ca91e Mon Sep 17 00:00:00 2001 From: "Chinmay D. Pai" Date: Thu, 20 Feb 2020 20:18:57 +0530 Subject: [PATCH 5/5] chore: setup distutils using apt instead of pip Signed-off-by: Chinmay D. Pai --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index a44f466b..441c0f5a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,10 +5,10 @@ python: - "2.7" install: - - sudo pip install urllib3 pyOpenSSL ndg-httpsclient pyasn1 distutils + - sudo pip install urllib3 pyOpenSSL ndg-httpsclient pyasn1 - sudo apt-get purge -y mysql-common mysql-server mysql-client - sudo apt-get install --only-upgrade -y git - - sudo apt-get install hhvm && rm -rf /home/travis/.kiex/ + - sudo apt-get install hhvm python-distutils && rm -rf /home/travis/.kiex/ - mkdir -p ~/.bench - mkdir -p /tmp/.bench - cp -r $TRAVIS_BUILD_DIR/* ~/.bench