1
Fork 0

Added swashrun python

This commit is contained in:
Edgar P. Burkhart 2022-03-02 14:41:27 +01:00
parent abed1cd0dc
commit c4fd6754ab
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227
2 changed files with 30 additions and 0 deletions

View file

@ -13,4 +13,6 @@ psize=Psize.dat
root=cache root=cache
[swash] [swash]
input=sws/INPUT.sws
swashrun=/opt/swash/swash/swashrun
out=out out=out

28
swash/processing/swash.py Normal file
View file

@ -0,0 +1,28 @@
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_") as tmp_raw:
tmpdir = pathlib.Path(tmp_raw)
shutil.copy2(inp, tmpdir)
shutil.copytree(
pathlib.Path(config.get("out", "root")), tmpdir, dirs_exist_ok=True
)
subprocess.run(
(config.get("swash", "swashrun"), "-input", inp.name), cwd=tmpdir
)
if out.exists():
shutil.rmtree(out)
shutil.copytree(tmpdir, out)