From 0789a389310c5025f5c696453bedc7d4bb4c35c7 Mon Sep 17 00:00:00 2001 From: GBenedett Date: Wed, 12 Jun 2024 11:46:36 +0200 Subject: [PATCH] check=True --- ceasiompy/PyAVL/avlrun.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/ceasiompy/PyAVL/avlrun.py b/ceasiompy/PyAVL/avlrun.py index 9d18ed614..f6c0c27c5 100644 --- a/ceasiompy/PyAVL/avlrun.py +++ b/ceasiompy/PyAVL/avlrun.py @@ -96,14 +96,24 @@ def run_avl(cpacs_path, wkdir): ref_density=density, g_acceleration=g, ) - subprocess.run(["xvfb-run", "avl"], stdin=open(str(command_path), "r"), cwd=case_dir_path) + run_avl_command = ["xvfb-run", "avl"] + with open(command_path, "r") as command_file: + subprocess.run( + run_avl_command, + stdin=command_file, + cwd=case_dir_path, + start_new_session=False, + check=True, # This will raise an exception if the command fails + ) if save_fig: conversion_command = ["ps2pdf", "plot.ps", "plot.pdf"] - subprocess.call(conversion_command, cwd=case_dir_path, start_new_session=False) + subprocess.run( + conversion_command, cwd=case_dir_path, start_new_session=False, check=True + ) delete_ps = ["rm", "plot.ps"] - subprocess.call(delete_ps, cwd=case_dir_path, start_new_session=False) + subprocess.run(delete_ps, cwd=case_dir_path, start_new_session=False, check=True) # =================================================================================================