Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Re-enabled exception catching and started the process of adding curses so I can make a more useful output display
  • Loading branch information
daminton committed Nov 21, 2022
1 parent d44dc07 commit 8434e68
Showing 1 changed file with 24 additions and 22 deletions.
46 changes: 24 additions & 22 deletions python/swiftest/swiftest/simulation_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import json
import os
from pathlib import Path
import sys
import curses
import datetime
import xarray as xr
import numpy as np
Expand Down Expand Up @@ -397,27 +397,29 @@ def run(self,**kwargs):
f.write(f"{str(self.driver_executable)} {self.integrator} {str(self.param_file)} compact\n")

cmd = f"{env['SHELL']} -l {driver_script}"
oldline = None
with subprocess.Popen(shlex.split(cmd),
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
env=env,
universal_newlines=True) as p:
for line in p.stdout:
if '[' in line:
print(line.replace('\n','\r'), end='')
elif "Normal termination" in line:
print(line.replace("Normal termination","\n\nNormal termination"),end='')
else:
print(line, end='')
res = p.communicate()
if p.returncode != 0:
for line in res[1]:
print(line, end='')
raise Exception ("Failure in swiftest_driver")
#except:
# warnings.warn(f"Error executing main swiftest_driver program",stacklevel=2)
# return

stdscr = curses.initscr()
try:
with subprocess.Popen(shlex.split(cmd),
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
env=env,
universal_newlines=True) as p:
for line in p.stdout:
if '[' in line:
print(line.replace('\n','\r'), end='')
elif "Normal termination" in line:
print(line.replace("Normal termination","\n\nNormal termination"),end='')
else:
print(line, end='')
res = p.communicate()
if p.returncode != 0:
for line in res[1]:
print(line, end='')
warnings.warn("Failure in swiftest_driver", stacklevel=2)
except:
warnings.warn(f"Error executing main swiftest_driver program",stacklevel=2)
return

# Read in new data
self.bin2xr()
Expand Down

0 comments on commit 8434e68

Please sign in to comment.