Bug#923071: command-not-found issues a warning when /etc/apt/sources.list does not exist

2019-10-18 Thread Nicolas Braud-Santoni
Control: reassign -1 python-apt
Control: retitle -1 python-apt issues a warning when /etc/apt/sources.list does 
not exist
Control: tag -1 + patch

On Sat, Feb 23, 2019 at 08:38:45PM +0100, Nicolas Braud-Santoni wrote:
> On my system, /etc/apt/sources.list does not exist (I exclusively use
> sources.list.d), causing command-not-found to issue a warning on every run:
> 
> > $ command-not-found cowsay
> > WARNING:root:could not open file '/etc/apt/sources.list'
> > 
> > Command 'cowsay' is available in '/usr/games/cowsay'
> > cowsay: command not found

Dear maintainers,

I finally took the time to investigate this issue, and discovered it was caused
by python-apt unconditionally trying to open /etc/apt/sources.list.

Please find attached a patch, also sent as a MR on Salsa:

  https://salsa.debian.org/apt-team/python-apt/merge_requests/18


Best,

  nicoo
From faa7243a3e4d358f291bdfa869d0410ebd11cdd0 Mon Sep 17 00:00:00 2001
From: Nicolas Braud-Santoni 
Date: Fri, 18 Oct 2019 19:34:14 +0200
Subject: [PATCH] aptsources.sourceslist.SourcesList.load: Ignore
 FileNotFoundError

Closes: 923071
---
 aptsources/sourceslist.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/aptsources/sourceslist.py b/aptsources/sourceslist.py
index 22649984..76c73f5d 100644
--- a/aptsources/sourceslist.py
+++ b/aptsources/sourceslist.py
@@ -389,6 +389,8 @@ class SourcesList(object):
 for line in f:
 source = SourceEntry(line, file)
 self.list.append(source)
+except FileNotFoundError:
+pass
 except Exception:
 logging.warning("could not open file '%s'\n" % file)
 
-- 
2.23.0



signature.asc
Description: PGP signature


Bug#923071: command-not-found issues a warning when /etc/apt/sources.list does not exist

2019-02-23 Thread Nicolas Braud-Santoni
Package: command-not-found
Version: 18.04.5-1
Severity: normal

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA512

Hi,

On my system, /etc/apt/sources.list does not exist (I exclusively use
sources.list.d), causing command-not-found to issue a warning on every run:

> $ command-not-found cowsay
> WARNING:root:could not open file '/etc/apt/sources.list'
> 
> Command 'cowsay' is available in '/usr/games/cowsay'
> cowsay: command not found


Maybe command-not-found should only issue a warning when failing to read
a file due to permissions issues?


Best,

  nicoo

- -- System Information:
Debian Release: buster/sid
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 4.19.0-2-amd64 (SMP w/4 CPU cores)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_OOT_MODULE, 
TAINT_UNSIGNED_MODULE
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) (ignored: LC_ALL 
set to en_US.UTF-8), LANGUAGE=en_US.UTF-8 (charmap=UTF-8) (ignored: LC_ALL set 
to en_US.UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages command-not-found depends on:
ii  apt-file 3.2.2
ii  lsb-release  10.2018112800
ii  python3  3.7.2-1
ii  python3-apt  1.8.3

command-not-found recommends no packages.

Versions of packages command-not-found suggests:
pn  snapd  

- -- no debconf information

-BEGIN PGP SIGNATURE-

iQJFBAEBCgAvFiEEU7EqA8ZVHYoLJhPE5vmO4pLV7MsFAlxxoUIRHG5pY29vQGRl
Ymlhbi5vcmcACgkQ5vmO4pLV7MunWQ/+MCdOlUcAgGm1smTWZGwpMqC/aVfWjaZQ
/ic6Vji3I1rCC/V6y9F14QoxG8TT25J3Y8VMAKrq/JFBsKORUToeVcyL8iMch9rU
xP/t1U6K/Cft+sxP1hEFB42ttclUIqSebGazp+WXzSfM/vgjoSRWbexD4+++Nmxr
YyvPC4cNFiclxkddcovyB4UiE/2/2AjL2dIDegN4ALvs0PimM36cfUnTANYwS0gb
seLNQhdP9TJS+vYmhU+YbcHDA3GG9Hm6nDHZ8E+/lGVWpHMvk9z07qDwH7rPnfwL
AlChhGDDjEkciP3b5EB5M24rweX6snvj7dvVkyiyaigK8NDMCx5706/IUVlGRxid
GNdCu64NSLvX6yCl0TiEcDXx6SHYt9U9uk/UYhwFcpfJz91Fb0edBX7FFzLlZ9S6
zIy06xRaMrUrVSTOHc8peZMsae+JoDOcH5J7D6E4Y+TC046hkGln8z5ZbYZjTRBY
Mdc7SiekV+bN81pqsASx+3AtKllz4eV1Q0JPKMOMsJoM+II4T+LHgyCjRHyb+5Cs
vD0cW33cCndoc/x62zkPwBLto3v/S0ccAilnignUf6C2a9NA0ULRAV/TJHPGOxpb
VOdwJxGLbZ/9zHxqKyDeP2GUI2H00gVL8C0XvaaHcaXprRBcThil8t5dvd1det1e
yTQs3ptygXg=
=VdbD
-END PGP SIGNATURE-