Isolate anatric subprocesses

This commit is contained in:
usov_i 2021-05-10 17:06:20 +02:00
parent 67853b8db4
commit 00ff4117ea
2 changed files with 8 additions and 6 deletions

View File

@ -23,12 +23,13 @@ REFLECTION_PRINTER_FORMATS = [
ALGORITHMS = ["adaptivemaxcog", "adaptivedynamic"]
def anatric(config_file, anatric_path="/afs/psi.ch/project/sinq/rhel7/bin/anatric"):
def anatric(config_file, anatric_path="/afs/psi.ch/project/sinq/rhel7/bin/anatric", cwd=None):
comp_proc = subprocess.run(
[anatric_path, config_file],
check=True,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
cwd=cwd,
check=True,
text=True,
)
print(" ".join(comp_proc.args))

View File

@ -1,5 +1,6 @@
import base64
import io
import os
import re
import tempfile
@ -347,14 +348,14 @@ def create():
temp_file = temp_dir + "/config.xml"
config.save_as(temp_file)
if doc.anatric_path:
pyzebra.anatric(temp_file, anatric_path=doc.anatric_path)
pyzebra.anatric(temp_file, anatric_path=doc.anatric_path, cwd=temp_dir)
else:
pyzebra.anatric(temp_file)
pyzebra.anatric(temp_file, cwd=temp_dir)
with open(config.logfile) as f_log:
with open(os.path.join(temp_dir, config.logfile)) as f_log:
output_log.value = f_log.read()
with open(config.reflectionPrinter_file) as f_res:
with open(os.path.join(temp_dir, config.reflectionPrinter_file)) as f_res:
output_res.value = f_res.read()
process_button = Button(label="Process", button_type="primary")