|
1 | 1 |
|
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. |
3 | 4 |
|
4 | 5 | import pandas as pd |
5 | 6 | import os |
6 | 7 | import subprocess |
7 | 8 | import shutil |
8 | 9 | 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 |
9 | 16 |
|
10 | 17 | os_name = platform.system() |
11 | 18 |
|
|
21 | 28 | folder = df[0].values |
22 | 29 | case = df[1].values |
23 | 30 |
|
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) |
25 | 37 |
|
26 | 38 | for i in range(len(folder)): |
| 39 | + print(case[i]) |
27 | 40 | os.chdir(outdir + folder[i]) |
28 | 41 | 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) |
30 | 43 | else: |
31 | | - subprocess.run([smokeview_path,'-runscript',case[i]]) |
| 44 | + subprocess.run([smokeview_path,'-runscript',case[i]], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) |
32 | 45 | os.chdir(original_dir) |
33 | 46 |
|
0 commit comments