diff options
author | Yaroslav Brustinov <ybrustin@cisco.com> | 2016-09-28 12:23:17 +0300 |
---|---|---|
committer | Yaroslav Brustinov <ybrustin@cisco.com> | 2016-09-28 12:23:17 +0300 |
commit | 08aaabafd6a07491bb89324c1306e6e88ae46980 (patch) | |
tree | d3367213b02aa69db2f3fe54d62f283262d3ab86 | |
parent | ffff2512ebbd65773a784565ce78d51d2ceb9a8d (diff) |
find_python.sh by default find any available Python, allow 3.5 too.
t-rex-64 fix case of no $USER when not in tty
-rwxr-xr-x | scripts/find_python.sh | 15 | ||||
-rwxr-xr-x | scripts/t-rex-64 | 4 |
2 files changed, 11 insertions, 8 deletions
diff --git a/scripts/find_python.sh b/scripts/find_python.sh index 9a9717c1..ea3c6b35 100755 --- a/scripts/find_python.sh +++ b/scripts/find_python.sh @@ -26,7 +26,7 @@ function find_python2 { return fi - echo "*** $PYTHON - python version is too old, 2.7 at least is required" + echo "*** $MACHINE_PYTHON - python version is too old, 2.7 at least is required" exit -1 } @@ -41,16 +41,16 @@ function find_python3 { MACHINE_PYTHON=python3 ITAY_PYTHON=/auto/proj-pcube-b/apps/PL-b/tools/python3.4/bin/python3 PYTHON=$MACHINE_PYTHON - PCHECK=`$PYTHON -c "import sys; ver = sys.version_info[0] * 10 + sys.version_info[1];sys.exit(ver != 34)" > /dev/null 2>&1 ` + PCHECK=`$PYTHON -c "import sys; ver = sys.version_info[0] * 10 + sys.version_info[1];sys.exit(ver != 34 and ver != 35)" > /dev/null 2>&1 ` if [ $? -eq 0 ]; then return fi PYTHON=$ITAY_PYTHON - PCHECK=`$PYTHON -c "import sys; ver = sys.version_info[0] * 10 + sys.version_info[1];sys.exit(ver != 34)" > /dev/null 2>&1 ` + PCHECK=`$PYTHON -c "import sys; ver = sys.version_info[0] * 10 + sys.version_info[1];sys.exit(ver != 34 and ver != 35)" > /dev/null 2>&1 ` if [ $? -eq 0 ]; then return fi - echo "*** $PYTHON - python version does not match, 3.4 is required" + echo "*** $MACHINE_PYTHON - python version does not match, 3.4 or 3.5 is required" exit -1 } @@ -74,8 +74,11 @@ case "$1" in ;; esac ;; - *) # default is python2 - find_python2 + *) # default is find any + (find_python2) &> /dev/null && find_python2 && return + (find_python3) &> /dev/null && find_python3 && return + echo "Python versions 2.7 or 3.4 or 3.5 required" + exit -1 ;; esac fi diff --git a/scripts/t-rex-64 b/scripts/t-rex-64 index c18db43f..4e5c0fae 100755 --- a/scripts/t-rex-64 +++ b/scripts/t-rex-64 @@ -1,5 +1,5 @@ #! /bin/bash -if [ $USER != 'root' ]; then +if [ "$(id -u)" != 0 ]; then echo 'Error: Please run as root (sudo etc.)' exit -1 fi @@ -20,7 +20,7 @@ saveterm="$(stty -g)" if cat /proc/cpuinfo | grep -q avx ; then ./_$(basename $0) $INPUT_ARGS RESULT=$? - if [ $? -eq 132 ]; then + if [ $RESULT -eq 132 ]; then echo " WARNING this program is optimized for the new Intel processors. " echo " try the ./t-rex-64-o application that should work for any Intel processor but might be slower. " echo " try to run t-rex-64-o .. " |