From: Zooko O'Whielacronx Date: Tue, 23 Sep 2008 15:48:20 +0000 (-0700) Subject: setup: if invoking lsb_release doesn't work (which it doesn't on our etch buildslave... X-Git-Url: https://git.rkrishnan.org/%5B/%5D%20/uri/flags/architecture.txt?a=commitdiff_plain;h=e2b1ce13f59a08f962b952cab740d6a88e4d832d;p=tahoe-lafs%2Ftahoe-lafs.git setup: if invoking lsb_release doesn't work (which it doesn't on our etch buildslave), then fall back to the Python Standard Library's platform.dist() function --- diff --git a/src/allmydata/__init__.py b/src/allmydata/__init__.py index 45881b50..ea5efb8e 100644 --- a/src/allmydata/__init__.py +++ b/src/allmydata/__init__.py @@ -36,9 +36,11 @@ def get_linux_distro(): http://refspecs.freestandards.org/LSB_3.2.0/LSB-Core-generic/LSB-Core-generic/lsbrelease.html - If executing "lsb_release" raises no exception, and returns exit code 0, - then return a two-tuple containing the information that lsb_release emitted - as strings. + If executing "lsb_release" raises no exception, and returns exit code 0, and + both the "distributor id" and "release" results are non-empty after being + stripped of whitespace, then return a two-tuple containing the information + that lsb_release emitted, as strings. Else, invoke platform.dist() and + return the first two elements of the tuple returned by that function. Returns a tuple (distname,version). Distname is what LSB calls a "distributor id", e.g. "Ubuntu". Version is what LSB calls a "release", @@ -68,7 +70,10 @@ def get_linux_distro(): except EnvironmentError: pass - return (_distname, _version) + if _distname and _version: + return (_distname, _version) + else: + return platform.dist()[:2] def get_platform(): # Our version of platform.platform(), telling us both less and more than the