From c16a89581c2e4212127d8c17e724949474655bb0 Mon Sep 17 00:00:00 2001 From: Eric Barrett Date: Thu, 21 Mar 2019 14:35:20 -0400 Subject: [PATCH] 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 --- ceph/ceph-manager/ceph-manager/ceph_manager/monitor.py | 6 +++--- tools/engtools/hostdata-collectors/scripts/live_stream.py | 4 ++-- tools/engtools/parsers/common/csv-to-influx.py | 6 +++--- tox.ini | 3 +-- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/ceph/ceph-manager/ceph-manager/ceph_manager/monitor.py b/ceph/ceph-manager/ceph-manager/ceph_manager/monitor.py index 364ac96db..5ddfca595 100644 --- a/ceph/ceph-manager/ceph-manager/ceph_manager/monitor.py +++ b/ceph/ceph-manager/ceph-manager/ceph_manager/monitor.py @@ -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.'} diff --git a/tools/engtools/hostdata-collectors/scripts/live_stream.py b/tools/engtools/hostdata-collectors/scripts/live_stream.py index 7346b44f6..09d9ae41c 100644 --- a/tools/engtools/hostdata-collectors/scripts/live_stream.py +++ b/tools/engtools/hostdata-collectors/scripts/live_stream.py @@ -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) diff --git a/tools/engtools/parsers/common/csv-to-influx.py b/tools/engtools/parsers/common/csv-to-influx.py index 8adce1c15..004393260 100755 --- a/tools/engtools/parsers/common/csv-to-influx.py +++ b/tools/engtools/parsers/common/csv-to-influx.py @@ -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 diff --git a/tox.ini b/tox.ini index ee68ff73b..7d8965ce3 100644 --- a/tox.ini +++ b/tox.ini @@ -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]