Fix: "except" issues for Python 2/3 compatible code.

change "except ValueError, e:"
to "except ValueError as e:"

and remove tox H231 from ignore for pep8 check
Story:2003430
Task: 26522

Change-Id: I06c7646c375ada7f8f06f870a7bdb0d7fc282e5a
Signed-off-by: Sun Austin <austin.sun@intel.com>
This commit is contained in:
Sun Austin 2018-10-15 14:41:06 +08:00
parent f2a6d355a9
commit 4fe73f515d
5 changed files with 5 additions and 6 deletions

View File

@ -94,7 +94,7 @@ def sm_api_notify(sm_dict):
except:
LOG.exception(_("sm-api bad rx message: %s" % sm_ack))
except socket.error, e:
except socket.error as e:
LOG.exception(_("sm-api socket error: %s on %s") % (e, sm_buf))
sm_ack_dict = {
'SM_API_MSG_TYPE': "unknown_set_node",

View File

@ -663,7 +663,7 @@ def notify_mtc_and_recv(mtc_address, mtc_port, idict):
LOG.exception("Mtc Response Error: %s" % mtc_response)
pass
except socket.error, e:
except socket.error as e:
LOG.exception(_("Socket Error: %s on %s:%s for %s") % (e,
mtc_address, mtc_port, serialized_idict))
# if e not in [errno.EWOULDBLOCK, errno.EINTR]:

View File

@ -207,7 +207,7 @@ def trycmd(*args, **kwargs):
try:
out, err = execute(*args, **kwargs)
failed = False
except ProcessExecutionError, exn:
except ProcessExecutionError as exn:
out, err = '', str(exn)
failed = True

View File

@ -39,7 +39,7 @@ def _send_msg_to_sm(sm_api_msg):
s.sendto(sm_api_msg, SM_API_SERVER_ADDR)
time.sleep(1)
except socket.error, e:
except socket.error as e:
print("sm-api socket error: %s on %s" % (e, sm_api_msg))

View File

@ -84,7 +84,6 @@ commands =
# H104: File contains nothing but comments
# H105: Don't use author tags
# H201: no 'except:'
# H231: Python 3.x incompatible 'except x,y:' construct
# H233: Python 3.x incompatible use of print operator
# H236: Python 3.x incompatible __metaclass__, use six.add_metaclass()
# H306: imports not in alphabetical order
@ -109,7 +108,7 @@ commands =
# B306 `BaseException.message` has been deprecated as of Python 2.6 and is removed in Python 3.
ignore= E114,E116,E121,E122,E123,E124,E125,E126,E127,E128,E129,E131,E201,E228,E231,E241,E251,E265,E271,
E302,E303,E305,E402,E713,E714,E722,E731,E999,
H102,H104,H105,H106,H201,H231,H233,H236,H306,H401,H403,H404,H405,H501,
H102,H104,H105,H106,H201,H233,H236,H306,H401,H403,H404,H405,H501,
F401,F811,F821,F841,
B001,B004,B006,B007,B008,B303,B305,B306
# Enable checks which are off by default