summaryrefslogtreecommitdiffstats
path: root/scripts/find_python.sh
diff options
context:
space:
mode:
authorYaroslav Brustinov <ybrustin@cisco.com>2016-03-27 19:06:48 +0300
committerYaroslav Brustinov <ybrustin@cisco.com>2016-03-27 19:06:48 +0300
commit68ed79b989008006897108c7978d5c65fef47711 (patch)
tree43ed82b63015777369e8db71ca247f512a9de467 /scripts/find_python.sh
parentfbf1d1f4387566e964b2775e79e4e71c87dc3f8d (diff)
fix find_python usage
Diffstat (limited to 'scripts/find_python.sh')
-rwxr-xr-xscripts/find_python.sh49
1 files changed, 36 insertions, 13 deletions
diff --git a/scripts/find_python.sh b/scripts/find_python.sh
index e9607fe5..cf475f73 100755
--- a/scripts/find_python.sh
+++ b/scripts/find_python.sh
@@ -1,7 +1,7 @@
#!/bin/bash
-# if no variable of $PYTHON is define - we try to find it
-function find_python {
+# function finds python2
+function find_python2 {
# two candidates - machine python and cisco linux python
MACHINE_PYTHON=python
CEL_PYTHON=/router/bin/python-2.7.4
@@ -24,27 +24,50 @@ function find_python {
exit -1
}
+# function finds python3
function find_python3 {
MACHINE_PYTHON=python3
ITAY_PYTHON=/auto/proj-pcube-b/apps/PL-b/tools/python3.4/bin/python3
- PYTHON3=$MACHINE_PYTHON
- PCHECK=`$PYTHON3 -c "import sys; ver = sys.version_info[0] * 10 + sys.version_info[1];sys.exit(ver != 34)"`
+ PYTHON=$MACHINE_PYTHON
+ PCHECK=`$PYTHON -c "import sys; ver = sys.version_info[0] * 10 + sys.version_info[1];sys.exit(ver != 34)"`
if [ $? -eq 0 ]; then
return
fi
- PYTHON3=$ITAY_PYTHON
- PCHECK=`$PYTHON3 -c "import sys; ver = sys.version_info[0] * 10 + sys.version_info[1];sys.exit(ver != 34)"`
+ PYTHON=$ITAY_PYTHON
+ PCHECK=`$PYTHON -c "import sys; ver = sys.version_info[0] * 10 + sys.version_info[1];sys.exit(ver != 34)"`
if [ $? -eq 0 ]; then
return
fi
- echo "*** $PYTHON3 - python version does not match, 3.4 is required"
+ echo "*** $PYTHON - python version does not match, 3.4 is required"
exit -1
}
-if [ -z "$PYTHON" ]; then
- find_python
-fi
+case "$1" in
+ "--python2") # we want python2
+ find_python2
+ ;;
+ "--python3") # we want python3
+ find_python3
+ ;;
+ *)
+ if [ -z "$PYTHON" ]; then # no python env. var
+ case $USER in
+ imarom|hhaim|ybrustin|ibarnea) # dev users, 70% python3 30% python2
+ case $(($RANDOM % 10)) in
+ [7-9])
+ find_python2
+ ;;
+ *)
+ find_python3
+ ;;
+ esac
+ ;;
+ *) # default is python2
+ find_python2
+ ;;
+ esac
+ fi
+ ;;
+esac
+
-if [ -z "$PYTHON3" ]; then
- find_python3
-fi