Coverage for /builds/kinetik161/ase/ase/calculators/turbomole/executor.py: 100.00%
14 statements
« prev ^ index » next coverage.py v7.2.7, created at 2023-12-10 11:04 +0000
« prev ^ index » next coverage.py v7.2.7, created at 2023-12-10 11:04 +0000
1"""
2Execution of turbomole binaries and scripts:
3define, dscf, grad, ridft, rdgrad, aoforce, jobex, NumForce
4"""
5import os
6from subprocess import PIPE, Popen
9def get_output_filename(basename):
10 """return the output file name from the basename of the executable"""
11 return 'ASE.TM.' + basename + '.out'
14def check_bad_output(stderr):
15 """check status written in stderr by turbomole executables"""
16 if 'abnormally' in stderr or 'ended normally' not in stderr:
17 raise OSError(f'Turbomole error: {stderr}')
20def execute(args, input_str=''):
21 """executes a turbomole executable and process the outputs"""
23 stdout_file = get_output_filename(os.path.basename(args[0]))
24 with open(stdout_file, 'w') as stdout:
25 proc = Popen(args, stdin=PIPE, stderr=PIPE, stdout=stdout,
26 encoding='ASCII')
27 stdout_txt, stderr_txt = proc.communicate(input=input_str)
28 check_bad_output(stderr_txt)
29 return stdout_file