-
Notifications
You must be signed in to change notification settings - Fork 6
/
run.sh
executable file
·36 lines (31 loc) · 863 Bytes
/
run.sh
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
#!/bin/sh
doc_str="Usage: ./run.sh
example: ./run.sh app/venom_auto.py
"
mkdir -p log
mkdir -p tmp
# if have argument, use it as file name
if [ $# -gt 0 ]; then
pf=$1
else
pf="app/x.py"
fi
file_name=${pf##*/}
today=$(date '+%Y-%m-%d_%H:%M:%S')
file_name_log="log/${file_name%.*}_${today}.log"
# set pipenv path
if [[ -f "$HOME/.pyenv/shims/pipenv" ]]; then
pipenv="$HOME/.pyenv/shims/pipenv"
elif [[ -f "$HOME/.local/bin/pipenv" ]]; then
pipenv="$HOME/.local/bin/pipenv"
elif [[ -f "/opt/homebrew/bin/pipenv" ]]; then
pipenv="/opt/homebrew/bin/pipenv"
elif [[ -f "/usr/local/bin/pipenv" ]]; then
pipenv="/usr/local/bin/pipenv"
else
echo "pipenv application not found"
fi
ptp=`pwd`
echo "Running PYTHONPATH=$ptp $pipenv run python $pf"
PYTHONPATH=`pwd` $pipenv run python $pf 2>&1 | tee -a $file_name_log
echo "check file $file_name_log"