pkgdep: support pycodestyle in check_format.sh

- install py27-pycodestyle on Freebsd
 - conditionally use pycodestyle in check_format.sh
 - fix various E722 do not use bare except errors caught by pycodestyle
 - see: https://github.com/PyCQA/pycodestyle/issues/466

Change-Id: I64ecf3f204a456134d891d1339f3aa1db281965a
Signed-off-by: John Meneghini <johnm@netapp.com>
Signed-off-by: Ed Rodriguez <ed.rodriguez@netapp.com>
Reviewed-on: https://review.gerrithub.io/416460
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
This commit is contained in:
John Meneghini 2018-06-21 19:29:12 +00:00 committed by Jim Harris
parent 8a0a98d35e
commit b7322649db
5 changed files with 15 additions and 7 deletions

View File

@ -110,13 +110,21 @@ else
fi fi
rm -f scripts/posix.log rm -f scripts/posix.log
if hash pep8; then if hash pep8 2>/dev/null; then
PEP8=pep8
fi
if hash pycodestyle 2>/dev/null; then
PEP8=pycodestyle
fi
if [ ! -z ${PEP8} ]; then
echo -n "Checking Python style..." echo -n "Checking Python style..."
PEP8_ARGS+=" --max-line-length=140" PEP8_ARGS+=" --max-line-length=140"
error=0 error=0
git ls-files '*.py' | xargs -n1 pep8 $PEP8_ARGS > pep8.log || error=1 git ls-files '*.py' | xargs -n1 $PEP8 $PEP8_ARGS > pep8.log || error=1
if [ $error -ne 0 ]; then if [ $error -ne 0 ]; then
echo " Python formatting errors detected" echo " Python formatting errors detected"
cat pep8.log cat pep8.log

View File

@ -46,10 +46,10 @@ elif [ -f /etc/SuSE-release ]; then
# Additional dependencies for building docs # Additional dependencies for building docs
zypper install -y doxygen mscgen graphviz zypper install -y doxygen mscgen graphviz
elif [ $SYSTEM = "FreeBSD" ] ; then elif [ $SYSTEM = "FreeBSD" ] ; then
pkg install gmake cunit openssl git devel/astyle bash devel/pep8 \ pkg install -y gmake cunit openssl git devel/astyle bash py27-pycodestyle \
python misc/e2fsprogs-libuuid sysutils/sg3_utils nasm python misc/e2fsprogs-libuuid sysutils/sg3_utils nasm
# Additional dependencies for building docs # Additional dependencies for building docs
pkg install doxygen mscgen graphviz pkg install -y doxygen mscgen graphviz
else else
echo "pkgdep: unknown system type." echo "pkgdep: unknown system type."
exit 1 exit 1

View File

@ -22,7 +22,7 @@ def main():
root_node = UIRoot(args.socket, shell) root_node = UIRoot(args.socket, shell)
try: try:
root_node.refresh() root_node.refresh()
except: except BaseException:
pass pass
if len(args.commands) > 0: if len(args.commands) > 0:

View File

@ -431,7 +431,7 @@ def verify_add_delete_ip_address(rpc_py):
"add ip {} to nic {} failed.".format(faked_ip, x["name"])) "add ip {} to nic {} failed.".format(faked_ip, x["name"]))
try: try:
check_call(ping_cmd.split()) check_call(ping_cmd.split())
except: except BaseException:
verify(False, 1, verify(False, 1,
"ping ip {} for {} was failed(adding was successful)".format "ping ip {} for {} was failed(adding was successful)".format
(faked_ip, x["name"])) (faked_ip, x["name"]))

View File

@ -50,6 +50,6 @@ if __name__ == "__main__":
print("RESULT: Some test cases FAIL") print("RESULT: Some test cases FAIL")
print(tc_failed) print(tc_failed)
sys.exit(1) sys.exit(1)
except: except BaseException:
print("Test: {num_test} - FAIL".format(num_test=num_test)) print("Test: {num_test} - FAIL".format(num_test=num_test))
sys.exit(1) sys.exit(1)