From 9aa09ddac229388626a2958ae3c2e9ee5f26b110 Mon Sep 17 00:00:00 2001 From: Daniel Mach Date: Tue, 30 Aug 2022 16:03:00 +0000 Subject: [PATCH] Fix build on SLE12 Fixes: #1123 Fixes: #1103 Signed-off-by: Michal Suchanek --- .github/workflows/unittests.yaml | 6 +++--- osc/conf.py | 6 +++++- osc/credentials.py | 5 ++++- setup.py | 3 +-- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/.github/workflows/unittests.yaml b/.github/workflows/unittests.yaml index 26195bc7..e8256108 100644 --- a/.github/workflows/unittests.yaml +++ b/.github/workflows/unittests.yaml @@ -50,7 +50,7 @@ jobs: zypper --non-interactive --gpg-auto-import-keys refresh zypper --non-interactive dist-upgrade zypper --non-interactive install git-lfs - zypper --non-interactive install diffstat diffutils python3 python3-chardet python3-M2Crypto python3-pip python3-rpm python3-setuptools + zypper --non-interactive install diffstat diffutils python3 python3-M2Crypto python3-pip python3-rpm python3-setuptools - name: 'Install packages (Fedora/CentOS)' if: ${{ startsWith(matrix.container, 'fedora:') || contains(matrix.container, 'centos:') }} @@ -58,7 +58,7 @@ jobs: dnf -y makecache dnf -y distro-sync dnf -y install git-lfs - dnf -y install diffstat diffutils python3 python3-chardet python3-m2crypto python3-pip python3-rpm python3-setuptools + dnf -y install diffstat diffutils python3 python3-m2crypto python3-pip python3-rpm python3-setuptools - name: 'Install packages (Debian/Ubuntu)' if: ${{ startsWith(matrix.container, 'debian:') || startsWith(matrix.container, 'ubuntu:') }} @@ -66,7 +66,7 @@ jobs: apt-get -y update apt-get -y upgrade apt-get -y --no-install-recommends install git-lfs - apt-get -y --no-install-recommends install diffstat diffutils python3 python3-chardet python3-m2crypto python3-pip python3-rpm python3-setuptools + apt-get -y --no-install-recommends install diffstat diffutils python3 python3-m2crypto python3-pip python3-rpm python3-setuptools - uses: actions/checkout@v3 diff --git a/osc/conf.py b/osc/conf.py index 6d8cc1cb..e3be9297 100644 --- a/osc/conf.py +++ b/osc/conf.py @@ -537,7 +537,11 @@ def _build_opener(apiurl): def http_error_401(self, req, fp, code, msg, headers): self._rewind_request(req) authreqs = {} - for authreq in headers.get_all('www-authenticate', []): + if hasattr(headers, "get_all"): + all_headers = headers.get_all('www-authenticate', []) + else: + all_headers = headers.getallmatchingheaders('www-authenticate') + for authreq in all_headers: scheme = authreq.split()[0].lower() authreqs[scheme] = authreq diff --git a/osc/credentials.py b/osc/credentials.py index d076b2ad..30242b6d 100644 --- a/osc/credentials.py +++ b/osc/credentials.py @@ -1,3 +1,5 @@ +from __future__ import print_function + import importlib import bz2 import base64 @@ -29,7 +31,6 @@ except BaseException as e: print(msg, e, file=sys.stderr) gnomekeyring = None -from . import conf from . import oscerr @@ -234,6 +235,7 @@ class KeyringCredentialsManager(AbstractCredentialsManager): keyring_backend = keyring.core.load_keyring(self._backend_cls_name) except ModuleNotFoundError: msg = "Invalid credentials_mgr_class: {}".format(self._backend_cls_name) + from . import conf raise oscerr.ConfigError(msg, conf.config['conffile']) keyring.set_keyring(keyring_backend) @@ -420,6 +422,7 @@ def create_credentials_manager(url, cp): creds_mgr = getattr(importlib.import_module(mod), cls).create(cp, options) except ModuleNotFoundError: msg = "Invalid credentials_mgr_class: {}".format(creds_mgr_cls) + from . import conf raise oscerr.ConfigError(msg, conf.config['conffile']) return creds_mgr diff --git a/setup.py b/setup.py index e0dd9b76..94c6596e 100755 --- a/setup.py +++ b/setup.py @@ -103,7 +103,7 @@ setuptools.setup( packages=['osc', 'osc.util'], scripts=['osc-wrapper.py'], data_files=data_files, - install_requires=['M2Crypto', 'chardet'], + install_requires=['M2Crypto'], classifiers=[ "Development Status :: 5 - Production/Stable", "Environment :: Console", @@ -129,5 +129,4 @@ setuptools.setup( ], # Override certain command classes with our own ones cmdclass=cmdclass, - test_suite="tests", )