Skip to content

Commit be5b3fb

Browse files
committed
Really fix #741
1 parent b338724 commit be5b3fb

File tree

1 file changed

+10
-18
lines changed

1 file changed

+10
-18
lines changed

puppetboard/utils.py

+10-18
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def url_for_field(field, value):
1919

2020

2121
def jsonprint(value):
22-
return json.dumps(value, indent=2, separators=(',', ': '))
22+
return json.dumps(value, indent=2, separators=(",", ": "))
2323

2424

2525
def check_db_version(puppetdb):
@@ -30,8 +30,8 @@ def check_db_version(puppetdb):
3030
current_version = puppetdb.current_version()
3131
log.info(f"PuppetDB version: {current_version}")
3232

33-
current_semver = current_version.split('-')[0]
34-
minimum_semver = '5.2.0'
33+
current_semver = current_version.split("-")[0]
34+
minimum_semver = "5.2.0"
3535

3636
if parse(current_semver) < parse(minimum_semver):
3737
log.error(f"The minimum supported version of PuppetDB is {minimum_semver}")
@@ -54,12 +54,7 @@ def check_secret_key(secret_key_value):
5454
being accepted in v5.x of the app.
5555
"""
5656

57-
# Flask's SECRET_KEY can be bytes or string, but for the check below
58-
# we need it to be a string
59-
if type(secret_key_value) is bytes:
60-
secret_key_value = secret_key_value.decode("utf-8")
61-
62-
if secret_key_value.startswith("default-"):
57+
if type(secret_key_value) is str and secret_key_value.startswith("default-"):
6358
log.warning(
6459
"Leaving SECRET_KEY set to a default value WILL cause issues"
6560
" when the app is restarted or has more than 1 replica"
@@ -72,7 +67,7 @@ def check_secret_key(secret_key_value):
7267
"Please see"
7368
" https://github.com/voxpupuli/puppetboard/issues/721"
7469
" for more info."
75-
)
70+
)
7671

7772

7873
def parse_python(value: str):
@@ -104,8 +99,7 @@ def formatvalue(value):
10499

105100

106101
def get_or_abort(func, *args, **kwargs):
107-
"""Perform a backend request and handle all the errors,
108-
"""
102+
"""Perform a backend request and handle all the errors,"""
109103
return _do_get_or_abort(False, func, *args, **kwargs)
110104

111105

@@ -166,19 +160,17 @@ def quote_columns_data(data: str) -> str:
166160
interpret the dot a way to get into a nested results object.
167161
168162
See https://datatables.net/reference/option/columns.data#Types."""
169-
return data.replace('.', '\\.')
163+
return data.replace(".", "\\.")
170164

171165

172166
def check_env(env: str, envs: dict):
173-
if env != '*' and env not in envs:
167+
if env != "*" and env not in envs:
174168
abort(404)
175169

176170

177171
def is_a_test():
178172
running_in_shell = any(
179-
pytest_binary in sys.argv[0] for pytest_binary in ['pytest', 'py.test']
180-
)
181-
running_in_intellij = any(
182-
'_jb_pytest_runner.py' in arg for arg in sys.argv
173+
pytest_binary in sys.argv[0] for pytest_binary in ["pytest", "py.test"]
183174
)
175+
running_in_intellij = any("_jb_pytest_runner.py" in arg for arg in sys.argv)
184176
return running_in_shell or running_in_intellij

0 commit comments

Comments
 (0)