diff --git a/.travis.yml b/.travis.yml index d392ef84..b364ffe5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,7 @@ install: script: - nosetests -c .noserc autocertkit/tests/ acktools/ + - tools/checkpep8.sh after_success: - coveralls diff --git a/requirements.txt b/requirements.txt index 148b1bc0..893b82f5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ paramiko coveralls +autopep8 diff --git a/tools/autopep8.sh b/tools/autopep8.sh index ccdaaf94..935323de 100755 --- a/tools/autopep8.sh +++ b/tools/autopep8.sh @@ -1,16 +1,15 @@ #!/bin/sh -if [ $# -eq 0 ] -then -echo "Automated extra/missing whitespace code correction using autopep8" -files=`find ../ -not -path "../XenAPI/*" | - egrep -e '\.(py)$$' -e 'plugins/autocertkit' | - sort | uniq` +pwd0="$(dirname "$0")" +if [ $# -eq 0 ] ; then + echo "Automated extra/missing whitespace code correction using autopep8" + files=`find $pwd0/../ -not -path "$pwd0/../XenAPI/*" | + egrep -e '\.(py)$$' -e 'plugins/autocertkit' | + sort | uniq` else -files="$1" + files="$1" fi -for file in $files -do +for file in $files ; do echo "Running autopep8 on $file for whitespace changes only..." autopep8 -i $file done diff --git a/tools/checkpep8.sh b/tools/checkpep8.sh new file mode 100755 index 00000000..fa4822f9 --- /dev/null +++ b/tools/checkpep8.sh @@ -0,0 +1,11 @@ +#!/bin/sh +pwd0="$(dirname "$0")" +$pwd0/autopep8.sh +if [ "$(git diff)" ]] ; then + echo "checkpep8: Found violations, use tools/autopep8.sh to fix." + echo "checkpep8: Expected fix:-" + git diff + exit 1 +else + echo "checkpep8: No violations found. Success" +fi