Skip to content

Commit 50f1540

Browse files
authored
Merge pull request #15545 from mcgratta/master
Python: Add optional argument for smokeview image renderer
2 parents f00744a + 718fc1d commit 50f1540

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

Utilities/Python/scripts/make_smv_images.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11

2-
# Make Smokeview images for the FDS Manuals
2+
# Make Smokeview images for the FDS Manuals.
3+
# The script uses the command "smokeview" unless you provide an optional name.
34

45
import pandas as pd
56
import os
67
import subprocess
78
import shutil
89
import platform
10+
import argparse
11+
12+
parser = argparse.ArgumentParser(description="A script to generate Smokeview images")
13+
parser.add_argument("message", nargs="?", default="smokeview", help="Optional smokeview name")
14+
args = parser.parse_args()
15+
shell_command = args.message
916

1017
os_name = platform.system()
1118

@@ -21,13 +28,19 @@
2128
folder = df[0].values
2229
case = df[1].values
2330

24-
smokeview_path = shutil.which('smokeview')
31+
if os_name == "Linux":
32+
result = subprocess.run(["bash", "-i", "-c", f"alias {shell_command} 2>/dev/null | sed -E \"s/alias {shell_command}='(.*)'/\\1/\""],
33+
capture_output=True, text=True)
34+
smokeview_path=result.stdout.strip()
35+
else:
36+
smokeview_path = shutil.which(shell_command)
2537

2638
for i in range(len(folder)):
39+
print(case[i])
2740
os.chdir(outdir + folder[i])
2841
if os_name == "Linux":
29-
subprocess.run(['xvfb-run',smokeview_path,'-runscript',case[i]])
42+
subprocess.run(['xvfb-run',smokeview_path,'-runscript',case[i]], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
3043
else:
31-
subprocess.run([smokeview_path,'-runscript',case[i]])
44+
subprocess.run([smokeview_path,'-runscript',case[i]], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
3245
os.chdir(original_dir)
3346

0 commit comments

Comments
 (0)