Skip to content

Commit

Permalink
more ci debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
wtbarnes committed Jan 5, 2024
1 parent 130f9ee commit 4b79ba0
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions hissw/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,13 @@ def run(self, script, args=None, save_vars=None, raise_exceptions=True):
# Expose the ssw_home variable in all scripts by default
args.update({'ssw_home': self.ssw_home})
with tempfile.TemporaryDirectory() as tmpdir:
tmpdir = pathlib.Path(tmpdir)
tmpdir_path = pathlib.Path(tmpdir)
date_string = datetime.datetime.now().strftime('%Y%m%d-%H%M%S')
# Construct temporary filenames
save_filename = tmpdir / f'idl_vars_{date_string}.sav'
procedure_filename = tmpdir / f'idl_procedure_{date_string}.pro'
command_filename = tmpdir / f'idl_script_{date_string}.pro'
shell_filename = tmpdir / f'ssw_shell_{date_string}.sh'
save_filename = tmpdir_path / f'idl_vars_{date_string}.sav'
procedure_filename = tmpdir_path / f'idl_procedure_{date_string}.pro'
command_filename = tmpdir_path / f'idl_script_{date_string}.pro'
shell_filename = tmpdir_path / f'ssw_shell_{date_string}.sh'
# Render and write scripts
idl_script = self.custom_script(script, args)
files = [
Expand All @@ -206,20 +206,23 @@ def run(self, script, args=None, save_vars=None, raise_exceptions=True):
with open(filename, 'w') as f:
f.write(filescript)
# Execute
os.chmod(shell_filename, mode=stat.S_IRWXU)
on_windows = platform.system().lower() == 'windows'
cmd_output = subprocess.run(
shell_filename.name if on_windows else f'./{shell_filename.name}',
cwd=shell_filename.parent,
shell=True,
capture_output=True,
text=True,
)
self._check_for_errors(cmd_output, raise_exceptions=raise_exceptions)
self._run_shell_script(shell_filename, raise_exceptions)
results = readsav(save_filename)

return results

def _run_shell_script(self, path, raise_exceptions):
os.chmod(path, mode=stat.S_IRWXU)
on_windows = platform.system().lower() == 'windows'
cmd_output = subprocess.run(
path.name if on_windows else f'./{path.name}',
cwd=path.parent,
shell=True,
capture_output=True,
text=True,
)
self._check_for_errors(cmd_output, raise_exceptions=raise_exceptions)

def _check_for_errors(self, output, raise_exceptions=True):
"""
Check IDL output to try and decide if an error has occurred
Expand Down

0 comments on commit 4b79ba0

Please sign in to comment.