Enable Exception.message Deprecated/Removed Error

Flake8 currently ignores 'BaseException.message' removed in python3
Enable B306 for more thorough testing of code

Change-Id: I9fbb01e8f61d679f4e611324efca6017c3b210e8
Story: 2004515
Task: 30076
Signed-off-by: Eric Barrett <eric.barrett@windriver.com>
This commit is contained in:
Eric Barrett 2019-03-21 14:35:20 -04:00
parent 360ad25564
commit c16a89581c
4 changed files with 9 additions and 10 deletions

View File

@ -60,7 +60,7 @@ class HandleUpgradesMixin(object):
except IOError as e:
raise exception.CephApiFailure(
call="osd_set_key",
reason=e.message)
reason=str(e))
else:
if not response.ok:
raise exception.CephSetKeyFailure(
@ -299,7 +299,7 @@ class Monitor(HandleUpgradesMixin):
response, fsid = self.service.ceph_api.fsid(
body='text', timeout=30)
except IOError as e:
LOG.warning(_LW("ceph_api.fsid failed: %s") % str(e.message))
LOG.warning(_LW("ceph_api.fsid failed: %s") % str(e))
self.cluster_is_up = False
return None
@ -317,7 +317,7 @@ class Monitor(HandleUpgradesMixin):
response, body = self.service.ceph_api.health(
body='text', timeout=30)
except IOError as e:
LOG.warning(_LW("ceph_api.health failed: %s") % str(e.message))
LOG.warning(_LW("ceph_api.health failed: %s") % str(e))
self.cluster_is_up = False
return {'health': constants.CEPH_HEALTH_DOWN,
'detail': 'Ceph cluster is down.'}

View File

@ -1264,7 +1264,7 @@ def createDB(influx_info, grafana_port, grafana_api_key):
if p is not None:
p.kill()
except Exception as e:
print(e.message)
print(str(e))
sys.exit(0)
@ -1308,7 +1308,7 @@ def deleteDB(influx_info, grafana_port, grafana_api_key):
if p is not None:
p.kill()
except Exception as e:
print(e.message)
print(str(e))
sys.exit(0)

View File

@ -65,7 +65,7 @@ def convertTime(file, node, start, lc, utcTime):
epoch = int(time.mktime(time.strptime(utcTime[:23], pattern)))
return str(epoch)
except Exception as e:
appendToFile("/tmp/csv-to-influx.log", "Error: Issue converting time for {} for {}. Please check the csv and re-parse as some data may be incorrect\n-{}".format(file, node, e.message))
appendToFile("/tmp/csv-to-influx.log", "Error: Issue converting time for {} for {}. Please check the csv and re-parse as some data may be incorrect\n-{}".format(file, node, str(e)))
return None
@ -320,7 +320,7 @@ def parse(path, file, node, options, influx_info):
"{} lines parsed in {} for {}".format(line_count, file_name, node))
break
except IOError as e:
appendToFile("/tmp/csv-to-influx.log", "Error: Issue opening {}\n-{}".format(file_loc, e.message))
appendToFile("/tmp/csv-to-influx.log", "Error: Issue opening {}\n-{}".format(file_loc, str(e)))
except (KeyboardInterrupt, SystemExit):
sys.exit(0)
else:
@ -363,7 +363,7 @@ def generateString(file, node, meas, tag_n, tag_v, field_n, field_v, lc, date):
return None
return base + '\n'
except Exception as e:
appendToFile("/tmp/csv-to-influx.log", "Error: Issue with http api string with {} for {}\n-{}".format(file, node, e.message))
appendToFile("/tmp/csv-to-influx.log", "Error: Issue with http api string with {} for {}\n-{}".format(file, node, str(e)))
return None

View File

@ -84,7 +84,6 @@ commands =
# B001 Do not use bare `except:
# B007 Loop control variable 'cpu' not used within the loop body.
# B301 Python 3 does not include `.iter*` methods on dictionaries.
# B306 `BaseException.message` has been deprecated as of Python 2.6 and is removed in Python 3.
# F series
# F401 'module' imported but unused
# F841 local variable '_alarm_state' is assigned to but never used
@ -92,7 +91,7 @@ ignore = E121,E123,E124,E125,E126,E127,E128,E201,E202,E203,E211,E221,E222,E225,E
E302,E303,E305,E402,E501,E722,E741,
H101,H102,H104,H201,H238,H237,H306,H401,H404,H405,
W191,W291,W391,W503,
B001,B007,B301,B306,
B001,B007,B301,
F401,F841
[testenv:pep8]