diff --git a/connection.py b/connection.py index b4bbb31b4f..ec17cb338d 100644 --- a/connection.py +++ b/connection.py @@ -31,6 +31,7 @@ else: from urlparse import urlparse from urllib import splitport # pylint: disable=C0412 +# pylint: disable=W0622 class ConnectionError(Exception): pass @@ -276,6 +277,7 @@ class PackageUpload: text = [x[1] for x in headers.getaddrlist(prefix + '-String')] # text is a list now, convert it to a string text = '\n'.join(text) + # pylint: disable=W1505 text = base64.decodestring(text) return text diff --git a/rhnpush.spec b/rhnpush.spec index 0a6da49618..aa3ba0db0d 100644 --- a/rhnpush.spec +++ b/rhnpush.spec @@ -5,6 +5,10 @@ %global default_py3 1 %endif +%if ( 0%{?fedora} && 0%{?fedora} < 28 ) || ( 0%{?rhel} && 0%{?rhel} < 8 ) +%global build_py2 1 +%endif + %define pythonX %{?default_py3: python3}%{!?default_py3: python2} Name: rhnpush @@ -12,14 +16,19 @@ Summary: Package uploader for the Spacewalk or Red Hat Satellite Server License: GPLv2 URL: https://github.com/spacewalkproject/spacewalk Version: 5.5.110 -Release: 4%{?dist} +Release: 5%{?dist} Source0: https://github.com/spacewalkproject/spacewalk/archive/%{name}-%{version}.tar.gz BuildArch: noarch Requires: %{pythonX}-%{name} = %{version}-%{release} BuildRequires: docbook-utils, gettext %if 0%{?pylint_check} +%if 0%{?build_py2} BuildRequires: spacewalk-python2-pylint %endif +%if 0%{?build_py3} +BuildRequires: spacewalk-python3-pylint +%endif +%endif %description rhnpush uploads package headers to the Spacewalk or Red Hat Satellite @@ -27,20 +36,27 @@ servers into specified channels and allows for several other channel management operations relevant to controlling what packages are available per channel. +%if 0%{?build_py2} %package -n python2-%{name} Summary: Package uploader for the Spacewalk or Red Hat Satellite Server %{?python_provide:%python_provide python2-%{name}} Requires: %{name} = %{version}-%{release} +%if 0%{?fedora} >= 28 +Requires: python2-rpm +BuildRequires: python2-devel +%else Requires: rpm-python +BuildRequires: python-devel +%endif Requires: rhnlib >= 2.8.3 Requires: python2-rhn-client-tools Requires: spacewalk-backend-libs >= 1.7.17 Requires: spacewalk-usix BuildRequires: spacewalk-backend-libs > 1.8.33 -BuildRequires: python-devel BuildRequires: python2-rhn-client-tools %description -n python2-%{name} Python 2 specific files for rhnpush. +%endif %if 0%{?build_py3} %package -n python3-%{name} @@ -53,7 +69,7 @@ Requires: python3-rhn-client-tools Requires: python3-spacewalk-backend-libs Requires: python3-spacewalk-usix BuildRequires: spacewalk-backend-libs > 1.8.33 -BuildRequires: python-devel +BuildRequires: python3-devel BuildRequires: python3-rhn-client-tools BuildRequires: python3-rpm-macros %description -n python3-%{name} @@ -69,8 +85,10 @@ make -f Makefile.rhnpush all %install install -d $RPM_BUILD_ROOT/%{python_sitelib} +%if 0%{?build_py2} make -f Makefile.rhnpush install PREFIX=$RPM_BUILD_ROOT ROOT=%{python_sitelib} \ MANDIR=%{_mandir} PYTHON_VERSION=%{python_version} +%endif %if 0%{?build_py3} sed -i 's|#!/usr/bin/python|#!/usr/bin/python3|' rhnpush @@ -87,9 +105,15 @@ ln -s rhnpush%{default_suffix} $RPM_BUILD_ROOT%{_bindir}/rhnpush %check %if 0%{?pylint_check} # check coding style +%if 0%{?build_py2} export PYTHONPATH=$RPM_BUILD_ROOT%{python_sitelib} spacewalk-python2-pylint $RPM_BUILD_ROOT%{_bindir} $RPM_BUILD_ROOT%{python_sitelib} %endif +%if 0%{?build_py3} +export PYTHONPATH=$RPM_BUILD_ROOT%{python3_sitelib} +spacewalk-python3-pylint $RPM_BUILD_ROOT%{_bindir} $RPM_BUILD_ROOT%{python3_sitelib} +%endif +%endif %files %{_bindir}/rhnpush @@ -98,9 +122,11 @@ spacewalk-python2-pylint $RPM_BUILD_ROOT%{_bindir} $RPM_BUILD_ROOT%{python_sitel %{_mandir}/man8/rhnpush.8* %doc COPYING +%if 0%{?build_py2} %files -n python2-%{name} %attr(755,root,root) %{_bindir}/rhnpush-%{python_version} %{python_sitelib}/rhnpush/ +%endif %if 0%{?build_py3} %files -n python3-%{name} @@ -109,6 +135,15 @@ spacewalk-python2-pylint $RPM_BUILD_ROOT%{_bindir} $RPM_BUILD_ROOT%{python_sitel %endif %changelog +* Tue Mar 20 2018 Tomas Kasparek 5.5.110-5 +- disable pylint warnings discovered by run on python3 (tkasparek@redhat.com) +- run pylint 2/3 depending on environment (tkasparek@redhat.com) +- don't build python2 subpackages on systems with default python3 + (tkasparek@redhat.com) +- be compliant with new packaging guidelines when requiring python2 packages + (tkasparek@redhat.com) +- require python3-devel for building on python3 (tkasparek@redhat.com) + * Wed Mar 14 2018 Tomas Kasparek 5.5.110-4 - build for python3 (tkasparek@redhat.com) diff --git a/rhnpush_main.py b/rhnpush_main.py index a4aef2f1f3..b50ec5b7b6 100755 --- a/rhnpush_main.py +++ b/rhnpush_main.py @@ -32,6 +32,7 @@ import os import random import sys import time +# pylint: disable=W0402 from optparse import Option, OptionParser # pylint: disable=F0401,E0611 diff --git a/uploadLib.py b/uploadLib.py index b712a92ce2..3aa6011b5b 100644 --- a/uploadLib.py +++ b/uploadLib.py @@ -754,6 +754,7 @@ def getServer(uri, proxy=None, username=None, password=None, ca_chain=None): # pylint: disable=E1123 def hasChannelChecksumCapability(rpc_server): """ check whether server supports getPackageChecksumBySession function""" + # pylint: disable=W1505 if 'rpcServerOverride' in inspect.getargspec(rhnserver.RhnServer.__init__)[0]: server = rhnserver.RhnServer(rpcServerOverride=rpc_server) else: @@ -768,6 +769,7 @@ def exists_getPackageChecksumBySession(rpc_server): # unfortunatelly we do not have capability for getPackageChecksumBySession function, # but extended_profile in version 2 has been created just 2 months before # getPackageChecksumBySession lets use it instead + # pylint: disable=W1505 if 'rpcServerOverride' in inspect.getargspec(rhnserver.RhnServer.__init__)[0]: server = rhnserver.RhnServer(rpcServerOverride=rpc_server) else: