blob: cf475f7374236f7668fc9796377e173db65b8b2b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
#!/bin/bash
# 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
# try the machine python
PYTHON=$MACHINE_PYTHON
PCHECK=`$PYTHON -c "import sys; ver = sys.version_info[0] * 10 + sys.version_info[1];sys.exit(ver < 27)"`
if [ $? -eq 0 ]; then
return
fi
# try the CEL python
PYTHON=$CEL_PYTHON
PCHECK=`$PYTHON -c "import sys; ver = sys.version_info[0] * 10 + sys.version_info[1];sys.exit(ver < 27)"`
if [ $? -eq 0 ]; then
return
fi
echo "*** $PYTHON - python version is too old, 2.7 at least is required"
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
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
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 "*** $PYTHON - python version does not match, 3.4 is required"
exit -1
}
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
|