2021-02-13 19:15:17 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -eu
|
|
|
|
|
|
|
|
|
|
|
|
# Need to replace last line of file from "}," to "}]"
|
|
|
|
# To avoid modify original file, use temporary file
|
|
|
|
TMP_FILE=stats_tmp.json
|
|
|
|
VENV=venv
|
|
|
|
|
|
|
|
if [[ $# -ne 1 ]] && [[ $# -ne 2 ]]; then
|
|
|
|
echo "Usage:"
|
|
|
|
echo " $0 STATS_FILE [-w] "
|
|
|
|
echo ""
|
|
|
|
echo "Params:"
|
|
|
|
echo " - stats_file: path to stats file"
|
|
|
|
echo ""
|
|
|
|
echo "Options:"
|
2021-02-14 17:09:34 +00:00
|
|
|
echo " - w: do render using web browser"
|
2021-02-13 19:15:17 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
STATS_FILE=$1
|
|
|
|
OPT=""
|
|
|
|
if [[ $# -eq 2 ]]; then
|
|
|
|
OPT=${OPT}" -w"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Pip install -----------------------------------------------------------------
|
|
|
|
if [ ! -d ${VENV} ]; then
|
|
|
|
echo "Installing python environment in ${VENV}..."
|
|
|
|
python3 -m venv ${VENV}
|
|
|
|
. ${VENV}/bin/activate
|
|
|
|
pip install --upgrade pip
|
|
|
|
pip install -r requirements.txt
|
|
|
|
echo "Python environment installed..."
|
|
|
|
echo ""
|
|
|
|
else
|
|
|
|
. ${VENV}/bin/activate
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# Render ----------------------------------------------------------------------
|
|
|
|
sed -e '$s/},/}]/' ${STATS_FILE} > ${TMP_FILE}
|
|
|
|
|
|
|
|
# Update last line
|
|
|
|
# Generate render
|
|
|
|
python render.py ${TMP_FILE} ${OPT}
|
|
|
|
|
|
|
|
rm ${TMP_FILE}
|
|
|
|
|
|
|
|
deactivate
|