Added swashrun python
This commit is contained in:
parent
abed1cd0dc
commit
c4fd6754ab
2 changed files with 30 additions and 0 deletions
|
@ -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
28
swash/processing/swash.py
Normal 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)
|
Loading…
Reference in a new issue