From 2935a44559ec0947bf23ae1b55ab85fb2ce8b15c Mon Sep 17 00:00:00 2001 From: Caleb Johnson Date: Tue, 24 Sep 2024 16:13:04 -0500 Subject: [PATCH] Bring try/raise inside file context --- qiskit_addon_dice_solver/dice_solver.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/qiskit_addon_dice_solver/dice_solver.py b/qiskit_addon_dice_solver/dice_solver.py index c009133..b680a4d 100644 --- a/qiskit_addon_dice_solver/dice_solver.py +++ b/qiskit_addon_dice_solver/dice_solver.py @@ -190,17 +190,17 @@ def _call_dice(working_dir: Path, mpirun_options: Sequence[str] | str | None) -> else: dice_call = ["mpirun", dice_path] - try: - with open(dice_log_path, "w") as logfile: + with open(dice_log_path, "w") as logfile: + try: subprocess.run( dice_call, cwd=working_dir, stdout=logfile, stderr=logfile, check=True ) - except subprocess.CalledProcessError as e: - raise DiceExecutionError( - command=dice_call, - returncode=e.returncode, - log_path=dice_log_path, - ) from e + except subprocess.CalledProcessError as e: + raise DiceExecutionError( + command=dice_call, + returncode=e.returncode, + log_path=dice_log_path, + ) from e def _write_input_files(