anvil/run_checks.sh
Gunther Hagleitner f51c9b17f0 remove noisy echo
2012-01-18 18:04:09 -08:00

79 lines
1.4 KiB
Bash
Executable File

#!/bin/bash
set -eu
function usage {
echo "Usage: $0 [OPTION]..."
echo " -p, --no-pep8 Don't run pep8"
echo " -y, --no-pylint Don't run pylint"
echo " -h, --help Print this usage message"
exit
}
function process_option {
case "$1" in
-h|--help) usage;;
-p|--pep8) pep8=0;;
-y|--pylint) pylint=0;;
-*);;
*);;
esac
}
pylint=1
pep8=1
wrapper="exec"
pylintrc_fn="pylintrc"
for arg in "$@"; do
process_option $arg
done
function run_pep8 {
echo "Running pep8 ..."
srcfiles=`find devstack -type f | grep "py\$"`
srcfiles+=" stack"
pep_ignores="E202"
tee_fn="pep8.log"
pep8_opts="--ignore=$pep_ignores --repeat"
echo "$(${wrapper} pep8 ${pep8_opts} ${srcfiles} 2>&1 | tee $tee_fn)"
if [ "$?" -ne "0" ]; then
echo "Sorry, cannot run pep8 ..."
exit 1
else
echo "Successfully ran pep8 ..."
fi
}
function run_pylint {
echo "Running pylint ..."
srcfiles=`find devstack -type f | grep "py\$" | sed 's/devstack\/\(.*\)\.py/\1/' | tr '/' '.'`
srcfiles+=" stack"
tee_fn="pylint.log"
pylint_opts="--rcfile=$pylintrc_fn"
echo "$(${wrapper} pylint ${pylint_opts} ${srcfiles} 2>&1 | tee $tee_fn)"
if [ "$?" -ne "0" ]; then
echo "Sorry, cannot run pylint ..."
exit 1
else
echo "Successfully ran pylint ..."
fi
}
if [ $pep8 -eq 1 ]; then
run_pep8
fi
if [ $pylint -eq 1 ]; then
run_pylint
fi
exit 0