From 0ab92c582509f6854e60d147e772ea75febdc741 Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Oct 06 2020 13:12:08 +0000 Subject: PR#2490: Drop py 2.6 support (RHEL6) Merges #2490 https://pagure.io/koji/pull-request/2490 Fixes: #2155 https://pagure.io/koji/issue/2155 Drop py 2.6 support (RHEL6) --- diff --git a/builder/Makefile b/builder/Makefile index b137335..80a46cd 100644 --- a/builder/Makefile +++ b/builder/Makefile @@ -3,7 +3,6 @@ PYVER := $(shell $(PYTHON) -c 'import sys; print("%.1s" %(sys.version))') BINFILES = kojid LIBEXECFILES = mergerepos SYSTEMDSYSTEMUNITDIR = $(shell pkg-config systemd --variable=systemdsystemunitdir) -TYPE = systemd _default: @echo "nothing to make. try make install" @@ -33,15 +32,6 @@ _install: mkdir -p $(DESTDIR)/etc/kojid install -p -m 644 kojid.conf $(DESTDIR)/etc/kojid/kojid.conf -install-systemd: _install +install: _install mkdir -p $(DESTDIR)$(SYSTEMDSYSTEMUNITDIR) install -p -m 644 kojid.service $(DESTDIR)$(SYSTEMDSYSTEMUNITDIR) - -install-sysv: _install - mkdir -p $(DESTDIR)/etc/rc.d/init.d - install -p -m 755 kojid.init $(DESTDIR)/etc/rc.d/init.d/kojid - - mkdir -p $(DESTDIR)/etc/sysconfig - install -p -m 644 kojid.sysconfig $(DESTDIR)/etc/sysconfig/kojid - -install: install-$(TYPE) diff --git a/builder/kojid b/builder/kojid index 5905ab1..a1f8162 100755 --- a/builder/kojid +++ b/builder/kojid @@ -26,6 +26,7 @@ from __future__ import absolute_import, division import copy import glob import grp +import io import json import logging import logging.handlers @@ -48,6 +49,8 @@ from gzip import GzipFile from optparse import SUPPRESS_HELP, OptionParser import Cheetah.Template +import dnf +import librepo import requests import rpm import six @@ -79,26 +82,6 @@ except ImportError: # pragma: no cover except ImportError: # pragma: no cover reqgssapi = None -try: - import librepo - import io -except ImportError: - librepo = None - -try: - import dnf -except ImportError: - dnf = None - -try: - # yum - from yum import repoMDObject - import yum.packages - import yum.Errors - yum_available = True -except ImportError: - yum_available = False - # imports for LiveCD, LiveMedia, and Appliance handler try: import pykickstart.parser as ksparser @@ -803,60 +786,42 @@ class BuildRoot(object): opts = dict([(k, getattr(self.options, k)) for k in ('topurl', 'topdir')]) opts['tempdir'] = self.options.workdir - # prefer librepo - if librepo is not None: - repo_url = os.path.join(repodir, self.br_arch) - # repo_url can start with '/', don't use os.path.join - if self.options.topurl: - repo_url = '%s/%s' % (self.options.topurl, repo_url) - elif self.options.topdir: - repo_url = '%s/%s' % (self.options.topdir, repo_url) - logging.error(repo_url) - tmpdir = os.path.join(self.tmpdir(), 'librepo-markExternalRPMs') - koji.ensuredir(tmpdir) - h = librepo.Handle() - r = librepo.Result() - h.setopt(librepo.LRO_REPOTYPE, librepo.LR_YUMREPO) - h.setopt(librepo.LRO_URLS, [repo_url]) - h.setopt(librepo.LRO_DESTDIR, tmpdir) - # We are using this just to find out location of 'origin', - # we don't even need to download it since we use openRemoteFile - h.setopt(librepo.LRO_YUMDLIST, []) - h.perform(r) - pkgorigins = r.getinfo(librepo.LRR_YUM_REPOMD)['origin']['location_href'] - koji.util.rmtree(tmpdir) - elif yum_available: - # XXX - cheap hack to get relative paths - repomdpath = os.path.join(repodir, self.br_arch, 'repodata', 'repomd.xml') - with koji.openRemoteFile(repomdpath, **opts) as fo: - try: - repodata = repoMDObject.RepoMD('ourrepo', fo) - except Exception: - raise koji.BuildError("Unable to parse repomd.xml file for %s" % - os.path.join(repodir, self.br_arch)) - data = repodata.getData('origin') - pkgorigins = data.location[1] - else: - # shouldn't occur - raise koji.GenericError("install librepo or yum") + repo_url = os.path.join(repodir, self.br_arch) + # repo_url can start with '/', don't use os.path.join + if self.options.topurl: + repo_url = '%s/%s' % (self.options.topurl, repo_url) + elif self.options.topdir: + repo_url = '%s/%s' % (self.options.topdir, repo_url) + logging.error(repo_url) + tmpdir = os.path.join(self.tmpdir(), 'librepo-markExternalRPMs') + koji.ensuredir(tmpdir) + h = librepo.Handle() + r = librepo.Result() + h.setopt(librepo.LRO_REPOTYPE, librepo.LR_YUMREPO) + h.setopt(librepo.LRO_URLS, [repo_url]) + h.setopt(librepo.LRO_DESTDIR, tmpdir) + # We are using this just to find out location of 'origin', + # we don't even need to download it since we use openRemoteFile + h.setopt(librepo.LRO_YUMDLIST, []) + h.perform(r) + pkgorigins = r.getinfo(librepo.LRR_YUM_REPOMD)['origin']['location_href'] + koji.util.rmtree(tmpdir) relpath = os.path.join(repodir, self.br_arch, pkgorigins) with koji.openRemoteFile(relpath, **opts) as fo: # at this point we know there were external repos at the create event, # so there should be an origins file. origin_idx = {} - # don't use 'with GzipFile' as it is not supported on py2.6 - fo2 = GzipFile(fileobj=fo, mode='r') - if six.PY3: - fo2 = io.TextIOWrapper(fo2, encoding='utf-8') - for line in fo2: - parts = line.split(None, 2) - if len(parts) < 2: - continue - # first field is formated by yum as [e:]n-v-r.a - nvra = "%(name)s-%(version)s-%(release)s.%(arch)s" % koji.parse_NVRA(parts[0]) - origin_idx[nvra] = parts[1] - fo2.close() + with GzipFile(fileobj=fo, mode='r') as fo2: + if six.PY3: + fo2 = io.TextIOWrapper(fo2, encoding='utf-8') + for line in fo2: + parts = line.split(None, 2) + if len(parts) < 2: + continue + # first field is formated by yum as [e:]n-v-r.a + nvra = "%(name)s-%(version)s-%(release)s.%(arch)s" % koji.parse_NVRA(parts[0]) + origin_idx[nvra] = parts[1] # mergerepo starts from a local repo in the task workdir, so internal # rpms have an odd-looking origin that we need to look for localtail = '/repo_%s_premerge/' % self.repo_info['id'] @@ -5756,10 +5721,7 @@ class createDistRepoTask(BaseTaskHandler): self.uploadpath = self.getUploadDir() self.get_rpms(tag, arch, keys, opts) if opts['multilib'] and koji.arch.isMultiLibArch(arch): - if dnf is not None: - self.do_multilib_dnf(arch, self.archmap[arch], opts['multilib']) - else: - self.do_multilib_yum(arch, self.archmap[arch], opts['multilib']) + self.do_multilib(arch, self.archmap[arch], opts['multilib']) self.split_pkgs(opts) self.write_kojipkgs() self.write_pkglist() @@ -5886,7 +5848,7 @@ class createDistRepoTask(BaseTaskHandler): raise koji.GenericError('failed to create repo: %s' % parseStatus(status, ' '.join(cmd))) - def do_multilib_dnf(self, arch, ml_arch, conf): + def do_multilib(self, arch, ml_arch, conf): repodir = koji.pathinfo.distrepo(self.rinfo['id'], self.rinfo['tag_name']) mldir = os.path.join(repodir, koji.canonArch(ml_arch)) ml_true = set() # multilib packages we need to include before depsolve @@ -6012,139 +5974,6 @@ enabled=1 rpminfo['_multilib'] = True self.kojipkgs[bnp] = rpminfo - def do_multilib_yum(self, arch, ml_arch, conf): - repodir = koji.pathinfo.distrepo(self.rinfo['id'], self.rinfo['tag_name']) - mldir = os.path.join(repodir, koji.canonArch(ml_arch)) - ml_true = set() # multilib packages we need to include before depsolve - ml_conf = os.path.join(koji.pathinfo.work(), conf) - - # read pkgs data from multilib repo - ml_pkgfile = os.path.join(mldir, 'kojipkgs') - ml_pkgs = json.load(open(ml_pkgfile, 'r')) - - # step 1: figure out which packages are multilib (should already exist) - mlm = multilib.DevelMultilibMethod(ml_conf) - fs_missing = set() - for bnp in self.kojipkgs: - rpminfo = self.kojipkgs[bnp] - ppath = rpminfo['_pkgpath'] - po = yum.packages.YumLocalPackage(filename=ppath) - if mlm.select(po): - # we need a multilib package to be included - ml_bnp = bnp.replace(arch, self.archmap[arch]) - ml_path = os.path.join(mldir, ml_bnp[0].lower(), ml_bnp) - # ^ XXX - should actually generate this - if ml_bnp not in ml_pkgs: - # not in our multilib repo - self.logger.error('%s (multilib) is not on the filesystem' % ml_path) - fs_missing.add(ml_path) - # we defer failure so can report all the missing deps - continue - ml_true.add(ml_path) - - # step 2: set up architectures for yum configuration - self.logger.info("Resolving multilib for %s using method devel" % arch) - yumbase = yum.YumBase() - yumbase.verbose_logger.setLevel(logging.ERROR) - yumdir = os.path.join(self.workdir, 'yum') - # TODO: unwind this arch mess - archlist = (arch, 'noarch') - transaction_arch = arch - archlist = archlist + self.compat[self.biarch[arch]] - best_compat = self.compat[self.biarch[arch]][0] - if koji.arch.archDifference(best_compat, arch) > 0: - transaction_arch = best_compat - if hasattr(koji.arch, 'ArchStorage'): - yumbase.preconf.arch = transaction_arch - else: - koji.arch.canonArch = transaction_arch - - yconfig = """ -[main] -debuglevel=2 -pkgpolicy=newest -exactarch=1 -gpgcheck=0 -reposdir=/dev/null -cachedir=/yumcache -installroot=%s -logfile=/yum.log - -[koji-%s] -name=koji multilib task -baseurl=file://%s -enabled=1 - -""" % (yumdir, self.id, mldir) - os.makedirs(os.path.join(yumdir, "yumcache")) - os.makedirs(os.path.join(yumdir, 'var/lib/rpm')) - - # step 3: proceed with yum config and set up - yconfig_path = os.path.join(yumdir, 'yum.conf-koji-%s' % arch) - with open(yconfig_path, 'w') as f: - f.write(yconfig) - self.session.uploadWrapper(yconfig_path, self.uploadpath, - os.path.basename(yconfig_path)) - yumbase.doConfigSetup(fn=yconfig_path) - yumbase.conf.cache = 0 - yumbase.doRepoSetup() - yumbase.doTsSetup() - yumbase.doRpmDBSetup() - # we trust Koji's files, so skip verifying sigs and digests - yumbase.ts.pushVSFlags( - (rpm._RPMVSF_NOSIGNATURES | rpm._RPMVSF_NODIGESTS)) - yumbase.doSackSetup(archlist=archlist, thisrepo='koji-%s' % arch) - yumbase.doSackFilelistPopulate() - for pkg in ml_true: - # TODO: store packages by first letter - # ppath = os.path.join(pkgdir, pkg.name[0].lower(), pname) - po = yum.packages.YumLocalPackage(filename=pkg) - yumbase.tsInfo.addInstall(po) - - # step 4: execute yum transaction to get dependencies - self.logger.info("Resolving depenencies for arch %s" % arch) - rc, errors = yumbase.resolveDeps() - ml_needed = {} - for tspkg in yumbase.tsInfo.getMembers(): - bnp = os.path.basename(tspkg.po.localPkg()) - dep_path = os.path.join(mldir, bnp[0].lower(), bnp) - ml_needed[dep_path] = tspkg - self.logger.debug("added %s" % dep_path) - if not os.path.exists(dep_path): - self.logger.error('%s (multilib dep) not on filesystem' % dep_path) - fs_missing.add(dep_path) - self.logger.info('yum return code: %s' % rc) - if not rc: - self.logger.error('yum depsolve was unsuccessful') - raise koji.GenericError(errors) - if len(fs_missing) > 0: - missing_log = os.path.join(self.workdir, 'missing_multilib.log') - with open(missing_log, 'w') as outfile: - outfile.write('The following multilib files were missing:\n') - for ml_path in fs_missing: - outfile.write(ml_path) - outfile.write('\n') - self.session.uploadWrapper(missing_log, self.uploadpath) - raise koji.GenericError('multilib packages missing. ' - 'See missing_multilib.log') - - # step 5: update kojipkgs - for dep_path in ml_needed: - tspkg = ml_needed[dep_path] - bnp = os.path.basename(dep_path) - if bnp in self.kojipkgs: - # we expect duplication with noarch, but not other arches - if tspkg.arch != 'noarch': - self.logger.warning("Multilib duplicate: %s", bnp) - continue - rpminfo = ml_pkgs[bnp].copy() - # fix _pkgpath, which comes from another task and could be wrong - # for us - # TODO: would be better if we could use the proper path here - rpminfo['_pkgpath'] = dep_path - rpminfo['_multilib'] = True - self.kojipkgs[bnp] = rpminfo - def pick_key(self, keys, avail_keys): best = None best_idx = None diff --git a/devtools/fakehub b/devtools/fakehub index c1b777d..6c61ebc 100755 --- a/devtools/fakehub +++ b/devtools/fakehub @@ -1,15 +1,15 @@ -#!/usr/bin/python2 +#!/usr/bin/python3 from __future__ import absolute_import, print_function import ast +import io import os import os.path import pprint import sys -from six.moves import cStringIO -from six.moves.urllib.parse import quote +from urllib.parse import quote sys.path.insert(0, os.getcwd()) sys.path.insert(1, os.path.join(os.getcwd(), 'hub')) @@ -94,7 +94,7 @@ def main(): environ['SERVER_NAME'] = 'myserver' environ['SERVER_PORT'] = '443' environ['REQUEST_URI'] = get_url(environ) - environ['wsgi.input'] = cStringIO(get_request()) + environ['wsgi.input'] = io.StringIO(get_request()) environ['REQUEST_METHOD'] = 'POST' environ['CONTENT_TYPE'] = 'text/xml' set_config(environ) diff --git a/devtools/fakeweb b/devtools/fakeweb index 12454e3..aa0f0f6 100755 --- a/devtools/fakeweb +++ b/devtools/fakeweb @@ -1,4 +1,4 @@ -#!/usr/bin/python2 +#!/usr/bin/python3 from __future__ import absolute_import, print_function @@ -7,10 +7,10 @@ import os import os.path import pprint import sys +from urllib.parse import quote from wsgiref.simple_server import make_server from wsgiref.util import setup_testing_defaults -from six.moves.urllib.parse import quote CWD = os.getcwd() sys.path.insert(0, CWD) diff --git a/docs/source/server_howto.rst b/docs/source/server_howto.rst index da80aff..f01a74d 100644 --- a/docs/source/server_howto.rst +++ b/docs/source/server_howto.rst @@ -548,9 +548,9 @@ have any mechanism for this, we need to do it via some other mechanism. Default handling is done by cron, but can be substituted by anything else (Ansible tower, etc.) -Script is by default installed on hub as `/usr/sbin/koji-sweep-db`. On systemd -systems it also has corresponding `koji-sweep-db` service and timer. Note, that -timer is not enabled by default, so you need to run usual `systemctl` commands: +Script is by default installed on hub as `/usr/sbin/koji-sweep-db`. It has also +corresponding `koji-sweep-db` service and timer. Note, that timer is not enabled +by default, so you need to run usual `systemctl` commands: :: diff --git a/koji.spec b/koji.spec index a5f3d78..d65ef6d 100644 --- a/koji.spec +++ b/koji.spec @@ -18,9 +18,13 @@ # and no python2 on rhel8+ %define py2_support 0 %else -%if 0%{?rhel} +%if 0%{?rhel} >= 7 # No python3 for older rhel %define py3_support 0 +%else +# don't build anything for rhel6 +%define py2_support 0 +%define py3_support 0 %endif %endif @@ -66,13 +70,6 @@ # If the definition isn't available for python3_pkgversion, define it %{?!python3_pkgversion:%global python3_pkgversion 3} -%if 0%{?fedora} || 0%{?rhel} >= 7 -%global use_systemd 1 -%else -%global use_systemd 0 -%global install_opt TYPE=sysv -%endif - %define baserelease 1 #build with --define 'testbuild 1' to have a timestamp appended to release %if "x%{?testbuild}" == "x1" @@ -100,10 +97,8 @@ Requires: python2-%{name} = %{version}-%{release} Requires: python-libcomps %endif %endif -%if %{use_systemd} BuildRequires: systemd BuildRequires: pkgconfig -%endif %description Koji is a system for building and tracking RPMS. The base package @@ -261,16 +256,9 @@ License: LGPLv2 and GPLv2+ Requires: mock >= 0.9.14 Requires(pre): /usr/sbin/useradd Requires: squashfs-tools -%if %{use_systemd} Requires(post): systemd Requires(preun): systemd Requires(postun): systemd -%else -Requires(post): /sbin/chkconfig -Requires(post): /sbin/service -Requires(preun): /sbin/chkconfig -Requires(preun): /sbin/service -%endif Requires: /usr/bin/cvs Requires: /usr/bin/svn Requires: /usr/bin/git @@ -295,16 +283,9 @@ Summary: Koji virtual machine management daemon Group: Applications/System License: LGPLv2 Requires: %{name} = %{version}-%{release} -%if %{use_systemd} Requires(post): systemd Requires(preun): systemd Requires(postun): systemd -%else -Requires(post): /sbin/chkconfig -Requires(post): /sbin/service -Requires(preun): /sbin/chkconfig -Requires(preun): /sbin/service -%endif %if 0%{py3_support} > 1 Requires: python%{python3_pkgversion}-libvirt Requires: python%{python3_pkgversion}-libxml2 @@ -333,11 +314,9 @@ Requires: python-psycopg2 Obsoletes: python2-koji-sidetag-plugin-tools < %{version}-%{release} Provides: python2-koji-sidetag-plugin-tools = %{version}-%{release} %endif -%if %{use_systemd} Requires(post): systemd Requires(preun): systemd Requires(postun): systemd -%endif %description utils Utilities for the Koji system @@ -388,12 +367,12 @@ exit 1 # python2 build %if 0%{py2_support} > 1 -make DESTDIR=$RPM_BUILD_ROOT PYTHON=%{__python2} %{?install_opt} install +make DESTDIR=$RPM_BUILD_ROOT PYTHON=%{__python2} install %else %if 0%{py2_support} for d in koji cli plugins ; do pushd $d - make DESTDIR=$RPM_BUILD_ROOT KOJI_MINIMAL=1 PYTHON=%{__python2} %{?install_opt} install + make DESTDIR=$RPM_BUILD_ROOT KOJI_MINIMAL=1 PYTHON=%{__python2} install popd done %endif @@ -402,7 +381,7 @@ done # python3 build %if 0%{py3_support} > 1 -make DESTDIR=$RPM_BUILD_ROOT PYTHON=%{__python3} %{?install_opt} install +make DESTDIR=$RPM_BUILD_ROOT PYTHON=%{__python3} install # alter python interpreter in koji CLI scripts='%{_bindir}/koji %{_sbindir}/kojid %{_sbindir}/kojira %{_sbindir}/koji-shadow %{_sbindir}/koji-gc %{_sbindir}/kojivmd %{_sbindir}/koji-sweep-db @@ -415,7 +394,7 @@ done # minimal for d in koji cli plugins ; do pushd $d - make DESTDIR=$RPM_BUILD_ROOT KOJI_MINIMAL=1 PYTHON=%{__python3} %{?install_opt} install + make DESTDIR=$RPM_BUILD_ROOT KOJI_MINIMAL=1 PYTHON=%{__python3} install popd done # alter python interpreter in koji CLI @@ -505,10 +484,8 @@ rm -rf $RPM_BUILD_ROOT %config(noreplace) %attr(0640, root, apache) /etc/koji-hub/hub.conf %dir /etc/koji-hub/hub.conf.d %{_sbindir}/koji-sweep-db -%if %{use_systemd} %{_unitdir}/koji-sweep-db.service %{_unitdir}/koji-sweep-db.timer -%endif %files -n python%{python3_pkgversion}-%{name}-hub %{_datadir}/koji-hub/*.py @@ -534,11 +511,9 @@ rm -rf $RPM_BUILD_ROOT %files utils %{_sbindir}/kojira -%if %{use_systemd} %{_unitdir}/koji-gc.service %{_unitdir}/koji-gc.timer %{_unitdir}/kojira.service -%endif %dir /etc/kojira %config(noreplace) /etc/kojira/kojira.conf %{_sbindir}/koji-gc @@ -567,12 +542,7 @@ rm -rf $RPM_BUILD_ROOT %dir %{_libexecdir}/kojid %{_libexecdir}/kojid/mergerepos %endif -%if %{use_systemd} %{_unitdir}/kojid.service -%else -%{_initrddir}/kojid -%config(noreplace) /etc/sysconfig/kojid -%endif %dir /etc/kojid %config(noreplace) /etc/kojid/kojid.conf %attr(-,kojibuilder,kojibuilder) /etc/mock/koji @@ -580,8 +550,6 @@ rm -rf $RPM_BUILD_ROOT %pre builder /usr/sbin/useradd -r -s /bin/bash -G mock -d /builddir -M kojibuilder 2>/dev/null ||: -%if %{use_systemd} - %post builder %systemd_post kojid.service @@ -591,33 +559,14 @@ rm -rf $RPM_BUILD_ROOT %postun builder %systemd_postun kojid.service -%else - -%post builder -/sbin/chkconfig --add kojid - -%preun builder -if [ $1 = 0 ]; then - /sbin/service kojid stop &> /dev/null - /sbin/chkconfig --del kojid -fi -%endif - %files vm %{_sbindir}/kojivmd #dir %%{_datadir}/kojivmd %{_datadir}/kojivmd/kojikamid -%if %{use_systemd} %{_unitdir}/kojivmd.service -%else -%{_initrddir}/kojivmd -%config(noreplace) /etc/sysconfig/kojivmd -%endif %dir /etc/kojivmd %config(noreplace) /etc/kojivmd/kojivmd.conf -%if %{use_systemd} - %post vm %systemd_post kojivmd.service @@ -627,19 +576,6 @@ fi %postun vm %systemd_postun kojivmd.service -%else - -%post vm -/sbin/chkconfig --add kojivmd - -%preun vm -if [ $1 = 0 ]; then - /sbin/service kojivmd stop &> /dev/null - /sbin/chkconfig --del kojivmd -fi - -%if %{use_systemd} - %post utils %systemd_post kojira.service @@ -649,18 +585,6 @@ fi %postun utils %systemd_postun kojira.service -%else -%post utils -/sbin/chkconfig --add kojira -/sbin/service kojira condrestart &> /dev/null || : -%preun utils -if [ $1 = 0 ]; then - /sbin/service kojira stop &> /dev/null || : - /sbin/chkconfig --del kojira -fi -%endif -%endif - %changelog * Tue Jul 28 2020 Mike McLean - 1.22.0-1 - PR#2404: release bump and changelog diff --git a/koji/__init__.py b/koji/__init__.py index 58c0da5..673a6f2 100644 --- a/koji/__init__.py +++ b/koji/__init__.py @@ -3304,10 +3304,6 @@ def formatTimeLong(value): t = datetime.datetime.fromtimestamp(value) else: t = value - # return date in local timezone, py 2.6 has tzone as astimezone required parameter - # would work simply as t.astimezone() for py 2.7+ - if t.tzinfo is None: - t = t.replace(tzinfo=dateutil.tz.gettz()) t = t.astimezone(dateutil.tz.gettz()) return datetime.datetime.strftime(t, '%a, %d %b %Y %H:%M:%S %Z') diff --git a/setup.py b/setup.py index 94f31b3..987682f 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,5 @@ from __future__ import absolute_import -import sys - from setuptools import setup @@ -13,6 +11,7 @@ def get_install_requires(): requires = [ 'python-dateutil', + 'pyOpenSSL', 'requests', 'requests-gssapi', 'six', @@ -20,13 +19,6 @@ def get_install_requires(): # 'rpm-py-installer', # it is optional feature # 'rpm', ] - # since pyOpenSSL-18.0.0, py26 support is dropped - # see https://pagure.io/koji/issue/1060 - if sys.version_info[0] == 2 and sys.version_info[1] < 7: - requires.append('pyOpenSSL<18.0.0') - else: - requires.append('pyOpenSSL') - return requires @@ -51,7 +43,6 @@ setup( "Intended Audience :: Developers", "License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)", "Natural Language :: English", - "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Operating System :: POSIX :: Linux", @@ -74,6 +65,6 @@ setup( 'util/koji-sweep-db', 'util/kojira', ], - python_requires='>=2.6', + python_requires='>=2.7', install_requires=get_install_requires(), ) diff --git a/test-requirements.txt b/test-requirements.txt index 1a8a17c..8f78224 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -2,8 +2,6 @@ flake8 flake8-import-order mock<=2.0.0 -requests-mock;python_version >= '2.7' -requests-mock<1.5.0;python_version < '2.7' +requests-mock coverage nose -unittest2;python_version < '3.0' diff --git a/tests/test_builder/test_build_notification.py b/tests/test_builder/test_build_notification.py index da92ba5..69aa06d 100644 --- a/tests/test_builder/test_build_notification.py +++ b/tests/test_builder/test_build_notification.py @@ -5,6 +5,7 @@ import locale import os import tempfile import time +import unittest import mock import six @@ -13,12 +14,6 @@ import koji import koji.util from .loadkojid import kojid -try: - import unittest2 as unittest -except ImportError: - import unittest - - class MyClientSession(koji.ClientSession): diff --git a/tests/test_builder/test_choose_taskarch.py b/tests/test_builder/test_choose_taskarch.py index e5cd0dd..a1c2c3f 100644 --- a/tests/test_builder/test_choose_taskarch.py +++ b/tests/test_builder/test_choose_taskarch.py @@ -2,10 +2,7 @@ from __future__ import absolute_import import mock import rpm import tempfile -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest import koji from .loadkojid import kojid from six.moves import range diff --git a/tests/test_builder/test_delay_times.py b/tests/test_builder/test_delay_times.py index 068d267..aa7bb2a 100644 --- a/tests/test_builder/test_delay_times.py +++ b/tests/test_builder/test_delay_times.py @@ -1,9 +1,6 @@ from __future__ import absolute_import import mock -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest import koji.daemon import koji diff --git a/tests/test_builder/test_taskparams.py b/tests/test_builder/test_taskparams.py index 69e9152..9e590f9 100644 --- a/tests/test_builder/test_taskparams.py +++ b/tests/test_builder/test_taskparams.py @@ -1,10 +1,7 @@ from __future__ import absolute_import import inspect import mock -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest import koji import koji.tasks diff --git a/tests/test_builder/test_volume_id.py b/tests/test_builder/test_volume_id.py index c37f622..2e557e6 100644 --- a/tests/test_builder/test_volume_id.py +++ b/tests/test_builder/test_volume_id.py @@ -1,10 +1,7 @@ from __future__ import absolute_import import mock import tempfile -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from .loadkojid import kojid import logging diff --git a/tests/test_cli/test_activate_session.py b/tests/test_cli/test_activate_session.py index 70c099e..23e700b 100644 --- a/tests/test_cli/test_activate_session.py +++ b/tests/test_cli/test_activate_session.py @@ -2,10 +2,7 @@ from __future__ import absolute_import import mock import shutil import tempfile -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from koji_cli.lib import activate_session diff --git a/tests/test_cli/test_add_group.py b/tests/test_cli/test_add_group.py index dc1582c..04e5b42 100644 --- a/tests/test_cli/test_add_group.py +++ b/tests/test_cli/test_add_group.py @@ -2,10 +2,7 @@ from __future__ import absolute_import import mock import six -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from koji_cli.commands import handle_add_group from . import utils diff --git a/tests/test_cli/test_add_group_pkg.py b/tests/test_cli/test_add_group_pkg.py index 1531c19..dd2fa26 100644 --- a/tests/test_cli/test_add_group_pkg.py +++ b/tests/test_cli/test_add_group_pkg.py @@ -1,9 +1,6 @@ from __future__ import absolute_import import mock -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from koji_cli.commands import handle_add_group_pkg from . import utils diff --git a/tests/test_cli/test_add_group_req.py b/tests/test_cli/test_add_group_req.py index d8dd90d..9502bb7 100644 --- a/tests/test_cli/test_add_group_req.py +++ b/tests/test_cli/test_add_group_req.py @@ -1,9 +1,6 @@ from __future__ import absolute_import import mock -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from koji_cli.commands import handle_add_group_req from . import utils diff --git a/tests/test_cli/test_add_host_to_channel.py b/tests/test_cli/test_add_host_to_channel.py index 1c3c245..22a24b5 100644 --- a/tests/test_cli/test_add_host_to_channel.py +++ b/tests/test_cli/test_add_host_to_channel.py @@ -4,10 +4,7 @@ import mock import os import six import sys -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from koji_cli.commands import handle_add_host_to_channel from . import utils diff --git a/tests/test_cli/test_add_notification.py b/tests/test_cli/test_add_notification.py index 7e121d4..51da4a2 100644 --- a/tests/test_cli/test_add_notification.py +++ b/tests/test_cli/test_add_notification.py @@ -1,10 +1,7 @@ from __future__ import absolute_import import koji import mock -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from six.moves import StringIO from koji_cli.commands import handle_add_notification diff --git a/tests/test_cli/test_add_pkg.py b/tests/test_cli/test_add_pkg.py index e8d5b28..d50d878 100644 --- a/tests/test_cli/test_add_pkg.py +++ b/tests/test_cli/test_add_pkg.py @@ -4,10 +4,7 @@ import mock import os import six import sys -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from mock import call diff --git a/tests/test_cli/test_add_tag.py b/tests/test_cli/test_add_tag.py index c24c3e3..1123eab 100644 --- a/tests/test_cli/test_add_tag.py +++ b/tests/test_cli/test_add_tag.py @@ -1,10 +1,7 @@ from __future__ import absolute_import import mock import six -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from koji_cli.commands import handle_add_tag from . import utils diff --git a/tests/test_cli/test_add_user.py b/tests/test_cli/test_add_user.py index 388f60e..d0604da 100644 --- a/tests/test_cli/test_add_user.py +++ b/tests/test_cli/test_add_user.py @@ -1,10 +1,7 @@ from __future__ import absolute_import import mock import six -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from koji_cli.commands import handle_add_user from . import utils diff --git a/tests/test_cli/test_add_volume.py b/tests/test_cli/test_add_volume.py index 0710321..dceff3b 100644 --- a/tests/test_cli/test_add_volume.py +++ b/tests/test_cli/test_add_volume.py @@ -1,10 +1,7 @@ from __future__ import absolute_import import mock import six -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from koji_cli.commands import handle_add_volume from . import utils diff --git a/tests/test_cli/test_assign_task.py b/tests/test_cli/test_assign_task.py index c68ef79..c7ab2d3 100644 --- a/tests/test_cli/test_assign_task.py +++ b/tests/test_cli/test_assign_task.py @@ -1,12 +1,7 @@ from __future__ import absolute_import import mock -import os import six -import sys -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest import koji from koji_cli.commands import handle_assign_task diff --git a/tests/test_cli/test_block_group_pkg.py b/tests/test_cli/test_block_group_pkg.py index da56e13..52d6d60 100644 --- a/tests/test_cli/test_block_group_pkg.py +++ b/tests/test_cli/test_block_group_pkg.py @@ -1,9 +1,6 @@ from __future__ import absolute_import import mock -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from koji_cli.commands import handle_block_group_pkg from . import utils diff --git a/tests/test_cli/test_block_group_req.py b/tests/test_cli/test_block_group_req.py index 39d4253..47a79fb 100644 --- a/tests/test_cli/test_block_group_req.py +++ b/tests/test_cli/test_block_group_req.py @@ -1,9 +1,6 @@ from __future__ import absolute_import import mock -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from koji_cli.commands import handle_block_group_req from . import utils diff --git a/tests/test_cli/test_call.py b/tests/test_cli/test_call.py index dfba8b8..a459dcc 100644 --- a/tests/test_cli/test_call.py +++ b/tests/test_cli/test_call.py @@ -2,10 +2,7 @@ from __future__ import absolute_import import json import mock import six -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from koji_cli.commands import handle_call from . import utils diff --git a/tests/test_cli/test_chain_build.py b/tests/test_cli/test_chain_build.py index c23f58c..0b9ac03 100644 --- a/tests/test_cli/test_chain_build.py +++ b/tests/test_cli/test_chain_build.py @@ -4,10 +4,7 @@ import mock import os import six import sys -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from koji_cli.commands import handle_chain_build from . import utils diff --git a/tests/test_cli/test_clone_tag.py b/tests/test_cli/test_clone_tag.py index 2ab39a6..67d4e0d 100644 --- a/tests/test_cli/test_clone_tag.py +++ b/tests/test_cli/test_clone_tag.py @@ -4,10 +4,7 @@ import mock import six from mock import call -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest import koji from koji_cli.commands import handle_clone_tag diff --git a/tests/test_cli/test_disable_host.py b/tests/test_cli/test_disable_host.py index e8824e6..46d322d 100644 --- a/tests/test_cli/test_disable_host.py +++ b/tests/test_cli/test_disable_host.py @@ -1,10 +1,7 @@ from __future__ import absolute_import import mock import six -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from mock import call from koji_cli.commands import handle_disable_host diff --git a/tests/test_cli/test_disable_user.py b/tests/test_cli/test_disable_user.py index ef1f83c..2e02ee6 100644 --- a/tests/test_cli/test_disable_user.py +++ b/tests/test_cli/test_disable_user.py @@ -1,10 +1,7 @@ from __future__ import absolute_import import mock import six -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from koji_cli.commands import handle_disable_user from . import utils diff --git a/tests/test_cli/test_dist_repo.py b/tests/test_cli/test_dist_repo.py index 45b9a2e..b400b62 100644 --- a/tests/test_cli/test_dist_repo.py +++ b/tests/test_cli/test_dist_repo.py @@ -3,10 +3,7 @@ from __future__ import print_function import copy import mock import six -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from koji_cli.commands import handle_dist_repo diff --git a/tests/test_cli/test_download_file.py b/tests/test_cli/test_download_file.py index c0bb333..894398f 100644 --- a/tests/test_cli/test_download_file.py +++ b/tests/test_cli/test_download_file.py @@ -6,10 +6,7 @@ import tempfile import os import requests_mock import requests -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from koji_cli.lib import download_file, _download_progress diff --git a/tests/test_cli/test_edit_external_repo.py b/tests/test_cli/test_edit_external_repo.py index dda7bdd..6adf1c8 100644 --- a/tests/test_cli/test_edit_external_repo.py +++ b/tests/test_cli/test_edit_external_repo.py @@ -2,10 +2,7 @@ from __future__ import absolute_import import mock import six -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest import koji from koji_cli.commands import handle_edit_external_repo diff --git a/tests/test_cli/test_edit_host.py b/tests/test_cli/test_edit_host.py index 578db7a..306d935 100644 --- a/tests/test_cli/test_edit_host.py +++ b/tests/test_cli/test_edit_host.py @@ -3,10 +3,7 @@ import mock import os import six import sys -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from mock import call diff --git a/tests/test_cli/test_edit_notification.py b/tests/test_cli/test_edit_notification.py index b265df1..8204709 100644 --- a/tests/test_cli/test_edit_notification.py +++ b/tests/test_cli/test_edit_notification.py @@ -1,10 +1,7 @@ from __future__ import absolute_import import koji import mock -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from six.moves import StringIO from koji_cli.commands import handle_edit_notification diff --git a/tests/test_cli/test_edit_user.py b/tests/test_cli/test_edit_user.py index 5c79920..56a776b 100644 --- a/tests/test_cli/test_edit_user.py +++ b/tests/test_cli/test_edit_user.py @@ -3,10 +3,7 @@ import mock import os import six import sys -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from koji_cli.commands import handle_edit_user diff --git a/tests/test_cli/test_enable_host.py b/tests/test_cli/test_enable_host.py index fc5941f..d5d6271 100644 --- a/tests/test_cli/test_enable_host.py +++ b/tests/test_cli/test_enable_host.py @@ -1,10 +1,7 @@ from __future__ import absolute_import import mock import six -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from mock import call from koji_cli.commands import handle_enable_host diff --git a/tests/test_cli/test_enable_user.py b/tests/test_cli/test_enable_user.py index 8145c97..faf7599 100644 --- a/tests/test_cli/test_enable_user.py +++ b/tests/test_cli/test_enable_user.py @@ -1,10 +1,7 @@ from __future__ import absolute_import import mock import six -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from koji_cli.commands import handle_enable_user from . import utils diff --git a/tests/test_cli/test_grant_cg_access.py b/tests/test_cli/test_grant_cg_access.py index f445eea..2b63d89 100644 --- a/tests/test_cli/test_grant_cg_access.py +++ b/tests/test_cli/test_grant_cg_access.py @@ -1,10 +1,7 @@ from __future__ import absolute_import import mock import six -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from koji_cli.commands import handle_grant_cg_access from . import utils diff --git a/tests/test_cli/test_grant_permission.py b/tests/test_cli/test_grant_permission.py index 2cc8290..b8419fa 100644 --- a/tests/test_cli/test_grant_permission.py +++ b/tests/test_cli/test_grant_permission.py @@ -1,10 +1,7 @@ from __future__ import absolute_import import mock import six -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from koji_cli.commands import handle_grant_permission from . import utils diff --git a/tests/test_cli/test_hello.py b/tests/test_cli/test_hello.py index e345c2a..dcf840a 100644 --- a/tests/test_cli/test_hello.py +++ b/tests/test_cli/test_hello.py @@ -2,10 +2,7 @@ from __future__ import absolute_import import mock import six -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest import koji from koji_cli.commands import handle_moshimoshi, _printable_unicode diff --git a/tests/test_cli/test_image_build.py b/tests/test_cli/test_image_build.py index 4278229..00040bc 100644 --- a/tests/test_cli/test_image_build.py +++ b/tests/test_cli/test_image_build.py @@ -2,10 +2,7 @@ from __future__ import absolute_import import mock import six import os -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest import koji diff --git a/tests/test_cli/test_image_build_indirection.py b/tests/test_cli/test_image_build_indirection.py index dfc0d67..9b6aa4a 100644 --- a/tests/test_cli/test_image_build_indirection.py +++ b/tests/test_cli/test_image_build_indirection.py @@ -1,10 +1,7 @@ from __future__ import absolute_import import mock import six -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest import koji diff --git a/tests/test_cli/test_import.py b/tests/test_cli/test_import.py index 623567f..654b9b7 100644 --- a/tests/test_cli/test_import.py +++ b/tests/test_cli/test_import.py @@ -2,10 +2,7 @@ from __future__ import absolute_import import mock import os import six -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest import koji from koji_cli.commands import handle_import diff --git a/tests/test_cli/test_import_cg.py b/tests/test_cli/test_import_cg.py index 1875a51..11ca191 100644 --- a/tests/test_cli/test_import_cg.py +++ b/tests/test_cli/test_import_cg.py @@ -8,10 +8,7 @@ from . import utils import os -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest class TestImportCG(utils.CliTestCase): diff --git a/tests/test_cli/test_import_comps.py b/tests/test_cli/test_import_comps.py index 18abae4..ae0cbee 100644 --- a/tests/test_cli/test_import_comps.py +++ b/tests/test_cli/test_import_comps.py @@ -4,10 +4,7 @@ import mock import os import six import sys -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest try: import libcomps diff --git a/tests/test_cli/test_import_sig.py b/tests/test_cli/test_import_sig.py index 828ef9b..074a227 100644 --- a/tests/test_cli/test_import_sig.py +++ b/tests/test_cli/test_import_sig.py @@ -5,10 +5,7 @@ import mock import random import six from six.moves import range -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from mock import call from koji.util import base64encode diff --git a/tests/test_cli/test_list_api.py b/tests/test_cli/test_list_api.py index 556afcf..deed4fc 100644 --- a/tests/test_cli/test_list_api.py +++ b/tests/test_cli/test_list_api.py @@ -1,10 +1,7 @@ from __future__ import absolute_import import mock import six -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from koji_cli.commands import anon_handle_list_api from . import utils diff --git a/tests/test_cli/test_list_channels.py b/tests/test_cli/test_list_channels.py index 84a6022..a2a256a 100644 --- a/tests/test_cli/test_list_channels.py +++ b/tests/test_cli/test_list_channels.py @@ -1,9 +1,6 @@ from __future__ import absolute_import import mock -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from six.moves import StringIO import koji diff --git a/tests/test_cli/test_list_commands.py b/tests/test_cli/test_list_commands.py index ef9b1f2..e265949 100644 --- a/tests/test_cli/test_list_commands.py +++ b/tests/test_cli/test_list_commands.py @@ -2,10 +2,7 @@ from __future__ import absolute_import import mock import os import six -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from . import loadcli, utils cli = loadcli.cli diff --git a/tests/test_cli/test_list_groups.py b/tests/test_cli/test_list_groups.py index 0abe89f..a6e0f64 100644 --- a/tests/test_cli/test_list_groups.py +++ b/tests/test_cli/test_list_groups.py @@ -2,10 +2,7 @@ from __future__ import absolute_import import mock import six import time -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from koji_cli.commands import anon_handle_list_groups from . import utils diff --git a/tests/test_cli/test_list_notifications.py b/tests/test_cli/test_list_notifications.py index a214abd..c2264d5 100644 --- a/tests/test_cli/test_list_notifications.py +++ b/tests/test_cli/test_list_notifications.py @@ -1,9 +1,6 @@ from __future__ import absolute_import import mock -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from six.moves import StringIO import koji diff --git a/tests/test_cli/test_list_permissions.py b/tests/test_cli/test_list_permissions.py index 1afb215..29f33d2 100644 --- a/tests/test_cli/test_list_permissions.py +++ b/tests/test_cli/test_list_permissions.py @@ -1,10 +1,7 @@ from __future__ import absolute_import import mock import six -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from koji_cli.commands import handle_list_permissions from . import utils diff --git a/tests/test_cli/test_list_tasks.py b/tests/test_cli/test_list_tasks.py index 8daebc1..ac45f29 100644 --- a/tests/test_cli/test_list_tasks.py +++ b/tests/test_cli/test_list_tasks.py @@ -1,10 +1,7 @@ from __future__ import absolute_import import mock import six -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest import koji from koji_cli.lib import _list_tasks diff --git a/tests/test_cli/test_list_volumes.py b/tests/test_cli/test_list_volumes.py index 0df5102..4c60bb5 100644 --- a/tests/test_cli/test_list_volumes.py +++ b/tests/test_cli/test_list_volumes.py @@ -1,10 +1,7 @@ from __future__ import absolute_import import mock import six -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from koji_cli.commands import handle_list_volumes from . import utils diff --git a/tests/test_cli/test_load_plugins.py b/tests/test_cli/test_load_plugins.py index 7e7e7b1..c9aa6a3 100644 --- a/tests/test_cli/test_load_plugins.py +++ b/tests/test_cli/test_load_plugins.py @@ -2,10 +2,7 @@ from __future__ import absolute_import import os -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest import mock diff --git a/tests/test_cli/test_maven_build.py b/tests/test_cli/test_maven_build.py index 0ab2f34..01d421f 100644 --- a/tests/test_cli/test_maven_build.py +++ b/tests/test_cli/test_maven_build.py @@ -5,10 +5,7 @@ import optparse import os import six import sys -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from koji_cli.commands import handle_maven_build from . import utils diff --git a/tests/test_cli/test_maven_chain.py b/tests/test_cli/test_maven_chain.py index 23f1144..5510d07 100644 --- a/tests/test_cli/test_maven_chain.py +++ b/tests/test_cli/test_maven_chain.py @@ -1,10 +1,7 @@ from __future__ import absolute_import import mock import six -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from koji_cli.commands import handle_maven_chain from . import utils diff --git a/tests/test_cli/test_mock_config.py b/tests/test_cli/test_mock_config.py index a863f15..440605f 100644 --- a/tests/test_cli/test_mock_config.py +++ b/tests/test_cli/test_mock_config.py @@ -1,10 +1,7 @@ from __future__ import absolute_import import mock import six -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from koji_cli.commands import anon_handle_mock_config from . import utils diff --git a/tests/test_cli/test_move_build.py b/tests/test_cli/test_move_build.py index 3398fcd..44d9312 100644 --- a/tests/test_cli/test_move_build.py +++ b/tests/test_cli/test_move_build.py @@ -1,10 +1,7 @@ from __future__ import absolute_import import mock import six -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from koji_cli.commands import handle_move_build from . import utils diff --git a/tests/test_cli/test_regen_repo.py b/tests/test_cli/test_regen_repo.py index 90f16b1..c19c411 100644 --- a/tests/test_cli/test_regen_repo.py +++ b/tests/test_cli/test_regen_repo.py @@ -3,10 +3,7 @@ from __future__ import print_function import copy import mock import six -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from koji_cli.commands import handle_regen_repo from . import utils diff --git a/tests/test_cli/test_remove_channel.py b/tests/test_cli/test_remove_channel.py index a82ca69..17cbc27 100644 --- a/tests/test_cli/test_remove_channel.py +++ b/tests/test_cli/test_remove_channel.py @@ -3,10 +3,7 @@ import mock import os import six import sys -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from koji_cli.commands import handle_remove_channel from . import utils diff --git a/tests/test_cli/test_remove_host_from_channel.py b/tests/test_cli/test_remove_host_from_channel.py index a0dd8a1..05ba32b 100644 --- a/tests/test_cli/test_remove_host_from_channel.py +++ b/tests/test_cli/test_remove_host_from_channel.py @@ -3,10 +3,7 @@ import mock import os import six import sys -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from koji_cli.commands import handle_remove_host_from_channel from . import utils diff --git a/tests/test_cli/test_remove_notification.py b/tests/test_cli/test_remove_notification.py index df253a5..8354e1e 100644 --- a/tests/test_cli/test_remove_notification.py +++ b/tests/test_cli/test_remove_notification.py @@ -1,10 +1,7 @@ from __future__ import absolute_import import koji import mock -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from six.moves import StringIO diff --git a/tests/test_cli/test_remove_pkg.py b/tests/test_cli/test_remove_pkg.py index 8c5df10..178e268 100644 --- a/tests/test_cli/test_remove_pkg.py +++ b/tests/test_cli/test_remove_pkg.py @@ -3,10 +3,7 @@ import mock import os import six import sys -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from mock import call diff --git a/tests/test_cli/test_rename_channel.py b/tests/test_cli/test_rename_channel.py index 45857e6..d1cb5ab 100644 --- a/tests/test_cli/test_rename_channel.py +++ b/tests/test_cli/test_rename_channel.py @@ -3,10 +3,7 @@ import mock import os import six import sys -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from koji_cli.commands import handle_rename_channel from . import utils diff --git a/tests/test_cli/test_restart_host.py b/tests/test_cli/test_restart_host.py index 49bf40e..750bb3d 100644 --- a/tests/test_cli/test_restart_host.py +++ b/tests/test_cli/test_restart_host.py @@ -1,10 +1,7 @@ from __future__ import absolute_import import mock import six -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest import koji from koji_cli.commands import handle_restart_hosts diff --git a/tests/test_cli/test_resubmit.py b/tests/test_cli/test_resubmit.py index 664eaa7..4a9d9d0 100644 --- a/tests/test_cli/test_resubmit.py +++ b/tests/test_cli/test_resubmit.py @@ -2,10 +2,7 @@ from __future__ import absolute_import from __future__ import print_function import mock import six -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from koji_cli.commands import handle_resubmit from . import utils diff --git a/tests/test_cli/test_revoke_cg_access.py b/tests/test_cli/test_revoke_cg_access.py index 9aa381a..8b3107c 100644 --- a/tests/test_cli/test_revoke_cg_access.py +++ b/tests/test_cli/test_revoke_cg_access.py @@ -1,10 +1,7 @@ from __future__ import absolute_import import mock import six -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from koji_cli.commands import handle_revoke_cg_access from . import utils diff --git a/tests/test_cli/test_revoke_permission.py b/tests/test_cli/test_revoke_permission.py index f807145..e532df0 100644 --- a/tests/test_cli/test_revoke_permission.py +++ b/tests/test_cli/test_revoke_permission.py @@ -1,10 +1,7 @@ from __future__ import absolute_import import mock import six -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from koji_cli.commands import handle_revoke_permission from . import utils diff --git a/tests/test_cli/test_running_in_bg.py b/tests/test_cli/test_running_in_bg.py index 0f5169d..9829782 100644 --- a/tests/test_cli/test_running_in_bg.py +++ b/tests/test_cli/test_running_in_bg.py @@ -1,9 +1,6 @@ from __future__ import absolute_import import mock -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from koji_cli.lib import _running_in_bg diff --git a/tests/test_cli/test_search.py b/tests/test_cli/test_search.py index 1d4c6c3..a692092 100644 --- a/tests/test_cli/test_search.py +++ b/tests/test_cli/test_search.py @@ -1,10 +1,7 @@ from __future__ import absolute_import import mock import six -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from koji_cli.commands import anon_handle_search from . import utils diff --git a/tests/test_cli/test_set_build_volume.py b/tests/test_cli/test_set_build_volume.py index 357527e..33302f1 100644 --- a/tests/test_cli/test_set_build_volume.py +++ b/tests/test_cli/test_set_build_volume.py @@ -1,10 +1,7 @@ from __future__ import absolute_import import mock import six -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from koji_cli.commands import handle_set_build_volume from . import utils diff --git a/tests/test_cli/test_set_pkg_arches.py b/tests/test_cli/test_set_pkg_arches.py index 6501e79..fd4ecaf 100644 --- a/tests/test_cli/test_set_pkg_arches.py +++ b/tests/test_cli/test_set_pkg_arches.py @@ -1,10 +1,7 @@ from __future__ import absolute_import import mock import six -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from koji_cli.commands import handle_set_pkg_arches from . import utils diff --git a/tests/test_cli/test_set_pkg_owner.py b/tests/test_cli/test_set_pkg_owner.py index 18e57af..03bef5e 100644 --- a/tests/test_cli/test_set_pkg_owner.py +++ b/tests/test_cli/test_set_pkg_owner.py @@ -1,10 +1,7 @@ from __future__ import absolute_import import mock import six -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from koji_cli.commands import handle_set_pkg_owner from . import utils diff --git a/tests/test_cli/test_set_task_priority.py b/tests/test_cli/test_set_task_priority.py index 1455fc0..15de222 100644 --- a/tests/test_cli/test_set_task_priority.py +++ b/tests/test_cli/test_set_task_priority.py @@ -1,10 +1,7 @@ from __future__ import absolute_import import mock import six -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from koji_cli.commands import handle_set_task_priority from . import utils diff --git a/tests/test_cli/test_spin_commands.py b/tests/test_cli/test_spin_commands.py index f5f3c42..9a4ea1a 100644 --- a/tests/test_cli/test_spin_commands.py +++ b/tests/test_cli/test_spin_commands.py @@ -2,10 +2,7 @@ from __future__ import absolute_import import mock import six -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest import koji from koji_cli.commands import handle_spin_livecd, handle_spin_livemedia, handle_spin_appliance, _build_image diff --git a/tests/test_cli/test_tag_build.py b/tests/test_cli/test_tag_build.py index 786e4be..c991663 100644 --- a/tests/test_cli/test_tag_build.py +++ b/tests/test_cli/test_tag_build.py @@ -1,10 +1,7 @@ from __future__ import absolute_import import mock import six -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from koji_cli.commands import handle_tag_build from . import utils diff --git a/tests/test_cli/test_taskinfo.py b/tests/test_cli/test_taskinfo.py index 08bb3ca..3886c7d 100644 --- a/tests/test_cli/test_taskinfo.py +++ b/tests/test_cli/test_taskinfo.py @@ -3,10 +3,7 @@ import collections import mock import six import time -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest import koji from koji_cli.commands import anon_handle_taskinfo, \ diff --git a/tests/test_cli/test_unblock_group_pkg.py b/tests/test_cli/test_unblock_group_pkg.py index d82deb1..7ae184e 100644 --- a/tests/test_cli/test_unblock_group_pkg.py +++ b/tests/test_cli/test_unblock_group_pkg.py @@ -1,9 +1,6 @@ from __future__ import absolute_import import mock -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from koji_cli.commands import handle_unblock_group_pkg from . import utils diff --git a/tests/test_cli/test_unblock_group_req.py b/tests/test_cli/test_unblock_group_req.py index cd88a9c..5b20a2d 100644 --- a/tests/test_cli/test_unblock_group_req.py +++ b/tests/test_cli/test_unblock_group_req.py @@ -1,9 +1,6 @@ from __future__ import absolute_import import mock -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from koji_cli.commands import handle_unblock_group_req from . import utils diff --git a/tests/test_cli/test_unblock_pkg.py b/tests/test_cli/test_unblock_pkg.py index 1d1923b..1fb25d1 100644 --- a/tests/test_cli/test_unblock_pkg.py +++ b/tests/test_cli/test_unblock_pkg.py @@ -1,10 +1,7 @@ from __future__ import absolute_import import mock import six -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from koji_cli.commands import handle_unblock_pkg diff --git a/tests/test_cli/test_unique_path.py b/tests/test_cli/test_unique_path.py index a223b9a..d07613b 100644 --- a/tests/test_cli/test_unique_path.py +++ b/tests/test_cli/test_unique_path.py @@ -1,8 +1,5 @@ from __future__ import absolute_import -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from six.moves import range diff --git a/tests/test_cli/test_upload_progress_callback.py b/tests/test_cli/test_upload_progress_callback.py index 6bcf62f..c291998 100644 --- a/tests/test_cli/test_upload_progress_callback.py +++ b/tests/test_cli/test_upload_progress_callback.py @@ -1,10 +1,7 @@ from __future__ import absolute_import import mock import six -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from koji_cli.lib import _format_size, _format_secs, _progress_callback diff --git a/tests/test_cli/test_wait_repo.py b/tests/test_cli/test_wait_repo.py index a73776f..d0388f8 100644 --- a/tests/test_cli/test_wait_repo.py +++ b/tests/test_cli/test_wait_repo.py @@ -3,10 +3,7 @@ from __future__ import print_function import copy import mock import six -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from koji_cli.commands import anon_handle_wait_repo from . import utils diff --git a/tests/test_cli/test_watch_tasks.py b/tests/test_cli/test_watch_tasks.py index 8a35fba..afec4e5 100644 --- a/tests/test_cli/test_watch_tasks.py +++ b/tests/test_cli/test_watch_tasks.py @@ -4,10 +4,7 @@ import mock import os import six import sys -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from mock import call from six.moves import range diff --git a/tests/test_cli/test_wrapper_rpm.py b/tests/test_cli/test_wrapper_rpm.py index beb8382..2129d13 100644 --- a/tests/test_cli/test_wrapper_rpm.py +++ b/tests/test_cli/test_wrapper_rpm.py @@ -1,10 +1,7 @@ from __future__ import absolute_import import mock import six -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from koji_cli.commands import handle_wrapper_rpm from . import utils diff --git a/tests/test_cli/test_write_signed_rpm.py b/tests/test_cli/test_write_signed_rpm.py index 1c6a07f..38643a8 100644 --- a/tests/test_cli/test_write_signed_rpm.py +++ b/tests/test_cli/test_write_signed_rpm.py @@ -2,10 +2,7 @@ from __future__ import absolute_import import hashlib import mock import six -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from mock import call import koji diff --git a/tests/test_cli/utils.py b/tests/test_cli/utils.py index 31bb4f6..31bef58 100644 --- a/tests/test_cli/utils.py +++ b/tests/test_cli/utils.py @@ -5,10 +5,7 @@ import os import six import sys from six.moves import map -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest PROGNAME = os.path.basename(sys.argv[0]) or 'koji' diff --git a/tests/test_docs_version.py b/tests/test_docs_version.py index b4f33b1..f99627b 100644 --- a/tests/test_docs_version.py +++ b/tests/test_docs_version.py @@ -2,10 +2,7 @@ from __future__ import absolute_import import os import six import subprocess -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest # docs version lives in docs/source/conf.py TOPDIR = os.path.dirname(__file__) + '/..' diff --git a/tests/test_hub/test_models/test_host.py b/tests/test_hub/test_models/test_host.py index 1a39a2e..950d482 100644 --- a/tests/test_hub/test_models/test_host.py +++ b/tests/test_hub/test_models/test_host.py @@ -1,9 +1,6 @@ from __future__ import absolute_import import mock -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest import koji import kojihub diff --git a/tests/test_kojira/test_repo_manager.py b/tests/test_kojira/test_repo_manager.py index 928a244..475bcff 100644 --- a/tests/test_kojira/test_repo_manager.py +++ b/tests/test_kojira/test_repo_manager.py @@ -1,10 +1,7 @@ from __future__ import absolute_import import mock import time -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest import koji diff --git a/tests/test_lib/test_argspec.py b/tests/test_lib/test_argspec.py index a565a64..60b3e24 100644 --- a/tests/test_lib/test_argspec.py +++ b/tests/test_lib/test_argspec.py @@ -1,8 +1,5 @@ from __future__ import absolute_import -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest import koji.util diff --git a/tests/test_lib/test_auth.py b/tests/test_lib/test_auth.py index e92a12b..dbb5e39 100644 --- a/tests/test_lib/test_auth.py +++ b/tests/test_lib/test_auth.py @@ -2,10 +2,7 @@ from __future__ import absolute_import import mock -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest import six import koji diff --git a/tests/test_lib/test_base64.py b/tests/test_lib/test_base64.py index 65d42db..1520f81 100644 --- a/tests/test_lib/test_base64.py +++ b/tests/test_lib/test_base64.py @@ -1,10 +1,7 @@ # coding=utf-8 from __future__ import absolute_import import six -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from koji.util import base64encode diff --git a/tests/test_lib/test_check_sigmd5.py b/tests/test_lib/test_check_sigmd5.py index ae5a7d8..e126c23 100644 --- a/tests/test_lib/test_check_sigmd5.py +++ b/tests/test_lib/test_check_sigmd5.py @@ -3,10 +3,7 @@ from __future__ import absolute_import import os.path import shutil import tempfile -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from koji.util import check_sigmd5 diff --git a/tests/test_lib/test_client_session.py b/tests/test_lib/test_client_session.py index 269d64a..ebe3dff 100644 --- a/tests/test_lib/test_client_session.py +++ b/tests/test_lib/test_client_session.py @@ -2,10 +2,7 @@ from __future__ import absolute_import import mock import six import weakref -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest import koji from koji.xmlrpcplus import Fault diff --git a/tests/test_lib/test_context.py b/tests/test_lib/test_context.py index 660e6cd..695a3a5 100644 --- a/tests/test_lib/test_context.py +++ b/tests/test_lib/test_context.py @@ -3,10 +3,7 @@ import six import time import random from six.moves import range -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from koji.context import context diff --git a/tests/test_lib/test_decode_bytes.py b/tests/test_lib/test_decode_bytes.py index dddaff0..7256c5b 100644 --- a/tests/test_lib/test_decode_bytes.py +++ b/tests/test_lib/test_decode_bytes.py @@ -1,10 +1,7 @@ # coding=utf-8 from __future__ import absolute_import import six -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from koji.util import decode_bytes diff --git a/tests/test_lib/test_encode_datetime.py b/tests/test_lib/test_encode_datetime.py index e2a2909..505c236 100644 --- a/tests/test_lib/test_encode_datetime.py +++ b/tests/test_lib/test_encode_datetime.py @@ -1,9 +1,6 @@ from __future__ import absolute_import import datetime -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest import koji.util from koji.xmlrpcplus import DateTime diff --git a/tests/test_lib/test_file_ops.py b/tests/test_lib/test_file_ops.py index dfb6069..1aa2a12 100644 --- a/tests/test_lib/test_file_ops.py +++ b/tests/test_lib/test_file_ops.py @@ -1,9 +1,6 @@ from __future__ import absolute_import -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest import mock import errno diff --git a/tests/test_lib/test_fixEncoding.py b/tests/test_lib/test_fixEncoding.py index ab26399..eaf8b97 100644 --- a/tests/test_lib/test_fixEncoding.py +++ b/tests/test_lib/test_fixEncoding.py @@ -7,10 +7,7 @@ from __future__ import absolute_import import koji import mock import six -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest class FixEncodingTestCase(unittest.TestCase): diff --git a/tests/test_lib/test_format_time.py b/tests/test_lib/test_format_time.py index 7fb588e..6946c3e 100644 --- a/tests/test_lib/test_format_time.py +++ b/tests/test_lib/test_format_time.py @@ -3,10 +3,7 @@ import datetime import os import time import locale -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest import six.moves.xmlrpc_client as xmlrpc_client diff --git a/tests/test_lib/test_gen_mock_config.py b/tests/test_lib/test_gen_mock_config.py index b6d822a..320ba44 100644 --- a/tests/test_lib/test_gen_mock_config.py +++ b/tests/test_lib/test_gen_mock_config.py @@ -2,10 +2,7 @@ from __future__ import absolute_import import ast import os import os.path -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest import koji diff --git a/tests/test_lib/test_grab_session_options.py b/tests/test_lib/test_grab_session_options.py index d46cefd..7b44151 100644 --- a/tests/test_lib/test_grab_session_options.py +++ b/tests/test_lib/test_grab_session_options.py @@ -1,9 +1,6 @@ from __future__ import absolute_import import optparse -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest import koji diff --git a/tests/test_lib/test_gssapi.py b/tests/test_lib/test_gssapi.py index c87e8cc..f796f8f 100644 --- a/tests/test_lib/test_gssapi.py +++ b/tests/test_lib/test_gssapi.py @@ -2,10 +2,7 @@ from __future__ import absolute_import import mock import os -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest import koji diff --git a/tests/test_lib/test_multicall_session.py b/tests/test_lib/test_multicall_session.py index 15b9142..c4978e4 100644 --- a/tests/test_lib/test_multicall_session.py +++ b/tests/test_lib/test_multicall_session.py @@ -1,8 +1,5 @@ import mock -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest import koji diff --git a/tests/test_lib/test_parse_arches.py b/tests/test_lib/test_parse_arches.py index a5aaeac..00d0d77 100644 --- a/tests/test_lib/test_parse_arches.py +++ b/tests/test_lib/test_parse_arches.py @@ -1,9 +1,6 @@ # coding: utf-8 from __future__ import absolute_import -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest import koji class TestParseArchesString(unittest.TestCase): diff --git a/tests/test_lib/test_parsers.py b/tests/test_lib/test_parsers.py index 8c67f67..e49217a 100644 --- a/tests/test_lib/test_parsers.py +++ b/tests/test_lib/test_parsers.py @@ -6,10 +6,7 @@ from __future__ import absolute_import import mock import os import rpm -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest import koji diff --git a/tests/test_lib/test_plugin.py b/tests/test_lib/test_plugin.py index 099877f..710a5c0 100644 --- a/tests/test_lib/test_plugin.py +++ b/tests/test_lib/test_plugin.py @@ -3,10 +3,7 @@ import copy import datetime import mock from six.moves import range -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest import koji import koji.util diff --git a/tests/test_lib/test_policy.py b/tests/test_lib/test_policy.py index 26cb105..fe907fd 100644 --- a/tests/test_lib/test_policy.py +++ b/tests/test_lib/test_policy.py @@ -1,8 +1,5 @@ from __future__ import absolute_import -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from nose.tools import raises diff --git a/tests/test_lib/test_profiles.py b/tests/test_lib/test_profiles.py index 0082570..1ec72e7 100644 --- a/tests/test_lib/test_profiles.py +++ b/tests/test_lib/test_profiles.py @@ -6,10 +6,7 @@ import traceback import mock from six.moves import range -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest class ProfilesTestCase(unittest.TestCase): diff --git a/tests/test_lib/test_restart_tasks.py b/tests/test_lib/test_restart_tasks.py index 860865c..d307585 100644 --- a/tests/test_lib/test_restart_tasks.py +++ b/tests/test_lib/test_restart_tasks.py @@ -2,10 +2,7 @@ from __future__ import absolute_import import mock import shutil import tempfile -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest import koji.tasks diff --git a/tests/test_lib/test_tasks.py b/tests/test_lib/test_tasks.py index ef2c04f..8dcd123 100644 --- a/tests/test_lib/test_tasks.py +++ b/tests/test_lib/test_tasks.py @@ -3,10 +3,7 @@ import random import shutil import six from six.moves import range -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from os import path, makedirs from tempfile import gettempdir diff --git a/tests/test_lib/test_utils.py b/tests/test_lib/test_utils.py index e9080a1..60d9c7e 100644 --- a/tests/test_lib/test_utils.py +++ b/tests/test_lib/test_utils.py @@ -10,10 +10,7 @@ import resource import six.moves.configparser import time import six -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest import requests_mock from mock import call, patch diff --git a/tests/test_lib/test_xmlrpcplus.py b/tests/test_lib/test_xmlrpcplus.py index 7ea5424..43974ef 100644 --- a/tests/test_lib/test_xmlrpcplus.py +++ b/tests/test_lib/test_xmlrpcplus.py @@ -1,10 +1,7 @@ # coding=utf-8 from __future__ import absolute_import from six.moves import range -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from six.moves import xmlrpc_client from koji import xmlrpcplus diff --git a/tests/test_plugins/test_protonmsg.py b/tests/test_plugins/test_protonmsg.py index 9a38bbd..82642cd 100644 --- a/tests/test_plugins/test_protonmsg.py +++ b/tests/test_plugins/test_protonmsg.py @@ -2,10 +2,7 @@ from __future__ import absolute_import import six import protonmsg import tempfile -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from mock import patch, MagicMock from koji.context import context diff --git a/tests/test_plugins/test_runroot_builder.py b/tests/test_plugins/test_runroot_builder.py index 014cb00..24998cb 100644 --- a/tests/test_plugins/test_runroot_builder.py +++ b/tests/test_plugins/test_runroot_builder.py @@ -1,10 +1,7 @@ from __future__ import absolute_import import copy import mock -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest import six.moves.configparser diff --git a/tests/test_plugins/test_runroot_cli.py b/tests/test_plugins/test_runroot_cli.py index b002cc7..17bb6df 100644 --- a/tests/test_plugins/test_runroot_cli.py +++ b/tests/test_plugins/test_runroot_cli.py @@ -2,10 +2,7 @@ from __future__ import absolute_import import io import mock import six -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest import koji from . import load_plugin diff --git a/tests/test_plugins/test_runroot_hub.py b/tests/test_plugins/test_runroot_hub.py index dfae605..f78b2e0 100644 --- a/tests/test_plugins/test_runroot_hub.py +++ b/tests/test_plugins/test_runroot_hub.py @@ -1,9 +1,6 @@ from __future__ import absolute_import import mock -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest import koji import runroot_hub diff --git a/tests/test_plugins/test_save_failed_tree_builder.py b/tests/test_plugins/test_save_failed_tree_builder.py index 909e8a3..920f605 100644 --- a/tests/test_plugins/test_save_failed_tree_builder.py +++ b/tests/test_plugins/test_save_failed_tree_builder.py @@ -2,10 +2,7 @@ from __future__ import absolute_import import mock import os import sys -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest # alter pythonpath to not load hub plugin sys.path = [os.path.join(os.path.dirname(__file__), '../../plugins/builder')] + sys.path diff --git a/tests/test_plugins/test_save_failed_tree_cli.py b/tests/test_plugins/test_save_failed_tree_cli.py index 676d85c..9bb65bb 100644 --- a/tests/test_plugins/test_save_failed_tree_cli.py +++ b/tests/test_plugins/test_save_failed_tree_cli.py @@ -1,10 +1,7 @@ from __future__ import absolute_import import mock import six -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest import koji diff --git a/tests/test_scm.py b/tests/test_scm.py index 5f1c668..54b2691 100644 --- a/tests/test_scm.py +++ b/tests/test_scm.py @@ -4,10 +4,7 @@ import mock import shutil import six import tempfile -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest import koji import koji.daemon diff --git a/util/Makefile b/util/Makefile index 7c068d3..da48a44 100644 --- a/util/Makefile +++ b/util/Makefile @@ -1,6 +1,5 @@ BINFILES = kojira koji-gc koji-shadow koji-sweep-db koji-sidetag-cleanup SYSTEMDSYSTEMUNITDIR = $(shell pkg-config systemd --variable=systemdsystemunitdir) -TYPE = systemd _default: @echo "nothing to make. try make install" @@ -29,16 +28,10 @@ _install: mkdir -p $(DESTDIR)/etc/koji-shadow install -p -m 644 koji-shadow.conf $(DESTDIR)/etc/koji-shadow/koji-shadow.conf -install-systemd: _install +install: _install mkdir -p $(DESTDIR)$(SYSTEMDSYSTEMUNITDIR) install -p -m 644 kojira.service $(DESTDIR)$(SYSTEMDSYSTEMUNITDIR) install -p -m 644 koji-gc.service $(DESTDIR)$(SYSTEMDSYSTEMUNITDIR) install -p -m 644 koji-gc.timer $(DESTDIR)$(SYSTEMDSYSTEMUNITDIR) install -p -m 644 koji-sweep-db.service $(DESTDIR)$(SYSTEMDSYSTEMUNITDIR) install -p -m 644 koji-sweep-db.timer $(DESTDIR)$(SYSTEMDSYSTEMUNITDIR) - -install-sysv: _install - # no more utils support for sysv - true - -install: install-$(TYPE) diff --git a/util/koji-gc b/util/koji-gc index 591410c..0c8af22 100755 --- a/util/koji-gc +++ b/util/koji-gc @@ -1,4 +1,4 @@ -#!/usr/bin/python2 +#!/usr/bin/python3 # koji-gc: a garbage collection tool for Koji # Copyright (c) 2007-2014 Red Hat, Inc. @@ -6,8 +6,6 @@ # Authors: # Mike McLean -from __future__ import absolute_import - import datetime import fcntl import fnmatch @@ -17,13 +15,11 @@ import pprint import smtplib import sys import time +import xmlrpc.client # for Fault +from email.mime import text as MIMEText from string import Template import requests -import six -import six.moves.configparser -import six.moves.xmlrpc_client # for Fault -from six.moves import email_mime_text as MIMEText import koji import koji.policy @@ -471,7 +467,7 @@ def handle_trash(): mcall = koji.MultiCallSession(session, batch=1000) for binfo in continuing: mcall.buildReferences(binfo['id'], limit=10, lazy=True) - for binfo, [refs] in six.moves.zip(continuing, mcall.call_all()): + for binfo, [refs] in zip(continuing, mcall.call_all()): i += 1 nvr = binfo['nvr'] # XXX - this is more data than we need @@ -583,7 +579,7 @@ def handle_trash(): # best we can do currently owner = binfo['owner_id'] else: - owner = max([(n, k) for k, n in six.iteritems(count)])[1] + owner = max([(n, k) for k, n in count.items()])[1] mcall.packageListAdd(trashcan_tag, binfo['name'], owner) mcall.tagBuildBypass(trashcan_tag, binfo['id'], force=True) # run all packageListAdd/tagBuildBypass finally @@ -655,7 +651,7 @@ def handle_delete(just_salvage=False): mcall = koji.MultiCallSession(session, batch=1000) for nvr, binfo in trash: mcall.listTags(build=binfo['id'], perms=False) - for (nvr, binfo), [tags] in six.moves.zip(trash, mcall.call_all()): + for (nvr, binfo), [tags] in zip(trash, mcall.call_all()): # see if build has been tagged elsewhere tags = [t['name'] for t in tags if t['name'] != trashcan_tag] if tags: @@ -713,7 +709,7 @@ def handle_delete(just_salvage=False): mcall.untagBuildBypass(trashcan_tag, binfo['id']) mcall.deleteBuild(binfo['id']) - for binfo, result in six.moves.zip(continuing, mcall.call_all()): + for binfo, result in zip(continuing, mcall.call_all()): if isinstance(result, dict): print("Warning: deletion failed: %s" % result['faultString']) # TODO - log details for delete failures @@ -936,7 +932,7 @@ def handle_prune(): session.untagBuildBypass(taginfo['id'], entry['build_id'], force=bypass) untagged.setdefault(nvr, {})[tagname] = 1 - except (six.moves.xmlrpc_client.Fault, koji.GenericError) as e: + except (xmlrpc.client.Fault, koji.GenericError) as e: print("Warning: untag operation failed: %s" % e) pass # if action == 'keep' do nothing @@ -970,7 +966,7 @@ def handle_prune(): print("Deleting untagged build: %s" % nvr) try: session.deleteBuild(build_id, strict=True) - except (six.moves.xmlrpc_client.Fault, koji.GenericError) as e: + except (xmlrpc.client.Fault, koji.GenericError) as e: print("Warning: deletion failed: %s" % e) # server issue pass diff --git a/util/koji-shadow b/util/koji-shadow index 2cbef13..16bb2ab 100755 --- a/util/koji-shadow +++ b/util/koji-shadow @@ -1,4 +1,4 @@ -#!/usr/bin/python2 +#!/usr/bin/python3 # koji-shadow: a tool to shadow builds between koji instances # Copyright (c) 2007-2016 Red Hat, Inc. @@ -37,9 +37,6 @@ import urllib2 import requests import rpm -import six -import six.moves.xmlrpc_client # for Fault -from six.moves import range import koji from koji.util import to_list @@ -513,7 +510,7 @@ class TrackedBuild(object): # changes happened during the build startup and some subtasks got the old # repo and others the new one. base = [] - for name, brlist in six.iteritems(bases): + for name, brlist in bases.items(): # We want to determine for each name if that package was present # in /all/ the buildroots or just some. # Because brlist is constructed only from elements of buildroots, we @@ -525,7 +522,7 @@ class TrackedBuild(object): if len(tags) > 1: log("Warning: found multiple buildroot tags for %s: %s" % (self.nvr, to_list(tags.keys()))) - counts = sorted([(n, tag) for tag, n in six.iteritems(tags)]) + counts = sorted([(n, tag) for tag, n in tags.items()]) tag = counts[-1][1] else: tag = to_list(tags.keys())[0] @@ -973,7 +970,7 @@ class BuildTracker(object): for pkg in session.listPackages(pkgID=name): owners.setdefault(pkg['owner_id'], []).append(pkg) if owners: - order = sorted([(len(v), k) for k, v in six.iteritems(owners)]) + order = sorted([(len(v), k) for k, v in owners.items()]) owner = order[-1][1] else: # just use ourselves @@ -1119,7 +1116,7 @@ class BuildTracker(object): nvr = dep.substitute problem_counts.setdefault(nvr, 0) problem_counts[nvr] += 1 - order = [(c, nvr) for (nvr, c) in six.iteritems(problem_counts)] + order = [(c, nvr) for (nvr, c) in problem_counts.items()] if order: order.sort(reverse=True) # print top 5 problems @@ -1200,7 +1197,7 @@ class BuildTracker(object): ret = False if options.max_jobs and len(self.state_idx['pending']) >= options.max_jobs: return ret - missing = sorted([(b.order, b.id, b) for b in six.itervalues(self.state_idx['missing'])]) + missing = sorted([(b.order, b.id, b) for b in self.state_idx['missing'].values()]) for order, build_id, build in missing: if not self.checkBuildDeps(build): continue diff --git a/util/koji-sidetag-cleanup b/util/koji-sidetag-cleanup index e99e533..bf1cbc4 100644 --- a/util/koji-sidetag-cleanup +++ b/util/koji-sidetag-cleanup @@ -1,4 +1,4 @@ -#!/usr/bin/python2 +#!/usr/bin/python3 import sys import configparser diff --git a/util/koji-sweep-db b/util/koji-sweep-db index c4c72bb..82f0e6a 100755 --- a/util/koji-sweep-db +++ b/util/koji-sweep-db @@ -1,11 +1,10 @@ #!/usr/bin/python2 import os +import xmlrpc.client +from configparser import RawConfigParser from optparse import OptionParser -from six.moves import xmlrpc_client -from six.moves.configparser import RawConfigParser - import koji.db @@ -71,7 +70,7 @@ def clean_scratch_tasks(cursor, vacuum, test, age): for row in cursor.fetchall(): task_id, request = row try: - params, method = xmlrpc_client.loads(request) + params, method = xmlrpc.client.loads(request) opts = params[2] if opts['scratch']: cursor.execute("INSERT INTO temp_scratch_tasks VALUES (%s)", (task_id,)) diff --git a/util/kojira b/util/kojira index daea9a6..040fb60 100755 --- a/util/kojira +++ b/util/kojira @@ -1,4 +1,4 @@ -#!/usr/bin/python2 +#!/usr/bin/python3 # Koji Repository Administrator (kojira) # Copyright (c) 2005-2014 Red Hat, Inc. @@ -20,8 +20,6 @@ # Authors: # Mike McLean -from __future__ import absolute_import, division - import errno import json import logging @@ -38,7 +36,6 @@ from optparse import OptionParser from xml.etree import ElementTree import requests -import six import koji from koji.util import deprecated, parseStatus, rmtree, to_list @@ -300,9 +297,9 @@ class RepoManager(object): def printState(self): self.logger.debug('Tracking %i repos, %i child processes', len(self.repos), len(self.delete_pids)) - for tag_id, task_id in six.iteritems(self.tasks): + for tag_id, task_id in self.tasks.items(): self.logger.debug("Tracking task %s for tag %s", task_id, tag_id) - for pid, desc in six.iteritems(self.delete_pids): + for pid, desc in self.delete_pids.items(): self.logger.debug("Delete job %s: %r", pid, desc) def rmtree(self, path): diff --git a/vm/Makefile b/vm/Makefile index 4916199..4f2ea42 100644 --- a/vm/Makefile +++ b/vm/Makefile @@ -1,7 +1,6 @@ BINFILES = kojivmd SHAREFILES = kojikamid SYSTEMDSYSTEMUNITDIR = $(shell pkg-config systemd --variable=systemdsystemunitdir) -TYPE = systemd _default: @echo "nothing to make. try make install" @@ -28,15 +27,6 @@ _install: kojikamid mkdir -p $(DESTDIR)/etc/kojivmd install -p -m 644 kojivmd.conf $(DESTDIR)/etc/kojivmd/kojivmd.conf -install-systemd: _install +install: _install mkdir -p $(DESTDIR)$(SYSTEMDSYSTEMUNITDIR) install -p -m 644 kojivmd.service $(DESTDIR)$(SYSTEMDSYSTEMUNITDIR) - -install-sysv: _install - mkdir -p $(DESTDIR)/etc/rc.d/init.d - install -p -m 755 kojivmd.init $(DESTDIR)/etc/rc.d/init.d/kojivmd - - mkdir -p $(DESTDIR)/etc/sysconfig - install -p -m 644 kojivmd.sysconfig $(DESTDIR)/etc/sysconfig/kojivmd - -install: install-$(TYPE) diff --git a/vm/kojikamid.py b/vm/kojikamid.py index b4de858..e7bf1b9 100755 --- a/vm/kojikamid.py +++ b/vm/kojikamid.py @@ -26,8 +26,6 @@ # kojiwind --install # in a cygwin shell. -from __future__ import absolute_import - import base64 import glob import hashlib @@ -43,12 +41,11 @@ import traceback import zipfile from optparse import OptionParser -import six -import six.moves.xmlrpc_client +import xmlrpc.client # urllib is required by the SCM class which is substituted into this file # do not remove the import below -from six.moves import urllib # noqa: F401 -from six.moves.configparser import RawConfigParser +import urllib # noqa: F401 +from configparser import RawConfigParser MANAGER_PORT = 7000 @@ -630,14 +627,12 @@ def get_mgmt_server(): macaddr, gateway = find_net_info() logger.debug('found MAC address %s, connecting to %s:%s', macaddr, gateway, MANAGER_PORT) - server = six.moves.xmlrpc_client.ServerProxy('http://%s:%s/' % - (gateway, MANAGER_PORT), allow_none=True) + server = xmlrpc.client.ServerProxy('http://%s:%s/' % (gateway, MANAGER_PORT), allow_none=True) # we would set a timeout on the socket here, but that is apparently not # supported by python/cygwin/Windows task_port = server.getPort(macaddr) logger.debug('found task-specific port %s', task_port) - return six.moves.xmlrpc_client.ServerProxy('http://%s:%s/' % (gateway, task_port), - allow_none=True) + return xmlrpc.client.ServerProxy('http://%s:%s/' % (gateway, task_port), allow_none=True) def get_options(): @@ -690,7 +685,7 @@ def stream_logs(server, handler, builds): logpath = os.path.join(build.source_dir, relpath) if logpath not in logs: logs[logpath] = (relpath, None) - for log, (relpath, fd) in six.iteritems(logs): + for log, (relpath, fd) in logs.items(): if not fd: if os.path.isfile(log): try: diff --git a/vm/kojivmd b/vm/kojivmd index 8320281..e50debd 100755 --- a/vm/kojivmd +++ b/vm/kojivmd @@ -1,4 +1,4 @@ -#!/usr/bin/python2 +#!/usr/bin/python3 # Koji virtual machine management daemon # Copyright (c) 2010-2014 Red Hat, Inc. @@ -35,14 +35,13 @@ import subprocess import sys import threading import time +import xmlrpc from contextlib import closing from optparse import OptionParser import libvirt import libxml2 import requests -import six.moves.xmlrpc_client -import six.moves.xmlrpc_server import koji import koji.util @@ -254,24 +253,24 @@ def main(options, session): # Tasks for handling VM lifecycle #################### -class DaemonXMLRPCServer(six.moves.xmlrpc_server.SimpleXMLRPCServer): +class DaemonXMLRPCServer(xmlrpc.server.SimpleXMLRPCServer): allow_reuse_address = True def __init__(self, addr, port): if sys.version_info[:2] <= (2, 4): - six.moves.xmlrpc_server.SimpleXMLRPCServer.__init__(self, (addr, port), - logRequests=False) + xmlrpc.server.SimpleXMLRPCServer.__init__(self, (addr, port), + logRequests=False) else: - six.moves.xmlrpc_server.SimpleXMLRPCServer.__init__(self, (addr, port), - logRequests=False, - allow_none=True) + xmlrpc.server.SimpleXMLRPCServer.__init__(self, (addr, port), + logRequests=False, + allow_none=True) self.logger = logging.getLogger('koji.vm.DaemonXMLRPCServer') self.socket.settimeout(5) self.active = True def server_close(self): self.active = False - six.moves.xmlrpc_server.SimpleXMLRPCServer.server_close(self) + xmlrpc.server.SimpleXMLRPCServer.server_close(self) def handle_while_active(self): while self.active: @@ -292,23 +291,20 @@ class DaemonXMLRPCServer(six.moves.xmlrpc_server.SimpleXMLRPCServer): # Copy and paste from SimpleXMLRPCServer, with the addition of passing # allow_none=True to xmlrpclib.dumps() def _marshaled_dispatch(self, data, dispatch_method=None): - params, method = six.moves.xmlrpc_client.loads(data) + params, method = xmlrpc.client.loads(data) try: if dispatch_method is not None: response = dispatch_method(method, params) else: response = self._dispatch(method, params) response = (response,) - response = six.moves.xmlrpc_client.dumps(response, - methodresponse=1, allow_none=True) - except six.moves.xmlrpc_client.Fault as fault: - response = six.moves.xmlrpc_client.dumps(fault) + response = xmlrpc.client.dumps(response, methodresponse=1, allow_none=True) + except xmlrpc.client.Fault as fault: + response = xmlrpc.client.dumps(fault) except Exception: # report exception back to server - response = six.moves.xmlrpc_client.dumps( - six.moves.xmlrpc_client.Fault( - 1, "%s:%s" % - (sys.exc_info()[0], sys.exc_info()[1])) + response = xmlrpc.client.dumps( + xmlrpc.client.Fault(1, "%s:%s" % (sys.exc_info()[0], sys.exc_info()[1])) ) return response @@ -434,7 +430,7 @@ class VMExecTask(BaseTaskHandler): def __init__(self, *args, **kw): super(VMExecTask, self).__init__(*args, **kw) - self.task_manager = six.moves.xmlrpc_client.ServerProxy( + self.task_manager = xmlrpc.client.ServerProxy( 'http://%s:%s/' % (self.options.privaddr, self.options.portbase), allow_none=True) self.port = None self.server = None