Add checks for bad venv, and delete if detected (#510)

* Add checks for two known bad venv states

* More sturdy replacement operator
This commit is contained in:
Daniel Markstedt 2021-12-06 18:38:41 -08:00 committed by GitHub
parent 5ec5a5f730
commit 0cc0ee9094
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 1 deletions

View File

@ -65,6 +65,19 @@ if [[ `gcc --version | awk '/gcc/' | awk -F ' ' '{print $3}' | awk -F '.' '{prin
echo $COMPILER_FLAGS
fi
# Test for two known broken venv states
if test -e venv; then
GOOD_VENV=true
test -e venv/bin/activate && GOOD_VENV=false
pip list &> /dev/null
test $? -eq 0 && GOOD_VENV=false
if ! "$GOOD_VENV"; then
echo "Deleting bad python venv"
sudo rm -rf venv
fi
fi
# Create the venv if it doesn't exist
if ! test -e venv; then
echo "Creating python venv for OLED Screen"
python3 -m venv venv

View File

@ -31,6 +31,19 @@ if [ $ERROR = 1 ] ; then
exit 1
fi
# Test for two known broken venv states
if test -e venv; then
GOOD_VENV=true
test -e venv/bin/activate && GOOD_VENV=false
pip list &> /dev/null
test $? -eq 0 && GOOD_VENV=false
if ! "$GOOD_VENV"; then
echo "Deleting bad python venv"
sudo rm -rf venv
fi
fi
# Create the venv if it doesn't exist
if ! test -e venv; then
echo "Creating python venv for web server"
python3 -m venv venv
@ -71,5 +84,5 @@ while [ "$1" != "" ]; do
shift
done
echo "Starting web server on port ${PORT-8080}..."
echo "Starting web server on port ${PORT:-8080}..."
python3 web.py ${PORT}