From e2b1ce13f59a08f962b952cab740d6a88e4d832d Mon Sep 17 00:00:00 2001 From: Zooko O'Whielacronx Date: Tue, 23 Sep 2008 08:48:20 -0700 Subject: [PATCH] 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 --- src/allmydata/__init__.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) 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 -- 2.45.2