manila/tools/check_logging.sh
Tom Barron 72ab1442ad Remove unused logging import and LOG global
This patch removes unused global LOG variable
and logging imports from various manila modules,
and adds a script to be run as part of pep8 that
will ensure that these do not creep back into
the codebase.

Change-Id: I162c4b2478df45aaf6ea8009b102d6de1a4e309e
2016-04-05 07:06:08 -04:00

29 lines
435 B
Bash
Executable File

#!/bin/bash
tree=$1
tmpfile=$(mktemp)
find $tree -name '*.py' \
| xargs grep -l 'import log' \
| xargs grep -l '^LOG =' \
| xargs grep -c 'LOG' \
| grep ':1$' \
| awk -F ':' '{print $1}' > $tmpfile
count=$(wc -l < $tmpfile)
if [[ count -eq 0 ]]; then
rm $tmpfile
exit 0
fi
echo 'Found files with unused LOG variable (see https://review.openstack.org/#/c/301054):'
cat $tmpfile
rm $tmpfile
exit 1