Author: bugman Date: Sun Oct 7 19:21:06 2012 New Revision: 17724 URL: http://svn.gna.org/viewcvs/relax?rev=17724&view=rev Log: Python 3 support for Modelfree4 and Dasha. The subprocess.Popen class works with byte arrays rather than strings in Python 3+. The Python objects are now interconverted when the Python 3 encode() and decode() methods are detected. Modified: trunk/generic_fns/dasha.py trunk/generic_fns/palmer.py Modified: trunk/generic_fns/dasha.py URL: http://svn.gna.org/viewcvs/relax/trunk/generic_fns/dasha.py?rev=17724&r1=17723&r2=17724&view=diff ============================================================================== --- trunk/generic_fns/dasha.py (original) +++ trunk/generic_fns/dasha.py Sun Oct 7 19:21:06 2012 @@ -421,15 +421,32 @@ lines = script.readlines() script.close() for line in lines: + # Encode to a Python 3 byte array. + if hasattr(line, 'encode'): + line = line.encode() + + # Write out. pipe.stdin.write(line) # Close the pipe. pipe.stdin.close() - # Write to stdout and stderr. + # Write to stdout. for line in pipe.stdout.readlines(): + # Decode Python 3 byte arrays. + if hasattr(line, 'decode'): + line = line.decode() + + # Write. sys.stdout.write(line) + + # Write to stderr. for line in pipe.stderr.readlines(): + # Decode Python 3 byte arrays. + if hasattr(line, 'decode'): + line = line.decode() + + # Write. sys.stderr.write(line) # Failure. Modified: trunk/generic_fns/palmer.py URL: http://svn.gna.org/viewcvs/relax/trunk/generic_fns/palmer.py?rev=17724&r1=17723&r2=17724&view=diff ============================================================================== --- trunk/generic_fns/palmer.py (original) +++ trunk/generic_fns/palmer.py Sun Oct 7 19:21:06 2012 @@ -597,10 +597,22 @@ # Close the pipe. pipe.stdin.close() - # Write to stdout and stderr. + # Write to stdout. for line in pipe.stdout.readlines(): + # Decode Python 3 byte streams. + if hasattr(line, 'decode'): + line = line.decode() + + # Write. sys.stdout.write(line) + + # Write to stderr. for line in pipe.stderr.readlines(): + # Decode Python 3 byte streams. + if hasattr(line, 'decode'): + line = line.decode() + + # Write. sys.stderr.write(line) # Failure.