From e85174abce22843a8bae2b28ebf83ece960c0a0b Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Thu, 4 Apr 2019 13:51:43 -0700 Subject: [PATCH] Use strict=False when reading repo files In some cases they may contain duplicate sections. With it set to False the last one wins instead of causing a traceback. Related: rhbz#1678937 --- src/pylorax/api/projects.py | 4 ++-- tests/pylorax/repos/duplicate-test.repo | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 tests/pylorax/repos/duplicate-test.repo diff --git a/src/pylorax/api/projects.py b/src/pylorax/api/projects.py index 9b31eb09..6411e236 100644 --- a/src/pylorax/api/projects.py +++ b/src/pylorax/api/projects.py @@ -553,7 +553,7 @@ def get_source_ids(source_path): if not os.path.exists(source_path): return [] - cfg = ConfigParser() + cfg = ConfigParser(strict=False) cfg.read(source_path) return cfg.sections() @@ -587,7 +587,7 @@ def delete_repo_source(source_glob, source_name): found = False for f in glob(source_glob): try: - cfg = ConfigParser() + cfg = ConfigParser(strict=False) cfg.read(f) if source_name in cfg.sections(): found = True diff --git a/tests/pylorax/repos/duplicate-test.repo b/tests/pylorax/repos/duplicate-test.repo new file mode 100644 index 00000000..5f22f75f --- /dev/null +++ b/tests/pylorax/repos/duplicate-test.repo @@ -0,0 +1,23 @@ +[duplicate-repo] +name=Duplicate repo #1 +failovermethod=priority +baseurl=file:///tmp/lorax-empty-repo/ +enabled=1 +metadata_expire=7d +repo_gpgcheck=0 +type=rpm +gpgcheck=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-$basearch +skip_if_unavailable=False + +[duplicate-repo] +name=Duplicate repo #2 +failovermethod=priority +baseurl=file:///tmp/lorax-empty-repo/ +enabled=1 +metadata_expire=7d +repo_gpgcheck=0 +type=rpm +gpgcheck=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-$basearch +skip_if_unavailable=False