Skip to content

Commit

Permalink
Add changes suggested by pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
meaksh committed Jun 29, 2023
1 parent 6bfcc7b commit 7ee35b5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions salt/modules/openscap.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def xccdf_eval(
"""
Run ``oscap xccdf eval`` commands on minions.
.. versionadded:: 3007
.. versionadded:: 3007.0
It uses cp.push_dir to upload the generated files to the salt master
in the master's minion files cachedir
Expand Down Expand Up @@ -160,19 +160,19 @@ def xccdf_eval(

if not os.path.exists(xccdffile):
success = False
error = "XCCDF File '{}' does not exist".format(xccdffile)
error = f"XCCDF File '{xccdffile}' does not exist"
for ofile in ovalfiles:
if success and not os.path.exists(ofile):
success = False
error = "Oval File '{}' does not exist".format(ofile)
error = f"Oval File '{ofile}' does not exist"

if success:
tempdir = tempfile.mkdtemp()
proc = Popen(cmd_opts, stdout=PIPE, stderr=PIPE, cwd=tempdir)
(stdoutdata, error) = proc.communicate()
success = _OSCAP_EXIT_CODES_MAP.get(proc.returncode, False)
if proc.returncode < 0:
error += "\nKilled by signal {}\n".format(proc.returncode).encode("ascii")
error += f"\nKilled by signal {proc.returncode}\n".encode("ascii")
returncode = proc.returncode
if success:
if not __salt__["cp.push_dir"](tempdir):
Expand Down Expand Up @@ -229,7 +229,7 @@ def xccdf(params):
(stdoutdata, error) = proc.communicate()
success = _OSCAP_EXIT_CODES_MAP.get(proc.returncode, False)
if proc.returncode < 0:
error += "\nKilled by signal {}\n".format(proc.returncode).encode("ascii")
error += f"\nKilled by signal {proc.returncode}\n".encode("ascii")
returncode = proc.returncode
if success:
if not __salt__["cp.push_dir"](tempdir):
Expand Down
8 changes: 4 additions & 4 deletions tests/pytests/unit/modules/test_openscap.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def test_openscap_xccdf_eval_success(random_temp_dir):
return_value=Mock(**{"returncode": 0, "communicate.return_value": ("", "")})
),
):
response = openscap.xccdf("eval --profile Default {}".format(policy_file))
response = openscap.xccdf(f"eval --profile Default {policy_file}")

assert openscap.tempfile.mkdtemp.call_count == 1
expected_cmd = [
Expand Down Expand Up @@ -72,7 +72,7 @@ def test_openscap_xccdf_eval_success_with_failing_rules(random_temp_dir):
)
),
):
response = openscap.xccdf("eval --profile Default {}".format(policy_file))
response = openscap.xccdf(f"eval --profile Default {policy_file}")

assert openscap.tempfile.mkdtemp.call_count == 1
expected_cmd = [
Expand Down Expand Up @@ -164,7 +164,7 @@ def test_openscap_xccdf_eval_evaluation_error():
)
),
):
response = openscap.xccdf("eval --profile Default {}".format(policy_file))
response = openscap.xccdf(f"eval --profile Default {policy_file}")

assert response == {
"upload_dir": None,
Expand All @@ -175,7 +175,7 @@ def test_openscap_xccdf_eval_evaluation_error():


def test_openscap_xccdf_eval_fail_not_implemented_action():
response = openscap.xccdf("info {}".format(policy_file))
response = openscap.xccdf(f"info {policy_file}")
mock_err = "argument action: invalid choice: 'info' (choose from 'eval')"

assert response == {
Expand Down

0 comments on commit 7ee35b5

Please sign in to comment.