Skip to content

Commit

Permalink
fix error being thrown. Instead use returncode to evaluate if it worked
Browse files Browse the repository at this point in the history
  • Loading branch information
Toddelismyname committed Jan 22, 2025
1 parent 459a8d5 commit 4757a10
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions FileGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,15 +165,25 @@ def format_precice_config(self, output_path: Path) -> None:
# Format the precice-config.xml if found
if precice_config_path:
self.logger.info("Formatting preCICE configuration...")
# self.logger.info(precice_config_path)
try:
result = subprocess.run([sys.executable, 'format_precice_config.py', precice_config_path],
check=True,
check=False,
capture_output=True,
text=True)
self.logger.success("preCICE configuration formatted successfully.")
except subprocess.CalledProcessError as e:
self.logger.error(f"Error formatting preCICE configuration: {e.stderr}")

# Check return codes: 0 (success), 2 (file modified)
if result.returncode in [0, 2]:
self.logger.success("preCICE configuration formatted successfully.")
if result.returncode == 2:
self.logger.info("Configuration file was modified during formatting.")
else:
self.logger.error(f"Unexpected return code: {result.returncode}")
self.logger.error(f"Standard Output: {result.stdout}")
self.logger.error(f"Standard Error: {result.stderr}")

except Exception as e:
# Catch any unexpected exceptions
self.logger.error(f"Unexpected error formatting preCICE configuration: {e}")
else:
self.logger.error("No precice-config.xml found to format.")

Expand Down

0 comments on commit 4757a10

Please sign in to comment.