mirror of
https://github.com/haiwen/seafile-server.git
synced 2025-09-16 23:29:25 +00:00
Modify scripts to support python3.
This commit is contained in:
@@ -23,57 +23,27 @@ function check_python_executable() {
|
||||
return 0
|
||||
fi
|
||||
|
||||
if which python2.7 2>/dev/null 1>&2; then
|
||||
PYTHON=python2.7
|
||||
elif which python27 2>/dev/null 1>&2; then
|
||||
PYTHON=python27
|
||||
else
|
||||
if !(python --version 2>&1 | grep "3\.[0-9]\.[0-9]") 2>/dev/null 1>&2; then
|
||||
echo
|
||||
echo "Can't find a python executable of version 2.7 or above in PATH"
|
||||
echo "Install python 2.7+ before continue."
|
||||
echo "The current version of python is not 3.x.x, please use Python 3.x.x ."
|
||||
echo
|
||||
err_and_quit
|
||||
fi
|
||||
|
||||
PYTHON="python"$(python --version | cut -b 8-10)
|
||||
if !which $PYTHON 2>/dev/null 1>&2; then
|
||||
echo
|
||||
echo "Can't find a python executable of $PYTHON in PATH"
|
||||
echo "Install $PYTHON before continue."
|
||||
echo "Or if you installed it in a non-standard PATH, set the PYTHON enviroment varirable to it"
|
||||
echo
|
||||
exit 1
|
||||
err_and_quit
|
||||
fi
|
||||
}
|
||||
|
||||
function check_python_module () {
|
||||
module=$1
|
||||
name=$2
|
||||
hint=$3
|
||||
printf " Checking python module: ${name} ... "
|
||||
if ! $PYTHON -c "import ${module}" 2>/dev/null 1>&2; then
|
||||
echo
|
||||
printf "\033[33m ${name} \033[m is not installed, Please install it first.\n"
|
||||
if [[ "${hint}" != "" ]]; then
|
||||
printf "${hint}"
|
||||
echo
|
||||
fi
|
||||
err_and_quit;
|
||||
fi
|
||||
echo -e "Done."
|
||||
}
|
||||
|
||||
function check_python () {
|
||||
echo "Checking python on this machine ..."
|
||||
check_python_executable
|
||||
if ! which $PYTHON 2>/dev/null 1>&2; then
|
||||
echo "No $PYTHON found on this machine. Please install it first."
|
||||
err_and_quit;
|
||||
else
|
||||
if ($Python --version 2>&1 | grep "3\\.[0-9].\\.[0-9]") 2>/dev/null 1>&2 ; then
|
||||
printf "\033[33m Python version 3.x \033[m detected\n"
|
||||
echo "Python 3.x is not supported. Please use python 2.x. Now quit."
|
||||
err_and_quit;
|
||||
fi
|
||||
|
||||
if [[ $PYTHON == "python2.6" ]]; then
|
||||
py26="2.6"
|
||||
fi
|
||||
|
||||
hint='\nOn Debian/Ubuntu:\n\nsudo apt-get install python-mysqldb\n\nOn CentOS/RHEL:\n\nsudo yum install MySQL-python'
|
||||
check_python_module MySQLdb python-mysqldb "${hint}"
|
||||
fi
|
||||
echo
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user