From d92f7641fee0d9132fb303054abe58aee978f58a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Sun, 7 Oct 2018 08:38:48 +0200 Subject: [PATCH] versions middleware: don't fail on corrupted apt cache (#27056) --- hobo/scrutiny/wsgi/middleware.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hobo/scrutiny/wsgi/middleware.py b/hobo/scrutiny/wsgi/middleware.py index c3c38e9..213b682 100644 --- a/hobo/scrutiny/wsgi/middleware.py +++ b/hobo/scrutiny/wsgi/middleware.py @@ -75,10 +75,15 @@ class VersionMiddleware(object): if project_name in cls.ENTROUVERT_PACKAGES: packages_version[project_name] = version # get versions from Debian packages + debian_cache = None if apt_cache: - cache = apt_cache.Cache() + try: + debian_cache = apt_cache.Cache() + except SystemError: + pass + if debian_cache: versions = [(p.name, p.installed.source_name, p.installed.version) \ - for p in cache if p.installed and ( + for p in debian_cache if p.installed and ( (p.installed and p.installed.origins[0].origin == "Entr'ouvert") or (p.candidate and p.candidate.origins[0].origin == "Entr'ouvert"))] for name, project_name, version in versions: -- 2.19.1