]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
add option to show version and path to the tahoe executable
authorcgalvan <cgalvan@mail.utexas.edu>
Fri, 16 Jan 2009 19:47:51 +0000 (12:47 -0700)
committercgalvan <cgalvan@mail.utexas.edu>
Fri, 16 Jan 2009 19:47:51 +0000 (12:47 -0700)
src/allmydata/__init__.py
src/allmydata/scripts/common.py

index a3f80fd81df826db5215afe54ca7530db79d4272..290da2078acead3a0d6038188f7911e0e3bfa58d 100644 (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)
index a6d0a1099fdec7f37779f221802c4cdb3e45254c..325f646300827abc36872d4b97b0cb3e0b0e5e02 100644 (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 = [