[Epydoc-commits] SF.net SVN: epydoc: [1309] trunk/epydoc/src/epydoc/cli.py
Brought to you by:
edloper
From: <ed...@us...> - 2006-08-23 15:58:14
|
Revision: 1309 Author: edloper Date: 2006-08-23 08:58:06 -0700 (Wed, 23 Aug 2006) ViewCVS: http://svn.sourceforge.net/epydoc/?rev=1309&view=rev Log Message: ----------- - Only import pstats/profile when we need them, and if the import fails, then issue an error message, rather than crashing. (pstats is not installed by default on some systems.) Modified Paths: -------------- trunk/epydoc/src/epydoc/cli.py Modified: trunk/epydoc/src/epydoc/cli.py =================================================================== --- trunk/epydoc/src/epydoc/cli.py 2006-08-23 15:47:09 UTC (rev 1308) +++ trunk/epydoc/src/epydoc/cli.py 2006-08-23 15:58:06 UTC (rev 1309) @@ -63,7 +63,7 @@ """ __docformat__ = 'epytext en' -import sys, os, time, re, pstats, pickle +import sys, os, time, re, pickle from glob import glob from optparse import OptionParser, OptionGroup import epydoc @@ -470,6 +470,9 @@ # Load profile information, if it was given. if options.pstat_files: + try: import pstats + except ImportError: + log.error("Could not import pstats -- ignoring pstat files.") try: profile_stats = pstats.Stats(options.pstat_files[0]) for filename in options.pstat_files[1:]: @@ -672,7 +675,10 @@ print >>sys.stderr, 'Use --debug to see trace information.' def _profile(): - import profile, pstats + try: import profile + except ImportError: + print >>sys.stderr, "Could not import profile module!" + return try: prof = profile.Profile() prof = prof.runctx('main(*parse_arguments())', globals(), {}) @@ -680,9 +686,13 @@ pass prof.dump_stats('profile.out') return + # Use the pstats statistical browser. This is made unnecessarily # difficult because the whole browser is wrapped in an # if __name__=='__main__' clause. + try: import pstats + except ImportError: + log.error("Could not import pstats -- skipping browser") try: pstats_pyfile = os.path.splitext(pstats.__file__)[0]+'.py' sys.argv = ['pstats.py', 'profile.out'] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |