From: david-sarah Date: Sat, 22 Jan 2011 04:02:20 +0000 (-0800) Subject: Don't put debugging information in 'My versions' section of the Welcome page. Also... X-Git-Tag: allmydata-tahoe-1.8.2b1~6 X-Git-Url: https://git.rkrishnan.org/pf/content/en/seg/priv.html?a=commitdiff_plain;h=cb02adb11027165ef61a3b9b42f6f9eb2c42e957;p=tahoe-lafs%2Ftahoe-lafs.git 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 --- 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