2 Decentralized storage grid.
4 maintainer web site: U{http://allmydata.com/}
6 community web site: U{http://allmydata.org/}
9 __version__ = "unknown"
11 from _version import __version__
13 # We're running in a tree that hasn't run "./setup.py darcsver", and didn't
14 # come with a _version.py, so we don't know what our version is. This should
15 # not happen very often.
18 hush_pyflakes = __version__
22 _auto_deps.require_auto_deps()
24 import platform, re, subprocess
25 _distributor_id = re.compile("(?:Distributor ID)?:?\s*(.*)", re.I)
26 _release = re.compile("(?:Release)?:?\s*(.*)", re.I)
28 def get_linux_distro():
29 """ Tries to determine the name of the Linux OS distribution name.
31 The function tries to execute "lsb_release", as standardized in 2001:
33 http://refspecs.freestandards.org/LSB_1.0.0/gLSB/lsbrelease.html
35 The current version of the standard is here:
37 http://refspecs.freestandards.org/LSB_3.2.0/LSB-Core-generic/LSB-Core-generic/lsbrelease.html
39 If executing "lsb_release" raises no exception, and returns exit code 0, and
40 both the "distributor id" and "release" results are non-empty after being
41 stripped of whitespace, then return a two-tuple containing the information
42 that lsb_release emitted, as strings. Else, invoke platform.dist() and
43 return the first two elements of the tuple returned by that function.
45 Returns a tuple (distname,version). Distname is what LSB calls a
46 "distributor id", e.g. "Ubuntu". Version is what LSB calls a "release",
49 A version of this has been submitted to python as a patch for the standard
50 library module "platform":
52 http://bugs.python.org/issue3937
57 p = subprocess.Popen(["lsb_release", "--id"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
60 m = _distributor_id.search(p.stdout.read())
62 _distname = m.group(1).strip()
64 p = subprocess.Popen(["lsb_release", "--release"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
67 m = _release.search(p.stdout.read())
69 _version = m.group(1).strip()
70 except EnvironmentError:
73 if _distname and _version:
74 return (_distname, _version)
76 return platform.dist()[:2]
79 # Our version of platform.platform(), telling us both less and more than the
80 # Python Standard Library's version does.
81 # We omit details such as the Linux kernel version number, but we add a
82 # more detailed and correct rendition of the Linux distribution and
83 # distribution-version.
84 if "linux" in platform.system().lower():
85 return platform.system()+"-"+"_".join(get_linux_distro())+"-"+platform.machine()+"-"+"_".join([x for x in platform.architecture() if x])
87 return platform.platform()
89 def get_package_versions():
90 import OpenSSL, allmydata, foolscap, nevow, platform, pycryptopp, setuptools, simplejson, twisted, zfec
93 'pyopenssl': OpenSSL.__version__,
94 'allmydata': allmydata.__version__,
95 'foolscap': foolscap.__version__,
96 'nevow': nevow.__version__,
97 'pycryptopp': pycryptopp.__version__,
98 'setuptools': setuptools.__version__,
99 'simplejson': simplejson.__version__,
100 'twisted': twisted.__version__,
101 'zfec': zfec.__version__,
102 'python': platform.python_version(),
103 'platform': get_platform()
106 def get_package_versions_string():
107 versions = get_package_versions()
109 for p in ["allmydata", "foolscap", "pycryptopp", "zfec", "twisted", "nevow", "python", "platform"]:
110 if versions.has_key(p):
111 res.append(str(p) + ": " + str(versions[p]))
114 res.append(str(p) + ": UNKNOWN")
115 for p, v in versions.iteritems():
116 res.append(str(p) + ": " + str(v))
117 return ', '.join(res)