From 272d11dd25bf76a1df557a0c9647aef7bde3deb1 Mon Sep 17 00:00:00 2001 From: Thomas Stilwell Date: Sun, 7 Sep 2014 20:36:23 -0500 Subject: [PATCH] upgrade_db.sh: fix locating of python binary This fixes two bugs: upgrade fails when deps were installed to virtualenv but not system upgrade fails when python==python3 (notably on arch) Signed-off-by: Thomas Stilwell --- upgrade_db.sh | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/upgrade_db.sh b/upgrade_db.sh index c5f4df465..c119e83c8 100755 --- a/upgrade_db.sh +++ b/upgrade_db.sh @@ -1,5 +1,20 @@ +#!/bin/bash + +PYTHON="./env/bin/python" +if [ ! -x $PYTHON ]; then + echo "No python executable found at ${PYTHON}" + if type python2 &>/dev/null; then + PYTHON=python2 + elif type python &>/dev/null; then + PYTHON=python + else + echo "No python executable found anywhere" + exit + fi +fi + # Execute from root dir as: bash upgrade_db.sh for file in db/migrations/* do - python $file $1 upgrade + $PYTHON $file $1 upgrade done