Noop Flake8 update
Fix modern flake8 complaints with no functional changes. Change-Id: I3eff9f9d8ee3952864ee0e78387b514c80c92bc4
This commit is contained in:
parent
f1c3deac35
commit
27b43f4bd6
|
@ -30,6 +30,7 @@ def _add_path(path):
|
|||
if path not in sys.path:
|
||||
sys.path.insert(1, path)
|
||||
|
||||
|
||||
_add_path(_root)
|
||||
_add_path(_hooks)
|
||||
|
||||
|
|
|
@ -205,6 +205,7 @@ def main(host, port, exname, extype, user, password, vhost, ssl, ssl_ca):
|
|||
|
||||
return ret
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = OptionParser()
|
||||
parser.add_option("--host", dest="host",
|
||||
|
|
|
@ -91,7 +91,7 @@ if __name__ == '__main__':
|
|||
partitions = len(json.loads(partition_data)['partitions'])
|
||||
cluster = len(json.loads(partition_data)['cluster_links'])
|
||||
|
||||
except:
|
||||
except json.decoder.JSONDecodeError:
|
||||
print(
|
||||
"UNKNOWN: Could not parse cluster status data returned by RabbitMQ"
|
||||
)
|
||||
|
|
|
@ -188,7 +188,7 @@ def list_vhosts():
|
|||
|
||||
if caching_cmp_pkgrevno('rabbitmq-server', '3.8.2') >= 0:
|
||||
decoded = json.loads(output)
|
||||
return [l['name'] for l in decoded]
|
||||
return [ll['name'] for ll in decoded]
|
||||
# NOTE(jamespage): Earlier rabbitmqctl versions append "...done"
|
||||
# to the output of list_vhosts
|
||||
elif '...done' in output:
|
||||
|
@ -258,7 +258,7 @@ def user_exists(user):
|
|||
cmd.append('--formatter=json')
|
||||
out = subprocess.check_output(cmd).decode('utf-8')
|
||||
decoded = json.loads(out)
|
||||
users = [l['user'] for l in decoded]
|
||||
users = [ll['user'] for ll in decoded]
|
||||
return user in users
|
||||
|
||||
# NOTE(ajkavanagh): pre 3.8.2 the code needs to deal with just a text
|
||||
|
@ -658,17 +658,17 @@ def execute(cmd, die=False, echo=False):
|
|||
stdout = ""
|
||||
stderr = ""
|
||||
|
||||
def print_line(l):
|
||||
def print_line(ll):
|
||||
if echo:
|
||||
print(l.strip('\n'))
|
||||
print(ll.strip('\n'))
|
||||
sys.stdout.flush()
|
||||
|
||||
for l in iter(p.stdout.readline, ''):
|
||||
print_line(l)
|
||||
stdout += l
|
||||
for l in iter(p.stderr.readline, ''):
|
||||
print_line(l)
|
||||
stderr += l
|
||||
for ll in iter(p.stdout.readline, ''):
|
||||
print_line(ll)
|
||||
stdout += ll
|
||||
for ll in iter(p.stderr.readline, ''):
|
||||
print_line(ll)
|
||||
stderr += ll
|
||||
|
||||
p.communicate()
|
||||
rc = p.returncode
|
||||
|
@ -1073,7 +1073,7 @@ def is_sufficient_peers():
|
|||
return False
|
||||
else:
|
||||
log("Sufficient number of peer units to form cluster {}"
|
||||
"".format(min_size, level=DEBUG))
|
||||
"".format(min_size), level=DEBUG)
|
||||
return True
|
||||
else:
|
||||
log("min-cluster-size is not defined, race conditions may occur if "
|
||||
|
|
|
@ -256,7 +256,7 @@ class RabbitMQEnvContext(object):
|
|||
|
||||
if os.path.exists(ENV_CONF):
|
||||
for line in open(ENV_CONF).readlines():
|
||||
if re.search('^\s*#', line) or not line.strip('\n'):
|
||||
if re.search(r'^\s*#', line) or not line.strip('\n'):
|
||||
# ignore commented or blank lines
|
||||
continue
|
||||
|
||||
|
|
|
@ -24,10 +24,12 @@ import subprocess
|
|||
_path = os.path.dirname(os.path.realpath(__file__))
|
||||
_root = os.path.abspath(os.path.join(_path, '..'))
|
||||
|
||||
|
||||
def _add_path(path):
|
||||
if path not in sys.path:
|
||||
sys.path.insert(1, path)
|
||||
|
||||
|
||||
_add_path(_root)
|
||||
|
||||
|
||||
|
@ -49,7 +51,7 @@ except ImportError:
|
|||
else:
|
||||
subprocess.check_call(['apt-get', 'install', '-y',
|
||||
'python3-requests'])
|
||||
import requests # flake8: noqa
|
||||
import requests # noqa: F401
|
||||
|
||||
import rabbit_net_utils
|
||||
import rabbit_utils as rabbit
|
||||
|
@ -67,7 +69,6 @@ from charmhelpers.contrib.hahelpers.cluster import (
|
|||
from charmhelpers.contrib.openstack.utils import (
|
||||
is_unit_paused_set,
|
||||
set_unit_upgrading,
|
||||
is_unit_upgrading_set,
|
||||
clear_unit_paused,
|
||||
clear_unit_upgrading,
|
||||
)
|
||||
|
@ -126,7 +127,6 @@ from charmhelpers.contrib.peerstorage import (
|
|||
peer_store,
|
||||
peer_store_and_set,
|
||||
peer_retrieve_by_prefix,
|
||||
leader_get,
|
||||
)
|
||||
|
||||
from charmhelpers.core.unitdata import kv
|
||||
|
@ -436,7 +436,8 @@ def cluster_changed(relation_id=None, remote_unit=None):
|
|||
return
|
||||
|
||||
if rabbit.is_sufficient_peers():
|
||||
# NOTE(freyes): all the nodes need to marked as 'clustered' (LP: #1691510)
|
||||
# NOTE(freyes): all the nodes need to marked as 'clustered'
|
||||
# (LP: #1691510)
|
||||
rabbit.cluster_with()
|
||||
|
||||
if not is_leader() and is_relation_made('nrpe-external-master'):
|
||||
|
@ -714,16 +715,14 @@ def update_nrpe_checks():
|
|||
)
|
||||
if config('management_plugin'):
|
||||
# add NRPE check
|
||||
_check_cmd = (
|
||||
'{}/check_rabbitmq_cluster.py --port {} --user {} --password {}'
|
||||
.format(NAGIOS_PLUGINS, rabbit.get_managment_port(),
|
||||
user, password))
|
||||
nrpe_compat.add_check(
|
||||
shortname=rabbit.RABBIT_USER + '_cluster',
|
||||
description='Check RabbitMQ Cluster',
|
||||
check_cmd='{}/check_rabbitmq_cluster.py --port {} --user {} --password {}'.format(
|
||||
NAGIOS_PLUGINS,
|
||||
rabbit.get_managment_port(),
|
||||
user,
|
||||
password
|
||||
)
|
||||
)
|
||||
check_cmd=_check_cmd)
|
||||
|
||||
nrpe_compat.write()
|
||||
|
||||
|
@ -969,6 +968,7 @@ def update_status():
|
|||
kvstore.get(INITIAL_CLIENT_UPDATE_KEY, False)):
|
||||
rabbit.check_cluster_memberships()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
hooks.execute(sys.argv)
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
charm-tools>=2.4.4
|
||||
coverage>=3.6
|
||||
mock>=1.2
|
||||
flake8>=2.2.4,<=2.4.1
|
||||
flake8>=2.2.4
|
||||
stestr>=2.2.0
|
||||
requests>=2.18.4
|
||||
pytz
|
||||
|
|
2
tox.ini
2
tox.ini
|
@ -118,5 +118,5 @@ commands =
|
|||
functest-run-suite --keep-model --bundle {posargs}
|
||||
|
||||
[flake8]
|
||||
ignore = E402,E226
|
||||
ignore = E402,E226,W504
|
||||
exclude = */charmhelpers
|
||||
|
|
|
@ -110,9 +110,9 @@ class TestConfig(object):
|
|||
return self.config
|
||||
|
||||
def set(self, attr, value):
|
||||
if attr not in self.config:
|
||||
raise KeyError
|
||||
self.config[attr] = value
|
||||
if attr not in self.config:
|
||||
raise KeyError
|
||||
self.config[attr] = value
|
||||
|
||||
def __getitem__(self, key):
|
||||
return self.get(key)
|
||||
|
|
Loading…
Reference in New Issue