Unpin flake8, fix lint

Change-Id: I7f47c1dac0761101980ebba3f9aab8732cb0d1ce
This commit is contained in:
Frode Nordahl 2020-08-26 16:15:23 +02:00
parent e350ff6144
commit 0ca99c2fc3
No known key found for this signature in database
GPG Key ID: 6A5D59A3BA48373F
9 changed files with 15 additions and 12 deletions

View File

@ -63,6 +63,7 @@ def osd_in(args):
check_call(cmd)
assess_status()
# A dictionary of all the defined actions to callables (which take
# parsed arguments).
ACTIONS = {"osd-out": osd_out, "osd-in": osd_in}

View File

@ -43,5 +43,6 @@ def main():
}
return audits.action_parse_results(audits.run(config))
if __name__ == "__main__":
sys.exit(main())

View File

@ -66,7 +66,7 @@ def zap():
len(failed_devices),
", ".join(failed_devices))
if not_block_devices:
if message is not '':
if len(message):
message += "\n\n"
message += "{} devices are not block devices: {}".format(
len(not_block_devices),

View File

@ -53,9 +53,9 @@ def run_main():
# command in the collect phase does fail, and so the start of the line is
# 'Failed'
state = STATE_OK
for l in lines:
print(l, end='')
if l.startswith('Failed'):
for line in lines:
print(line, end='')
if line.startswith('Failed'):
state = STATE_CRITICAL
return state

View File

@ -20,7 +20,8 @@ def check_ceph_status(args):
.check_output(["ceph", "status"])
.decode('UTF-8')
.split('\n'))
status_data = dict(l.strip().split(' ', 1) for l in lines if len(l) > 1)
status_data = dict(
line.strip().split(' ', 1) for line in lines if len(line) > 1)
if ('health' not in status_data or
'monmap' not in status_data or
@ -40,7 +41,7 @@ def check_ceph_status(args):
msg += '"'
raise nagios_plugin.CriticalError(msg)
osds = re.search("^.*: (\d+) osds: (\d+) up, (\d+) in",
osds = re.search(r"^.*: (\d+) osds: (\d+) up, (\d+) in",
status_data['osdmap'])
if osds.group(1) > osds.group(2): # not all OSDs are "up"
msg = 'CRITICAL: Some OSDs are not up. Total: {}, up: {}'.format(

View File

@ -30,8 +30,8 @@ def lsb_release():
"""Return /etc/lsb-release in a dict"""
d = {}
with open('/etc/lsb-release', 'r') as lsb:
for l in lsb:
k, v = l.split('=')
for el in lsb:
k, v = el.split('=')
d[k.strip()] = v.strip()
return d

View File

@ -245,7 +245,7 @@ def get_blacklist():
def get_journal_devices():
if config('osd-journal'):
devices = [l.strip() for l in config('osd-journal').split(' ')]
devices = [el.strip() for el in config('osd-journal').split(' ')]
else:
devices = []
storage_ids = storage_list('osd-journals')
@ -287,6 +287,6 @@ def is_sata30orless(device):
result = subprocess.check_output(["/usr/sbin/smartctl", "-i", device])
print(result)
for line in str(result).split("\\n"):
if re.match("SATA Version is: *SATA (1\.|2\.|3\.0)", str(line)):
if re.match(r"SATA Version is: *SATA (1\.|2\.|3\.0)", str(line)):
return True
return False

View File

@ -10,7 +10,7 @@
charm-tools>=2.4.4
requests>=2.18.4
mock>=1.2
flake8>=2.2.4,<=2.4.1
flake8>=2.2.4
stestr>=2.2.0
coverage>=4.5.2
pyudev # for ceph-* charm unit tests (need to fix the ceph-* charm unit tests/mocking)

View File

@ -116,5 +116,5 @@ commands =
functest-run-suite --keep-model --bundle {posargs}
[flake8]
ignore = E402,E226
ignore = E402,E226,W504
exclude = */charmhelpers