#!/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:" echo " - w: do rende1r using web browser" 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