Skip to content

Commit

Permalink
fix some lint for python
Browse files Browse the repository at this point in the history
  • Loading branch information
bodsch committed Nov 12, 2024
1 parent 6a92b3c commit 03295cf
Show file tree
Hide file tree
Showing 38 changed files with 266 additions and 267 deletions.
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# E221 multiple spaces before operator
# E251 unexpected spaces around keyword / parameter equals

ignore = E221,E251
# ignore = E221,E251

exclude =
# No need to traverse our git directory
Expand Down
1 change: 0 additions & 1 deletion plugins/filter/grafana.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ def keyfiles(self, data):

return result


def content_security_policy(self, data):
"""
"""
Expand Down
8 changes: 4 additions & 4 deletions plugins/filter/verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ def validate_datasource_type(self, data):
)

return dict(
valid = True,
msg = "All datasources are valid."
valid=True,
msg="All datasources are valid."
)

def absent_datasources(self, data):
Expand All @@ -121,8 +121,8 @@ def absent_datasources(self, data):
# res = {}
if values.get("state", "present") == "absent":
res = dict(
name = datasource,
orgId = values.get("org_id", 1)
name=datasource,
orgId=values.get("org_id", 1)
)
result.append(res)

Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/grafana_api_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def run(self):
self.module.log(msg=f" all : {self.grafana_api_keys} / {type(self.grafana_api_keys)}")

present_keys = [v for v in self.grafana_api_keys if v.get('state', "present") == "present"]
absent_keys = [v for v in self.grafana_api_keys if v.get('state', "present") == "absent"]
absent_keys = [v for v in self.grafana_api_keys if v.get('state', "present") == "absent"]
# disabled_keys = [v for v in self.grafana_api_keys if v.get('state', "present") == "disabled"]

# self.module.log(msg=f" present : {present_keys}")
Expand Down
26 changes: 13 additions & 13 deletions plugins/modules/grafana_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ def _list(self):
_failed = False

return dict(
failed = _failed,
changed = _changed,
installed = plugin_list
failed=_failed,
changed=_changed,
installed=plugin_list
)

def _list_remote(self):
Expand Down Expand Up @@ -162,9 +162,9 @@ def _install(self):

if len(self.plugins) == 0:
return dict(
failed = True,
changed =False,
msg = "Missing a list of Plugins to install."
failed=True,
changed=False,
msg="Missing a list of Plugins to install."
)

plugin_list = self._list()
Expand Down Expand Up @@ -196,8 +196,8 @@ def _install(self):

res = {}
res[p] = dict(
failed = False,
changed = False,
failed=False,
changed=False,
state=f"already in version {plugin_version} installed."
)
result_state.append(res)
Expand All @@ -217,8 +217,8 @@ def _install(self):

res = {}
res[p] = dict(
failed = False,
changed = True,
failed=False,
changed=True,
state=f"version {version_string} successfuly installed."
)
result_state.append(res)
Expand Down Expand Up @@ -249,9 +249,9 @@ def _install(self):
# self.module.log(msg=f" result_msg : '{result_msg}'")

return dict(
failed = failed,
changed = changed,
msg = result_msg
failed=failed,
changed=changed,
msg=result_msg
)

def _uninstall(self):
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/grafana_service_accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def run(self):
self.module.log(msg=f" account : {self.grafana_service_accounts}")

present_keys = [v for v in self.grafana_service_accounts if v.get('state', "present") == "present"]
absent_keys = [v for v in self.grafana_service_accounts if v.get('state', "present") == "absent"]
absent_keys = [v for v in self.grafana_service_accounts if v.get('state', "present") == "absent"]
# disabled_keys = [v for v in self.grafana_service_accounts if v.get('state', "present") == "disabled"]

# self.module.log(msg=f" must present : {present_keys}")
Expand Down
6 changes: 3 additions & 3 deletions plugins/modules/loki_verify_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ def run(self):
msg = err

result = dict(
failed = _failed,
changed = False,
failed=_failed,
changed=False,
cmd=" ".join(args),
msg = msg
msg=msg
)

return result
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/sync_dashboards.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def main():
"""
"""
args = dict(
source_directory = dict(
source_directory=dict(
required=True,
type='str'
),
Expand Down
18 changes: 9 additions & 9 deletions roles/grafana/molecule/configured/tests/test_default.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def read_ansible_yaml(file_name, role_name):
read_file = None

for e in ["yml", "yaml"]:
test_file = "{}.{}".format(file_name, e)
test_file = f"{file_name}.{e}"
if os.path.isfile(test_file):
read_file = test_file
break
Expand Down Expand Up @@ -76,16 +76,16 @@ def get_vars(host):
# print(" -> {} / {}".format(distribution, os))
# print(" -> {}".format(base_dir))

file_defaults = read_ansible_yaml(f"{base_dir}/defaults/main", "role_defaults")
file_vars = read_ansible_yaml(f"{base_dir}/vars/main", "role_vars")
file_distibution = read_ansible_yaml(f"{base_dir}/vars/{operation_system}", "role_distibution")
file_molecule = read_ansible_yaml(f"{molecule_dir}/group_vars/all/vars", "test_vars")
file_defaults = read_ansible_yaml(f"{base_dir}/defaults/main", "role_defaults")
file_vars = read_ansible_yaml(f"{base_dir}/vars/main", "role_vars")
file_distibution = read_ansible_yaml(f"{base_dir}/vars/{operation_system}", "role_distibution")
file_molecule = read_ansible_yaml(f"{molecule_dir}/group_vars/all/vars", "test_vars")
# file_host_molecule = read_ansible_yaml("{}/host_vars/{}/vars".format(base_dir, HOST), "host_vars")

defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults")
vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars")
distibution_vars = host.ansible("include_vars", file_distibution).get("ansible_facts").get("role_distibution")
molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars")
defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults")
vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars")
distibution_vars = host.ansible("include_vars", file_distibution).get("ansible_facts").get("role_distibution")
molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars")
# host_vars = host.ansible("include_vars", file_host_molecule).get("ansible_facts").get("host_vars")

ansible_vars = defaults_vars
Expand Down
16 changes: 8 additions & 8 deletions roles/grafana/molecule/default/tests/test_grafana.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,16 @@ def get_vars(host):
# print(" -> {} / {}".format(distribution, os))
# print(" -> {}".format(base_dir))

file_defaults = read_ansible_yaml(f"{base_dir}/defaults/main", "role_defaults")
file_vars = read_ansible_yaml(f"{base_dir}/vars/main", "role_vars")
file_distibution = read_ansible_yaml(f"{base_dir}/vars/{operation_system}", "role_distibution")
file_molecule = read_ansible_yaml(f"{molecule_dir}/group_vars/all/vars", "test_vars")
file_defaults = read_ansible_yaml(f"{base_dir}/defaults/main", "role_defaults")
file_vars = read_ansible_yaml(f"{base_dir}/vars/main", "role_vars")
file_distibution = read_ansible_yaml(f"{base_dir}/vars/{operation_system}", "role_distibution")
file_molecule = read_ansible_yaml(f"{molecule_dir}/group_vars/all/vars", "test_vars")
# file_host_molecule = read_ansible_yaml("{}/host_vars/{}/vars".format(base_dir, HOST), "host_vars")

defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults")
vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars")
distibution_vars = host.ansible("include_vars", file_distibution).get("ansible_facts").get("role_distibution")
molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars")
defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults")
vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars")
distibution_vars = host.ansible("include_vars", file_distibution).get("ansible_facts").get("role_distibution")
molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars")
# host_vars = host.ansible("include_vars", file_host_molecule).get("ansible_facts").get("host_vars")

ansible_vars = defaults_vars
Expand Down
16 changes: 8 additions & 8 deletions roles/grafana/molecule/default/tests/test_grafana_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,16 @@ def get_vars(host):
# print(" -> {} / {}".format(distribution, os))
# print(" -> {}".format(base_dir))

file_defaults = read_ansible_yaml(f"{base_dir}/defaults/main", "role_defaults")
file_vars = read_ansible_yaml(f"{base_dir}/vars/main", "role_vars")
file_distibution = read_ansible_yaml(f"{base_dir}/vars/{operation_system}", "role_distibution")
file_molecule = read_ansible_yaml(f"{molecule_dir}/group_vars/all/vars", "test_vars")
file_defaults = read_ansible_yaml(f"{base_dir}/defaults/main", "role_defaults")
file_vars = read_ansible_yaml(f"{base_dir}/vars/main", "role_vars")
file_distibution = read_ansible_yaml(f"{base_dir}/vars/{operation_system}", "role_distibution")
file_molecule = read_ansible_yaml(f"{molecule_dir}/group_vars/all/vars", "test_vars")
# file_host_molecule = read_ansible_yaml("{}/host_vars/{}/vars".format(base_dir, HOST), "host_vars")

defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults")
vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars")
distibution_vars = host.ansible("include_vars", file_distibution).get("ansible_facts").get("role_distibution")
molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars")
defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults")
vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars")
distibution_vars = host.ansible("include_vars", file_distibution).get("ansible_facts").get("role_distibution")
molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars")
# host_vars = host.ansible("include_vars", file_host_molecule).get("ansible_facts").get("host_vars")

ansible_vars = defaults_vars
Expand Down
16 changes: 8 additions & 8 deletions roles/grafana/molecule/default/tests/test_grafana_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,16 @@ def get_vars(host):
# print(" -> {} / {}".format(distribution, os))
# print(" -> {}".format(base_dir))

file_defaults = read_ansible_yaml(f"{base_dir}/defaults/main", "role_defaults")
file_vars = read_ansible_yaml(f"{base_dir}/vars/main", "role_vars")
file_distibution = read_ansible_yaml(f"{base_dir}/vars/{operation_system}", "role_distibution")
file_molecule = read_ansible_yaml(f"{molecule_dir}/group_vars/all/vars", "test_vars")
file_defaults = read_ansible_yaml(f"{base_dir}/defaults/main", "role_defaults")
file_vars = read_ansible_yaml(f"{base_dir}/vars/main", "role_vars")
file_distibution = read_ansible_yaml(f"{base_dir}/vars/{operation_system}", "role_distibution")
file_molecule = read_ansible_yaml(f"{molecule_dir}/group_vars/all/vars", "test_vars")
# file_host_molecule = read_ansible_yaml("{}/host_vars/{}/vars".format(base_dir, HOST), "host_vars")

defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults")
vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars")
distibution_vars = host.ansible("include_vars", file_distibution).get("ansible_facts").get("role_distibution")
molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars")
defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults")
vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars")
distibution_vars = host.ansible("include_vars", file_distibution).get("ansible_facts").get("role_distibution")
molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars")
# host_vars = host.ansible("include_vars", file_host_molecule).get("ansible_facts").get("host_vars")

ansible_vars = defaults_vars
Expand Down
16 changes: 8 additions & 8 deletions roles/grafana/molecule/latest/tests/test_grafana.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,16 @@ def get_vars(host):
# print(" -> {} / {}".format(distribution, os))
# print(" -> {}".format(base_dir))

file_defaults = read_ansible_yaml(f"{base_dir}/defaults/main", "role_defaults")
file_vars = read_ansible_yaml(f"{base_dir}/vars/main", "role_vars")
file_distibution = read_ansible_yaml(f"{base_dir}/vars/{operation_system}", "role_distibution")
file_molecule = read_ansible_yaml(f"{molecule_dir}/group_vars/all/vars", "test_vars")
file_defaults = read_ansible_yaml(f"{base_dir}/defaults/main", "role_defaults")
file_vars = read_ansible_yaml(f"{base_dir}/vars/main", "role_vars")
file_distibution = read_ansible_yaml(f"{base_dir}/vars/{operation_system}", "role_distibution")
file_molecule = read_ansible_yaml(f"{molecule_dir}/group_vars/all/vars", "test_vars")
# file_host_molecule = read_ansible_yaml("{}/host_vars/{}/vars".format(base_dir, HOST), "host_vars")

defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults")
vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars")
distibution_vars = host.ansible("include_vars", file_distibution).get("ansible_facts").get("role_distibution")
molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars")
defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults")
vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars")
distibution_vars = host.ansible("include_vars", file_distibution).get("ansible_facts").get("role_distibution")
molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars")
# host_vars = host.ansible("include_vars", file_host_molecule).get("ansible_facts").get("host_vars")

ansible_vars = defaults_vars
Expand Down
16 changes: 8 additions & 8 deletions roles/grafana/molecule/latest/tests/test_grafana_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,16 @@ def get_vars(host):
# print(" -> {} / {}".format(distribution, os))
# print(" -> {}".format(base_dir))

file_defaults = read_ansible_yaml(f"{base_dir}/defaults/main", "role_defaults")
file_vars = read_ansible_yaml(f"{base_dir}/vars/main", "role_vars")
file_distibution = read_ansible_yaml(f"{base_dir}/vars/{operation_system}", "role_distibution")
file_molecule = read_ansible_yaml(f"{molecule_dir}/group_vars/all/vars", "test_vars")
file_defaults = read_ansible_yaml(f"{base_dir}/defaults/main", "role_defaults")
file_vars = read_ansible_yaml(f"{base_dir}/vars/main", "role_vars")
file_distibution = read_ansible_yaml(f"{base_dir}/vars/{operation_system}", "role_distibution")
file_molecule = read_ansible_yaml(f"{molecule_dir}/group_vars/all/vars", "test_vars")
# file_host_molecule = read_ansible_yaml("{}/host_vars/{}/vars".format(base_dir, HOST), "host_vars")

defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults")
vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars")
distibution_vars = host.ansible("include_vars", file_distibution).get("ansible_facts").get("role_distibution")
molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars")
defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults")
vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars")
distibution_vars = host.ansible("include_vars", file_distibution).get("ansible_facts").get("role_distibution")
molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars")
# host_vars = host.ansible("include_vars", file_host_molecule).get("ansible_facts").get("host_vars")

ansible_vars = defaults_vars
Expand Down
16 changes: 8 additions & 8 deletions roles/grafana/molecule/latest/tests/test_grafana_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,16 @@ def get_vars(host):
# print(" -> {} / {}".format(distribution, os))
# print(" -> {}".format(base_dir))

file_defaults = read_ansible_yaml(f"{base_dir}/defaults/main", "role_defaults")
file_vars = read_ansible_yaml(f"{base_dir}/vars/main", "role_vars")
file_distibution = read_ansible_yaml(f"{base_dir}/vars/{operation_system}", "role_distibution")
file_molecule = read_ansible_yaml(f"{molecule_dir}/group_vars/all/vars", "test_vars")
file_defaults = read_ansible_yaml(f"{base_dir}/defaults/main", "role_defaults")
file_vars = read_ansible_yaml(f"{base_dir}/vars/main", "role_vars")
file_distibution = read_ansible_yaml(f"{base_dir}/vars/{operation_system}", "role_distibution")
file_molecule = read_ansible_yaml(f"{molecule_dir}/group_vars/all/vars", "test_vars")
# file_host_molecule = read_ansible_yaml("{}/host_vars/{}/vars".format(base_dir, HOST), "host_vars")

defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults")
vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars")
distibution_vars = host.ansible("include_vars", file_distibution).get("ansible_facts").get("role_distibution")
molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars")
defaults_vars = host.ansible("include_vars", file_defaults).get("ansible_facts").get("role_defaults")
vars_vars = host.ansible("include_vars", file_vars).get("ansible_facts").get("role_vars")
distibution_vars = host.ansible("include_vars", file_distibution).get("ansible_facts").get("role_distibution")
molecule_vars = host.ansible("include_vars", file_molecule).get("ansible_facts").get("test_vars")
# host_vars = host.ansible("include_vars", file_host_molecule).get("ansible_facts").get("host_vars")

ansible_vars = defaults_vars
Expand Down
Loading

0 comments on commit 03295cf

Please sign in to comment.