Control: tags -1 patch Daniel,
Thanks for this and sorry for the slowness. I am working on an update for lsb_release and have picked this up. My proposed fix is attached. As far as I can see it is safe to continue if apt-cache is not available and lsb_release will try other options. Any comments? Thanks Mark
>From 3e32d1e9697dac52a77296bcc4f3d3129c8f153e Mon Sep 17 00:00:00 2001 From: Mark Hindley <m...@hindley.org.uk> Date: Fri, 6 May 2022 08:13:25 +0100 Subject: [PATCH] Catch exceptions from running apt-cache and warn but continue. Closes: #951651 --- lsb_release.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lsb_release.py b/lsb_release.py index 5ef13ce..38d00c5 100644 --- a/lsb_release.py +++ b/lsb_release.py @@ -168,11 +168,16 @@ def parse_apt_policy(): data = [] C_env = os.environ.copy(); C_env['LC_ALL'] = 'C.UTF-8' - policy = subprocess.Popen(['apt-cache','policy'], - env=C_env, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - close_fds=True).communicate()[0].decode('utf-8') + try: + policy = subprocess.Popen(['apt-cache','policy'], + env=C_env, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + close_fds=True).communicate()[0].decode('utf-8') + except Exception as e: + print('Failed to run apt-cache:', e, file=sys.stderr) + return + for line in policy.split('\n'): line = line.strip() m = re.match(r'(-?\d+)', line) -- 2.35.1