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