Skip to content

Commit

Permalink
try to fix subprocess command
Browse files Browse the repository at this point in the history
  • Loading branch information
wtbarnes committed Jan 5, 2024
1 parent 933fc05 commit 148123d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions hissw/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import datetime
import os
import pathlib
import platform
import stat
import subprocess
import tempfile
Expand Down Expand Up @@ -188,12 +189,12 @@ def run(self, script, args=None, save_vars=None, raise_exceptions=True):
with tempfile.TemporaryDirectory() as tmpdir:
tmpdir = pathlib.Path(tmpdir)
date_string = datetime.datetime.now().strftime('%Y%m%d-%H%M%S')
# Get filenames
# 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'
# Render and save scripts
# Render and write scripts
idl_script = self.custom_script(script, args)
files = [
(procedure_filename, self.procedure_script(idl_script, save_vars, save_filename)),
Expand All @@ -206,8 +207,10 @@ def run(self, script, args=None, save_vars=None, raise_exceptions=True):
f.write(filescript)
# Execute
os.chmod(shell_filename, mode=stat.S_IRWXU)
on_windows = platform.system().lower() == 'windows'
cmd_output = subprocess.run(
[shell_filename],
shell_filename.name if on_windows else f'./{shell_filename.name}',
cwd=shell_filename.parent,
shell=True,
capture_output=True,
text=True,
Expand Down

0 comments on commit 148123d

Please sign in to comment.