1 Star 0 Fork 46

Eliauk./openGauss-DBMind

forked from openGauss/openGauss-DBMind 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
gs_dbmind 4.03 KB
一键复制 编辑 原始数据 按行查看 历史
wangtq 提交于 2022-11-23 10:17 . chore: update notifications of gs_dbmind
#!/usr/bin/env bash
# Copyright (c) 2022 Huawei Technologies Co.,Ltd.
#
# openGauss is licensed under Mulan PSL v2.
# You can use this software according to the terms and conditions of the Mulan PSL v2.
# You may obtain a copy of Mulan PSL v2 at:
#
# http://license.coscl.org.cn/MulanPSL2
#
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
# See the Mulan PSL v2 for more details.
# ------------Utils------------
function die() {
echo -e "FATAL: $1"
exit 1
}
function extract_libname() {
# Split real library name.
line=$1
tmparr=(${line//==/ })
libname=${tmparr[0]}
tmparr=(${libname//>=/ })
libname=${tmparr[0]}
tmparr=(${libname//<=/ })
libname=${tmparr[0]}
tmparr=(${libname//~=/ })
libname=${tmparr[0]}
# trim
libname=$(echo $libname | sed 's/ *$//g')
echo $libname
}
# ------------Main Process------------
ABSPATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
DBMIND_PATH=${ABSPATH}/dbmind
ORIGIN_PATH=$(pwd)
cd $ABSPATH
# Check whether Python has been installed onto the OS.
source constant
# Set local Python VM if we have.
export PATH=${ABSPATH}/python/bin:$PATH
PYTHON=$(which python3)
if [[ "$?" != "0" ]]; then
die "Not found the Python environment."
fi
# Check for the Python version.
$PYTHON -c "import sys; exit(${MIN_PYTHON_VERSION} <= sys.version_info[:2] <= ${MAX_PYTHON_VERSION})"
if [[ "$?" != "1" ]]; then
die "Not supported Python (${PYTHON}) version. At least Python ${MIN_PYTHON_VERSION}"
fi
# Run set command
if [[ $1 == "set" ]]; then
cd $ORIGIN_PATH
echo "WARN: The SET operation will not detect the integrity of the module, please install the module in advance."
$PYTHON $DBMIND_PATH/ $@ &
exit $?
fi
cd $ABSPATH
# Check for dependencies
## Firstly, get the machine architecture so that determine different requirement files.
if [[ -f "${DBMIND_PATH}/requirements-x86.txt" ]]; then
REQUIREMENT_PATH=$DBMIND_PATH
else
REQUIREMENT_PATH=$DBMIND_PATH/..
fi
machine=$(uname -m)
if [[ "$machine" =~ "x86" ]]; then
requirements=$REQUIREMENT_PATH/"requirements-x86.txt"
else
requirements=$REQUIREMENT_PATH/"requirements-aarch64.txt"
fi
## Secondly, check whether each library has been installed.
if [[ $PYTHONPATH ]]; then
echo "NOTICE: You have set the variable PYTHONPATH. DBMind ignored it."
fi
export PYTHONPATH=${ABSPATH}/3rd
installed_list=$($PYTHON -m pip list --disable-pip-version-check)
while read line; do
libname=$(extract_libname $line)
# skip comment
if [[ $libname == "#"* ]] || [[ $libname == "" ]] ; then
continue
fi
found=$(echo $installed_list | grep -i "$libname")
if [[ $found == "" ]]; then
die "Need dependency ${libname}. You should use pip to install it, following:\n
${PYTHON} -m pip install -r ${requirements}"
fi
done < $requirements
# Furthermore, if users want to use several components, he should install optional dependencies.
## e.g., gs_dbmind component sqldiag ...
optional_reqs=$REQUIREMENT_PATH/"requirements-optional.txt"
if [[ "$1" == "component" ]] && [[ "$2" == "sqldiag" || "$2" == "xtuner" ]]; then
while read line; do
libname=$(extract_libname $line)
# skip comment
if [[ $libname == "#"* ]] || [[ $libname == "" ]] ; then
continue
fi
found=$(echo $installed_list | grep -i "$libname")
if [[ $found == "" ]]; then
echo -e "NOTICE: Maybe you need dependency ${libname} while using this component. You should use pip to install it, following:\n
${PYTHON} -m pip install -r ${optional_reqs}"
fi
done < $optional_reqs
fi
set -f
for arg in "${@}" ; do
if [[ ${arg:0:1} != '-' ]]; then
arg=`echo $arg |sed 's/"""/\\\\\\"\\\\\\"\\\\\\"/g'`
arg=`${PYTHON} -c "import shlex;print(shlex.quote(\"\"\"$arg\"\"\"))"`
fi
_args=$_args" "$arg
done
cd $ORIGIN_PATH
eval $PYTHON $DBMIND_PATH/ $_args
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/longzzqq/openGauss-DBMind.git
git@gitee.com:longzzqq/openGauss-DBMind.git
longzzqq
openGauss-DBMind
openGauss-DBMind
master

搜索帮助