Author: bugman Date: Mon Feb 22 18:17:12 2010 New Revision: 10827 URL: http://svn.gna.org/viewcvs/relax?rev=10827&view=rev Log: Renamed Info_box.print_sys_info() to Info_box.sys_info(). The method now returns the info string, and this is printed later. Modified: 1.3/info.py 1.3/relax Modified: 1.3/info.py URL: http://svn.gna.org/viewcvs/relax/1.3/info.py?rev=10827&r1=10826&r2=10827&view=diff ============================================================================== --- 1.3/info.py (original) +++ 1.3/info.py Mon Feb 22 18:17:12 2010 @@ -164,50 +164,60 @@ return intro_string - def print_sys_info(self): - """Print some info about the current relax instance.""" + def sys_info(self): + """Return a string for printing to STDOUT with info about the current relax instance. + + @return: The info string. + @rtype: str + """ + + # Init. + text = '' # Formatting string. - format = " %-25s%s" + format = " %-25s%s\n" # The relax version. - print("\nrelax information:") - print(format % ("relax version: ", version)) + text = text + ("\nrelax information:\n") + text = text + (format % ("relax version: ", version)) # Hardware info. - print("\nHardware information:") - print(format % ("Machine: ", platform.machine())) - print(format % ("Processor: ", platform.processor())) + text = text + ("\nHardware information:\n") + text = text + (format % ("Machine: ", platform.machine())) + text = text + (format % ("Processor: ", platform.processor())) # System info. - print("\nSystem information:") - print(format % ("System: ", platform.system())) - print(format % ("Release: ", platform.release())) - print(format % ("Version: ", platform.version())) + text = text + ("\nSystem information:\n") + text = text + (format % ("System: ", platform.system())) + text = text + (format % ("Release: ", platform.release())) + text = text + (format % ("Version: ", platform.version())) if platform.win32_ver()[0]: - print(format % ("Win32 version: ", (platform.win32_ver()[0] + " " + platform.win32_ver()[1] + " " + platform.win32_ver()[2] + " " + platform.win32_ver()[3]))) + text = text + (format % ("Win32 version: ", (platform.win32_ver()[0] + " " + platform.win32_ver()[1] + " " + platform.win32_ver()[2] + " " + platform.win32_ver()[3]))) if platform.linux_distribution()[0]: - print(format % ("GNU/Linux version: ", (platform.linux_distribution()[0] + " " + platform.linux_distribution()[1] + " " + platform.linux_distribution()[2]))) + text = text + (format % ("GNU/Linux version: ", (platform.linux_distribution()[0] + " " + platform.linux_distribution()[1] + " " + platform.linux_distribution()[2]))) if platform.mac_ver()[0]: - print(format % ("Mac version: ", (platform.mac_ver()[0] + " (" + platform.mac_ver()[1][0] + ", " + platform.mac_ver()[1][1] + ", " + platform.mac_ver()[1][2] + ") " + platform.mac_ver()[2]))) - print(format % ("Distribution: ", (platform.dist()[0] + " " + platform.dist()[1] + " " + platform.dist()[2]))) - print(format % ("Full platform string: ", (platform.platform()))) + text = text + (format % ("Mac version: ", (platform.mac_ver()[0] + " (" + platform.mac_ver()[1][0] + ", " + platform.mac_ver()[1][1] + ", " + platform.mac_ver()[1][2] + ") " + platform.mac_ver()[2]))) + text = text + (format % ("Distribution: ", (platform.dist()[0] + " " + platform.dist()[1] + " " + platform.dist()[2]))) + text = text + (format % ("Full platform string: ", (platform.platform()))) # Software info. - print("\nSoftware information:") - print(format % ("Architecture: ", (platform.architecture()[0] + " " + platform.architecture()[1]))) - print(format % ("Python version: ", platform.python_version())) - print(format % ("Python branch: ", platform.python_branch())) - print((format+', %s') % ("Python build: ", platform.python_build()[0], platform.python_build()[1])) - print(format % ("Python compiler: ", platform.python_compiler())) - print(format % ("Python implementation: ", platform.python_implementation())) - print(format % ("Python revision: ", platform.python_revision())) - print(format % ("Numpy version: ", numpy.__version__)) - print(format % ("Libc version: ", (platform.libc_ver()[0] + " " + platform.libc_ver()[1]))) - print(format % ("Network name: ", platform.node())) + text = text + ("\nSoftware information:\n") + text = text + (format % ("Architecture: ", (platform.architecture()[0] + " " + platform.architecture()[1]))) + text = text + (format % ("Python version: ", platform.python_version())) + text = text + (format % ("Python branch: ", platform.python_branch())) + text = text + ((format[:-1]+', %s\n') % ("Python build: ", platform.python_build()[0], platform.python_build()[1])) + text = text + (format % ("Python compiler: ", platform.python_compiler())) + text = text + (format % ("Python implementation: ", platform.python_implementation())) + text = text + (format % ("Python revision: ", platform.python_revision())) + text = text + (format % ("Numpy version: ", numpy.__version__)) + text = text + (format % ("Libc version: ", (platform.libc_ver()[0] + " " + platform.libc_ver()[1]))) + text = text + (format % ("Network name: ", platform.node())) # End with an empty newline. - print("") + text = text + ("\n") + + # Return the text. + return text Modified: 1.3/relax URL: http://svn.gna.org/viewcvs/relax/1.3/relax?rev=10827&r1=10826&r2=10827&view=diff ============================================================================== --- 1.3/relax (original) +++ 1.3/relax Mon Feb 22 18:17:12 2010 @@ -105,7 +105,7 @@ # Show the relax info and exit. if mode == 'info': info = Info_box() - info.print_sys_info() + print(info.sys_info()) sys.exit() # Logging.