Author: bugman Date: Mon Feb 22 19:59:57 2010 New Revision: 10829 URL: http://svn.gna.org/viewcvs/relax?rev=10829&view=rev Log: The Info_box.package_info() has been added to provide package information. This is show with the -i cmdline option. The following packages are currently reported: minfx bmrblib numpy Numeric ScientificPython wxPython mpi4py scons epydoc Modified: 1.3/info.py Modified: 1.3/info.py URL: http://svn.gna.org/viewcvs/relax/1.3/info.py?rev=10829&r1=10828&r2=10829&view=diff ============================================================================== --- 1.3/info.py (original) +++ 1.3/info.py Mon Feb 22 19:59:57 2010 @@ -26,6 +26,7 @@ # relax module imports. import dep_check import numpy +from pkg_resources import Requirement, working_set import platform from textwrap import wrap from version import version @@ -162,6 +163,50 @@ # Return the formatted text. return intro_string + + + def package_info(self, format=" %-25s%s\n"): + """Return a string for printing to STDOUT with info from the Python packages used by relax. + + @return: The info string. + @rtype: str + """ + + # Init. + text = '' + + # Header. + text = text + ("\nPython packages (most of these are optional for relax):\n") + + # Loop over all packages. + packages = ['minfx', 'bmrblib', 'numpy', 'Numeric', 'ScientificPython', 'wxPython', 'mpi4py', 'scons', 'epydoc'] + for package in packages: + # Get the package info. + pkg_info = working_set.find(Requirement.parse(package)) + + # The package name. + text = text + (format % ("Name: ", pkg_info.project_name)) + + # Not installed. + if pkg_info == None: + text = text + (format % ("Installed: ", False)) + text = text + "\n" + continue + + # Installed + else: + text = text + (format % ("Installed: ", True)) + + # The text. + text = text + (format % ("Version: ", pkg_info.version)) + text = text + (format % ("Location: ", pkg_info.location)) + text = text + (format % ("Egg name: ", pkg_info.egg_name())) + + # End. + text = text + "\n" + + # Return the info string. + return text def sys_info(self): @@ -208,6 +253,9 @@ 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())) + + # Python packages. + text = text + self.package_info(format=format) # End with an empty newline. text = text + ("\n")