Don't put debugging information in 'My versions' section of the Welcome page. Also remove the extra blank line between version and command output when --version[-and-path] is used. refs #1306

This commit is contained in:
david-sarah 2011-01-21 20:02:20 -08:00
parent 3eadc8a053
commit cb02adb110
2 changed files with 17 additions and 16 deletions

View File

@ -300,17 +300,20 @@ def cross_check_pkg_resources_versus_import():
return errors
def get_error_string(errors):
def get_error_string(errors, debug=False):
from allmydata._auto_deps import install_requires
return ("\n%s\n\n"
"For debugging purposes, the PYTHONPATH was\n"
" %r\n"
"install_requires was\n"
" %r\n"
"sys.path after importing pkg_resources was\n"
" %s\n"
% ("\n".join(errors), os.environ.get('PYTHONPATH'), install_requires, (os.pathsep+"\n ").join(sys.path)) )
msg = "\n%s\n" % ("\n".join(errors),)
if debug:
msg += ("\n"
"For debugging purposes, the PYTHONPATH was\n"
" %r\n"
"install_requires was\n"
" %r\n"
"sys.path after importing pkg_resources was\n"
" %s\n"
% (os.environ.get('PYTHONPATH'), install_requires, (os.pathsep+"\n ").join(sys.path)) )
return msg
def check_all_requirements():
"""This function returns a list of errors due to any failed checks."""
@ -346,7 +349,7 @@ def check_all_requirements():
errors.append("%s: %s" % (e.__class__.__name__, e))
if errors:
raise PackagingError(get_error_string(errors))
raise PackagingError(get_error_string(errors, debug=True))
check_all_requirements()
@ -357,7 +360,7 @@ def get_package_versions():
def get_package_locations():
return dict([(k, l) for k, (v, l) in _vers_and_locs_list])
def get_package_versions_string(show_paths=False):
def get_package_versions_string(show_paths=False, debug=False):
res = []
for p, (v, loc) in _vers_and_locs_list:
info = str(p) + ": " + str(v)
@ -370,6 +373,6 @@ def get_package_versions_string(show_paths=False):
if not hasattr(sys, 'frozen'):
errors = cross_check_pkg_resources_versus_import()
if errors:
output += get_error_string(errors)
output += get_error_string(errors, debug=debug)
return output

View File

@ -42,14 +42,12 @@ class BaseOptions(usage.Options):
def opt_version(self):
import allmydata
print >>self.stdout, allmydata.get_package_versions_string()
print >>self.stdout
print >>self.stdout, allmydata.get_package_versions_string(debug=True)
self.no_command_needed = True
def opt_version_and_path(self):
import allmydata
print >>self.stdout, allmydata.get_package_versions_string(show_paths=True)
print >>self.stdout
print >>self.stdout, allmydata.get_package_versions_string(show_paths=True, debug=True)
self.no_command_needed = True