forked from Sefaria/Sefaria-Project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run
executable file
·41 lines (35 loc) · 848 Bytes
/
run
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
#!/bin/bash
# Run a python script with necessary setup
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export PYTHONPATH=$DIR
export DJANGO_SETTINGS_MODULE=sefaria.settings
if [ $# -eq 0 ]; then
echo "Please specify a python script to run."
exit 1
fi
if [ "$1" = "--profile" ] ; then
profilescript=true
shift
fi
# look in scripts/ by default
if [ -e $DIR/scripts/$1 ]; then
script="$DIR/scripts/$1"
else
script=$1
fi
if [ $# -eq 1 ]; then
if [ "$profilescript" = true ] ; then
echo "profiling"
python3 -m cProfile $script
else
python3 $script
fi
elif [ $# -ge 2 ]; then
passargs=("${@:2}")
if [ "$profilescript" = true ] ; then
echo "profiling"
python3 -m cProfile $script "${passargs[@]}"
else
python3 $script "${passargs[@]}"
fi
fi