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,
40 then return a two-tuple containing the information that lsb_release emitted
43 Returns a tuple (distname,version). Distname is what LSB calls a
44 "distributor id", e.g. "Ubuntu". Version is what LSB calls a "release",
47 A version of this has been submitted to python as a patch for the standard
48 library module "platform":
50 http://bugs.python.org/issue3937
55 p = subprocess.Popen(["lsb_release", "--id"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
58 m = _distributor_id.search(p.stdout.read())
60 _distname = m.group(1).strip()
62 p = subprocess.Popen(["lsb_release", "--release"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
65 m = _release.search(p.stdout.read())
67 _version = m.group(1).strip()
68 except EnvironmentError:
71 return (_distname, _version)
74 # Our version of platform.platform(), telling us both less and more than the
75 # Python Standard Library's version does.
76 # We omit details such as the Linux kernel version number, but we add a
77 # more detailed and correct rendition of the Linux distribution and
78 # distribution-version.
79 if "linux" in platform.system().lower():
80 return platform.system()+"-"+"_".join(get_linux_distro())+"-"+platform.machine()+"-"+"_".join([x for x in platform.architecture() if x])
82 return platform.platform()
84 def get_package_versions():
85 import OpenSSL, allmydata, foolscap, nevow, platform, pycryptopp, setuptools, simplejson, twisted, zfec
88 'pyopenssl': OpenSSL.__version__,
89 'allmydata': allmydata.__version__,
90 'foolscap': foolscap.__version__,
91 'nevow': nevow.__version__,
92 'pycryptopp': pycryptopp.__version__,
93 'setuptools': setuptools.__version__,
94 'simplejson': simplejson.__version__,
95 'twisted': twisted.__version__,
96 'zfec': zfec.__version__,
97 'python': platform.python_version(),
98 'platform': get_platform()
101 def get_package_versions_string():
102 versions = get_package_versions()
104 for p in ["allmydata", "foolscap", "pycryptopp", "zfec", "twisted", "nevow", "python", "platform"]:
105 if versions.has_key(p):
106 res.append(str(p) + ": " + str(versions[p]))
109 res.append(str(p) + ": UNKNOWN")
110 for p, v in versions.iteritems():
111 res.append(str(p) + ": " + str(v))
112 return ', '.join(res)