From 5fd0f7b40830f236b07519818bc525b9d530d9d8 Mon Sep 17 00:00:00 2001 From: Steve Langasek Date: Tue, 21 Feb 2012 16:49:04 +0100 Subject: [PATCH] Don't run apt-cache if /etc/lsb-release exists. Since /etc/lsb-release overrides detected information, there's no need to try and detect that information if lsb-release contains everything we need. This saves us calling the hugely expensive apt-cache. --- lsb_release.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lsb_release.py b/lsb_release.py index 5c6cb9a..9208858 100644 --- a/lsb_release.py +++ b/lsb_release.py @@ -284,9 +284,15 @@ def get_lsb_information(): return distinfo def get_distro_information(): - distinfo = guess_debian_release() - distinfo.update(get_lsb_information()) - return distinfo + lsbinfo = get_lsb_information() + # OS is only used inside guess_debian_release anyway + for key in ('ID', 'RELEASE', 'CODENAME', 'DESCRIPTION',): + if key not in lsbinfo: + distinfo = guess_debian_release() + distinfo.update(lsbinfo) + return distinfo + else: + return lsbinfo def test(): print get_distro_information() -- 2.30.2