28 lines
665 B
Python
28 lines
665 B
Python
import pathlib
|
|
import subprocess
|
|
import configparser
|
|
import shutil
|
|
import tempfile
|
|
|
|
|
|
config = configparser.ConfigParser()
|
|
config.read("config.ini")
|
|
|
|
inp = pathlib.Path(config.get("swash", "input"))
|
|
out = pathlib.Path(config.get("swash", "out"))
|
|
|
|
with tempfile.TemporaryDirectory(prefix="swash_", dir=".") as tmp_raw:
|
|
tmpdir = pathlib.Path(tmp_raw)
|
|
|
|
shutil.copy2(inp, tmpdir)
|
|
shutil.copytree(
|
|
pathlib.Path(config.get("data", "out")), tmpdir, dirs_exist_ok=True
|
|
)
|
|
|
|
subprocess.run(
|
|
(config.get("swash", "swashrun"), "-input", inp.name), cwd=tmpdir
|
|
)
|
|
|
|
if out.exists():
|
|
shutil.rmtree(out)
|
|
shutil.move(tmpdir, out)
|