2022-03-02 14:41:27 +01:00
|
|
|
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"))
|
|
|
|
|
2022-03-02 16:03:00 +01:00
|
|
|
with tempfile.TemporaryDirectory(prefix="swash_", dir=".") as tmp_raw:
|
2022-03-02 14:41:27 +01:00
|
|
|
tmpdir = pathlib.Path(tmp_raw)
|
|
|
|
|
|
|
|
shutil.copy2(inp, tmpdir)
|
|
|
|
shutil.copytree(
|
2022-03-03 10:58:49 +01:00
|
|
|
pathlib.Path(config.get("data", "out")), tmpdir, dirs_exist_ok=True
|
2022-03-02 14:41:27 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
subprocess.run(
|
|
|
|
(config.get("swash", "swashrun"), "-input", inp.name), cwd=tmpdir
|
|
|
|
)
|
|
|
|
|
|
|
|
if out.exists():
|
|
|
|
shutil.rmtree(out)
|
2022-03-02 16:03:00 +01:00
|
|
|
shutil.move(tmpdir, out)
|