From: cgalvan Date: Fri, 16 Jan 2009 19:47:51 +0000 (-0700) Subject: add option to show version and path to the tahoe executable X-Git-Tag: allmydata-tahoe-1.3.0~187 X-Git-Url: https://git.rkrishnan.org/%5B/frontends//%22news.html/%22?a=commitdiff_plain;h=7bfaa74ef17cadc2c1402543cf3f2f595caf8f78;p=tahoe-lafs%2Ftahoe-lafs.git add option to show version and path to the tahoe executable --- diff --git a/src/allmydata/__init__.py b/src/allmydata/__init__.py index a3f80fd8..290da207 100644 --- a/src/allmydata/__init__.py +++ b/src/allmydata/__init__.py @@ -137,15 +137,40 @@ def get_package_versions(): 'platform': get_platform() } -def get_package_versions_string(): +def get_package_locations(): + import OpenSSL, allmydata, foolscap, nevow, platform, pycryptopp, setuptools, simplejson, twisted, zfec + + return { + 'pyopenssl': os.path.dirname(OpenSSL.__file__), + 'allmydata': os.path.dirname(allmydata.__file__), + 'foolscap': os.path.dirname(foolscap.__file__), + 'nevow': os.path.dirname(nevow.__file__), + 'pycryptopp': os.path.dirname(pycryptopp.__file__), + 'setuptools': os.path.dirname(setuptools.__file__), + 'simplejson': os.path.dirname(simplejson.__file__), + 'twisted': os.path.dirname(twisted.__file__), + 'zfec': os.path.dirname(zfec.__file__), + 'python': platform.python_version(), + 'platform': get_platform() + } + +def get_package_versions_string(show_paths=False): versions = get_package_versions() + paths = None + if show_paths: + paths = get_package_locations() + res = [] for p in ["allmydata", "foolscap", "pycryptopp", "zfec", "twisted", "nevow", "python", "platform"]: if versions.has_key(p): - res.append(str(p) + ": " + str(versions[p])) + info = str(p) + ": " + str(versions[p]) del versions[p] else: - res.append(str(p) + ": UNKNOWN") + info = str(p) + ": UNKNOWN" + if show_paths: + info = info + " (%s)" % str(paths[p]) + res.append(info) + for p, v in versions.iteritems(): res.append(str(p) + ": " + str(v)) return ', '.join(res) diff --git a/src/allmydata/scripts/common.py b/src/allmydata/scripts/common.py index a6d0a109..325f6463 100644 --- a/src/allmydata/scripts/common.py +++ b/src/allmydata/scripts/common.py @@ -12,6 +12,7 @@ class BaseOptions: optFlags = [ ["quiet", "q", "Operate silently."], ["version", "V", "Display version numbers and exit."], + ["version-and-path", "v", "Display version numbers and paths to their locations and exit."], ] def opt_version(self): @@ -19,6 +20,11 @@ class BaseOptions: print allmydata.get_package_versions_string() sys.exit(0) + def opt_version_and_path(self): + import allmydata + print allmydata.get_package_versions_string(show_paths=True) + sys.exit(0) + class BasedirMixin: optFlags = [