Author: bugman Date: Sun Oct 12 00:51:36 2008 New Revision: 7628 URL: http://svn.gna.org/viewcvs/relax?rev=7628&view=rev Log: Switched from os.spawnlp to os.popen3 for proper IO redirection. This allows the system tests to capture Modelfree4's STDOUT and STDERR streams, as they are fused into relax's. Modified: 1.3/generic_fns/palmer.py Modified: 1.3/generic_fns/palmer.py URL: http://svn.gna.org/viewcvs/relax/1.3/generic_fns/palmer.py?rev=7628&r1=7627&r2=7628&view=diff ============================================================================== --- 1.3/generic_fns/palmer.py (original) +++ 1.3/generic_fns/palmer.py Sun Oct 12 00:51:36 2008 @@ -26,15 +26,10 @@ # Python module imports. from math import pi -from os import F_OK, P_WAIT, access, chdir, chmod, getcwd, listdir, remove, system +from os import F_OK, access, chdir, chmod, getcwd, listdir, popen3, remove, system from re import match, search from string import count, find, split - -# UNIX only functions from the os module (Modelfree4 only runs under UNIX anyway). -try: - from os import spawnlp -except ImportError: - pass +import sys # relax module imports. from generic_fns.mol_res_spin import exists_mol_res_spin_data, spin_loop @@ -567,18 +562,21 @@ # Test the binary file string corresponds to a valid executable. test_binary(binary) - # Execute Modelfree4 (inputting a PDB file). + # Execute Modelfree4. if pdb: - status = spawnlp(P_WAIT, binary, binary, '-i', 'mfin', '-d', 'mfdata', '-p', 'mfpar', '-m', 'mfmodel', '-o', 'mfout', '-e', 'out', '-s', pdb) - if status: - raise RelaxProgFailError, 'Modelfree4' - - - # Execute Modelfree4 (without a PDB file). + cmd = binary + ' -i mfin -d mfdata -p mfpar -m mfmodel -o mfout -e out -s ' + pdb else: - status = spawnlp(P_WAIT, binary, binary, '-i', 'mfin', '-d', 'mfdata', '-p', 'mfpar', '-m', 'mfmodel', '-o', 'mfout', '-e', 'out') - if status: - raise RelaxProgFailError, 'Modelfree4' + cmd = binary + ' -i mfin -d mfdata -p mfpar -m mfmodel -o mfout -e out' + stdin, stdout, stderr = popen3(cmd) + + # Close the pipe. + stdin.close() + + # Write to stdout and stderr. + for line in stdout.readlines(): + sys.stdout.write(line) + for line in stderr.readlines(): + sys.stderr.write(line) # Failure. except: