[reprotest] 02/04: Use distro.py to parse /etc/os-release

Ximin Luo infinity0 at debian.org
Mon Nov 6 10:30:28 UTC 2017


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch master
in repository reprotest.

commit 88f75086aec753bb588ec3f24a9fd38ec156d56b
Author: kpcyrd <git at rxv.cc>
Date:   Thu Nov 2 13:06:09 2017 +0100

    Use distro.py to parse /etc/os-release
---
 reprotest/lib/adt_testbed.py | 20 ++------------------
 setup.py                     |  1 +
 2 files changed, 3 insertions(+), 18 deletions(-)

diff --git a/reprotest/lib/adt_testbed.py b/reprotest/lib/adt_testbed.py
index 9e70e6c..937b05c 100644
--- a/reprotest/lib/adt_testbed.py
+++ b/reprotest/lib/adt_testbed.py
@@ -31,6 +31,7 @@ import signal
 import subprocess
 import tempfile
 import shutil
+import distro
 import urllib.parse
 
 # Don't need this in reprotest, try to be distro-agnostic
@@ -50,23 +51,6 @@ timeouts = {'short': 100, 'copy': 300, 'install': 3000, 'test': 10000,
             'build': 100000}
 
 
-def os_release():
-    os_release = dict()
-
-    try:
-        with open('/etc/os-release') as f:
-            for line in f:
-                try:
-                    key, value = line.strip().split('=', 1)
-                    os_release[key] = value.strip('\'\"')
-                except ValueError:
-                    pass
-    except:
-        adtlog.warning("Could not load /etc/os-release")
-
-    return os_release
-
-
 class Testbed:
     def __init__(self, vserver_argv, output_dir, user,
                  setup_commands=[], setup_commands_boot=[], add_apt_pockets=[],
@@ -107,7 +91,7 @@ class Testbed:
 
 
         if not host_distro:
-            host_distro = os_release().get('ID')
+            host_distro = distro.id()
             adtlog.info("Tried distro auto-detection, got %r" % host_distro)
 
         if host_distro in SYSTEM_INTERFACES:
diff --git a/setup.py b/setup.py
index 04974da..7ecb96b 100644
--- a/setup.py
+++ b/setup.py
@@ -22,6 +22,7 @@ setup(name='reprotest',
       install_requires=[
           'diffoscope',
           'rstr',
+          'distro',
           ],
       classifiers=[
           'Development Status :: 3 - Alpha',

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/reprotest.git



More information about the Reproducible-commits mailing list