BIND 10 trac2062, updated. 5c6c47046be1da96c581693c500461dff5ba9304 [2062] Add OS distribution name

BIND 10 source code commits bind10-changes at lists.isc.org
Thu Jun 28 07:03:03 UTC 2012


The branch, trac2062 has been updated
       via  5c6c47046be1da96c581693c500461dff5ba9304 (commit)
      from  b2a7049b19584687962588cd5695748541ddfc32 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 5c6c47046be1da96c581693c500461dff5ba9304
Author: Mukund Sivaraman <muks at isc.org>
Date:   Thu Jun 28 12:32:43 2012 +0530

    [2062] Add OS distribution name

-----------------------------------------------------------------------

Summary of changes:
 src/bin/showtech/showtech.py.in       |    1 +
 src/lib/python/isc/sysinfo/sysinfo.py |   41 +++++++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+)

-----------------------------------------------------------------------
diff --git a/src/bin/showtech/showtech.py.in b/src/bin/showtech/showtech.py.in
index abcebfe..599c695 100755
--- a/src/bin/showtech/showtech.py.in
+++ b/src/bin/showtech/showtech.py.in
@@ -35,6 +35,7 @@ def main():
 
     print('\nPlatform');
     print(' + Operating system: ' + s.get_platform_name())
+    print(' + Distribution: ' + s.get_platform_distro())
     print(' + Kernel version: ' + s.get_platform_version())
     if s.get_platform_is_smp():
         print(' + SMP kernel: yes')
diff --git a/src/lib/python/isc/sysinfo/sysinfo.py b/src/lib/python/isc/sysinfo/sysinfo.py
index f718e48..5506974 100644
--- a/src/lib/python/isc/sysinfo/sysinfo.py
+++ b/src/lib/python/isc/sysinfo/sysinfo.py
@@ -18,6 +18,8 @@
 import os
 import sys
 import re
+import subprocess
+import os.path
 
 class SysInfo:
     def __init__(self):
@@ -71,6 +73,42 @@ class SysInfo:
                     self._mem_swap_free = int(r.group(1).strip()) * 1024
                     continue
 
+        self._platform_distro = None
+
+        try:
+            s = subprocess.check_output(['lsb_release', '-a'])
+            for line in s.decode('utf-8').split('\n'):
+                r = re.match('^Description:(.*)', line)
+                if r:
+                    self._platform_distro = r.group(1).strip()
+                    break
+        except (subprocess.CalledProcessError, OSError):
+            pass
+
+        if self._platform_distro is None:
+            files = ['/etc/debian_release',
+                     '/etc/debian_version',
+                     '/etc/SuSE-release',
+                     '/etc/UnitedLinux-release',
+                     '/etc/mandrake-release',
+                     '/etc/gentoo-release',
+                     '/etc/fedora-release',
+                     '/etc/redhat-release',
+                     '/etc/redhat_version',
+                     '/etc/slackware-release',
+                     '/etc/slackware-version',
+                     '/etc/arch-release',
+                     '/etc/lsb-release',
+                     '/etc/mageia-release']
+            for fn in files:
+                if os.path.exists(fn):
+                    with open(fn) as f:
+                        self._platform_distro = f.read().strip()
+                    break
+
+        if self._platform_distro is None:
+            self._platform_distro = 'Unknown'
+
     def get_num_processors(self):
         # This is the number of hyperthreads when hyper-threading is
         # used. This is not entirely portable, so we'll have to handle
@@ -95,6 +133,9 @@ class SysInfo:
     def get_platform_is_smp(self):
         return self._platform_is_smp
 
+    def get_platform_distro(self):
+        return self._platform_distro
+
     def get_uptime(self):
         return self._uptime
 



More information about the bind10-changes mailing list