This repository has been archived on 2022-02-01. You can view files and clone it, but cannot push or open issues or pull requests.
openfoam_project/openfoam/run/run.py

19 lines
415 B
Python
Raw Normal View History

2022-01-26 18:08:17 +01:00
import subprocess as sp
import logging
2022-01-26 18:26:29 +01:00
def run(command, case, alias=None):
if alias == None: alias = command
log = logging.getLogger(alias)
2022-01-26 18:08:17 +01:00
proc = sp.Popen(
2022-01-26 18:26:29 +01:00
command,
cwd=case,
2022-01-26 18:08:17 +01:00
stdout=sp.PIPE,
stderr=sp.PIPE,
text=True,
)
for line in proc.stdout:
2022-01-26 18:26:29 +01:00
log.info(line[:-1])
2022-01-26 18:08:17 +01:00
for line in proc.stderr:
2022-01-26 18:26:29 +01:00
log.info(line[:-1])
return proc.wait()