Author: bugman Date: Thu Mar 27 11:27:34 2014 New Revision: 22561 URL: http://svn.gna.org/viewcvs/relax?rev=22561&view=rev Log: Python 3 fixes for the info module. The new processor_name() function was not compatible with Python 3 as the text read from STDOUT needs to be 'decoded'. Modified: trunk/info.py Modified: trunk/info.py URL: http://svn.gna.org/viewcvs/relax/trunk/info.py?rev=22561&r1=22560&r2=22561&view=diff ============================================================================== --- trunk/info.py (original) +++ trunk/info.py Thu Mar 27 11:27:34 2014 @@ -38,7 +38,7 @@ Structure = object from os import environ, pathsep, waitpid import platform -from re import sub +from re import search, sub PIPE, Popen = None, None if dep_check.subprocess_module: from subprocess import PIPE, Popen @@ -559,7 +559,12 @@ # Loop over the lines, returning the first model name with the leading "model name :" text stripped. for line in data: - if "model name" in line: + # Decode Python 3 byte arrays. + if hasattr(line, 'decode'): + line = line.decode() + + # Find the processor name. + if search("model name", line): # Convert the text. name = sub(".*model name.*:", "", line, 1) name = name.strip() @@ -588,8 +593,14 @@ # Get the STDOUT data. data = pipe.stdout.readlines() + # Decode Python 3 byte arrays. + string = data[0] + if hasattr(string, 'decode'): + string = string.decode() + + # Find the processor name. # Return the string. - return data[0].strip() + return string.strip() # Nothing. except: