From cfb64aa10409f7cb5b4814967c5a28e7b0d768f1 Mon Sep 17 00:00:00 2001 From: Mikhail Yumanov Date: Thu, 11 Mar 2021 00:21:21 +0300 Subject: [PATCH] Replaced with if stmt --- deploy_local_beta/cleanup.sh | 1 + deploy_local_beta/deploy_local_beta.sh | 71 ++++++------------- .../deploy_local_beta_python2.sh | 10 +-- deploy_local_beta/run.sh | 34 ++++++++- 4 files changed, 61 insertions(+), 55 deletions(-) diff --git a/deploy_local_beta/cleanup.sh b/deploy_local_beta/cleanup.sh index 1c8e89725..cedb72208 100644 --- a/deploy_local_beta/cleanup.sh +++ b/deploy_local_beta/cleanup.sh @@ -37,6 +37,7 @@ unset ANYBETA_VENV_ACTIVATE unset ANYBETA_REPORT_PREFIX unset ANYBETA_ERROR_PREFIX unset ANYBETA_SAVE_VENV +unset ANYBETA_correct_args unset ANYBETA_report unset ANYBETA_error diff --git a/deploy_local_beta/deploy_local_beta.sh b/deploy_local_beta/deploy_local_beta.sh index 26b92260a..681334735 100644 --- a/deploy_local_beta/deploy_local_beta.sh +++ b/deploy_local_beta/deploy_local_beta.sh @@ -6,65 +6,38 @@ if ! test $ANYBETA_ROOT then echo "ERROR: This file should not be run directly." echo "Execute \`. deploy_local_beta/run.sh\` from repository root instead." - exit 1 -fi - - -# PARSE ARGS -############ - -while (( "$#" )); do - ANYBETA_PARAM=`echo $1 | awk -F= '{ print $1 }'` - ANYBETA_VALUE=`echo $1 | awk -F= '{ print $2 }'` - - case $ANYBETA_PARAM in - -p|--python-path) - ANYBETA_PYTHON_PATH=$ANYBETA_VALUE - shift - ;; +else - -h|--help) - ANYBETA_usage - exit 0 - ;; - *) - echo "Error: unknown parameter $ANYBETA_PARAM" - exit 1 - ;; - esac -done + # CHECK PYTHON PATH + ################### +# if ! test -e $ANYBETA_PYTHON_PATH +# then +# ANYBETA_error "Bad python path: $ANYBETA_PYTHON_PATH" +# else -# CHECK PYTHON PATH -################### -if ! test -e $ANYBETA_PYTHON_PATH -then - ANYBETA_error "Bad python path: $ANYBETA_PYTHON_PATH" - exit 1 -fi + # CLONE REPOSITORY + ################## + ANYBETA_report + ANYBETA_report "Init submodules" + git submodule init + git submodule update -# CLONE REPOSITORY -################## -ANYBETA_report -ANYBETA_report "Init submodules" -git submodule init -git submodule update + # CHOOSE RIGHT VERSION + ###################### + ANYBETA_PYTHON_VERSION_CHECK="from __future__ import print_function; import sys; print(int(sys.version_info < (3, 3)))" -# CHOOSE RIGHT VERSION -###################### + if test `$ANYBETA_PYTHON_PATH -c "$ANYBETA_PYTHON_VERSION_CHECK"` -eq 1 + then + . $ANYBETA_DEPLOY/deploy_local_beta_python2.sh + else + . $ANYBETA_DEPLOY/deploy_local_beta_python3.sh + fi -ANYBETA_PYTHON_VERSION_CHECK="from __future__ import print_function; import sys; print(int(sys.version_info < (3, 3)))" -if test `$ANYBETA_PYTHON_PATH -c "$ANYBETA_PYTHON_VERSION_CHECK"` -eq 1 -then - . $ANYBETA_DEPLOY/deploy_local_beta_python2.sh -else - . $ANYBETA_DEPLOY/deploy_local_beta_python3.sh fi - - diff --git a/deploy_local_beta/deploy_local_beta_python2.sh b/deploy_local_beta/deploy_local_beta_python2.sh index 91901ebfc..1078775e4 100644 --- a/deploy_local_beta/deploy_local_beta_python2.sh +++ b/deploy_local_beta/deploy_local_beta_python2.sh @@ -6,8 +6,7 @@ if ! test $ANYBETA_ROOT then echo "ERROR: This file should not be run directly." echo "Execute \`. deploy_local_beta/run.sh\` from repository root instead." - exit 1 -fi +else #SETUP VIRTUALENV @@ -33,7 +32,8 @@ pip install -r requirements_local.txt ANYBETA_report ANYBETA_report "Manage django project" -$ANYBETA_PYTHON_PATH setup.py develop -./anytask/manage.py -./anytask/manage.py migrate --noinput +python setup.py develop +python ./anytask/manage.py migrate --noinput #./anytask/manage.py runserver 127.0.0.1:8019 -v 3 --traceback + +fi diff --git a/deploy_local_beta/run.sh b/deploy_local_beta/run.sh index be87551d7..406fc218a 100644 --- a/deploy_local_beta/run.sh +++ b/deploy_local_beta/run.sh @@ -45,4 +45,36 @@ function ANYBETA_usage() { export -f ANYBETA_report ANYBETA_error ANYBETA_usage -$ANYBETA_DEPLOY/deploy_local_beta.sh "$@" + +# PARSE ARGS +############ + +ANYBETA_correct_args=1 + +while (( "$#" )); do + ANYBETA_PARAM=`echo $1 | awk -F= '{ print $1 }'` + ANYBETA_VALUE=`echo $1 | awk -F= '{ print $2 }'` + + case $ANYBETA_PARAM in + -p|--python-path) + ANYBETA_PYTHON_PATH=$ANYBETA_VALUE + shift + ;; + + -h|--help) + ANYBETA_usage + shift + ;; + + *) + ANYBETA_error "Error: unknown parameter $ANYBETA_PARAM" + shift + ANYBETA_correct_args=0 + ;; + esac +done + +if test $ANYBETA_correct_args = 1 +then + . $ANYBETA_DEPLOY/deploy_local_beta.sh "$@" +fi