From cb02adb11027165ef61a3b9b42f6f9eb2c42e957 Mon Sep 17 00:00:00 2001 From: david-sarah Date: Fri, 21 Jan 2011 20:02:20 -0800 Subject: [PATCH] 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 --- src/allmydata/__init__.py | 27 +++++++++++++++------------ src/allmydata/scripts/common.py | 6 ++---- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/allmydata/__init__.py b/src/allmydata/__init__.py index b0078d08..8977bac2 100644 --- a/src/allmydata/__init__.py +++ b/src/allmydata/__init__.py @@ -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 diff --git a/src/allmydata/scripts/common.py b/src/allmydata/scripts/common.py index 4fa217ca..1391cea2 100644 --- a/src/allmydata/scripts/common.py +++ b/src/allmydata/scripts/common.py @@ -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 -- 2.45.2