add option to show version and path to the tahoe executable

This commit is contained in:
cgalvan 2009-01-16 12:47:51 -07:00
parent 7fc784fc55
commit 7bfaa74ef1
2 changed files with 34 additions and 3 deletions

View File

@ -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)

View File

@ -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 = [