From d2ecd449121400b81d6ba5c10207829e4d7ce42f Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: May 12 2017 09:34:17 +0000 Subject: python-modernize -f libmodernize.fixes.fix_imports_six --- diff --git a/builder/kojid b/builder/kojid index 8831c8e..e4c84c9 100755 --- a/builder/kojid +++ b/builder/kojid @@ -57,11 +57,11 @@ import sys import time import traceback import xml.dom.minidom -import xmlrpclib +import six.moves.xmlrpc_client import zipfile import copy import Cheetah.Template -from ConfigParser import ConfigParser +from six.moves.configparser import ConfigParser from fnmatch import fnmatch from gzip import GzipFile from optparse import OptionParser, SUPPRESS_HELP @@ -1976,7 +1976,7 @@ class ChainMavenTask(MultiPlatformTask): del todo[package] try: results = self.wait(running.keys()) - except (xmlrpclib.Fault, koji.GenericError), e: + except (six.moves.xmlrpc_client.Fault, koji.GenericError), e: # One task has failed, wait for the rest to complete before the # chainmaven task fails. self.wait(all=True) should thrown an exception. self.wait(all=True) @@ -5633,7 +5633,7 @@ if __name__ == "__main__": options.serverca) except koji.AuthError, e: quit("Error: Unable to log in: %s" % e) - except xmlrpclib.ProtocolError: + except six.moves.xmlrpc_client.ProtocolError: quit("Error: Unable to connect to server %s" % (options.server)) elif options.user: try: @@ -5641,7 +5641,7 @@ if __name__ == "__main__": session.login() except koji.AuthError: quit("Error: Unable to log in. Bad credentials?") - except xmlrpclib.ProtocolError: + except six.moves.xmlrpc_client.ProtocolError: quit("Error: Unable to connect to server %s" % (options.server)) elif 'krbV' in sys.modules: krb_principal = options.krb_principal @@ -5667,7 +5667,7 @@ if __name__ == "__main__": #make sure it works try: ret = session.echo("OK") - except xmlrpclib.ProtocolError: + except six.moves.xmlrpc_client.ProtocolError: quit("Error: Unable to connect to server %s" % (options.server)) if ret != ["OK"]: quit("Error: incorrect server response: %r" % (ret)) diff --git a/cli/koji b/cli/koji index 63de79d..b0b88ae 100755 --- a/cli/koji +++ b/cli/koji @@ -43,7 +43,7 @@ except ImportError: # pragma: no cover import simplejson as json except ImportError: json = None -import ConfigParser +import six.moves.configparser import base64 import dateutil.parser import errno @@ -63,7 +63,7 @@ import time import traceback import urlgrabber.grabber as grabber import urlgrabber.progress as progress -import xmlrpclib +import six.moves.xmlrpc_client try: import libcomps except ImportError: # pragma: no cover @@ -278,7 +278,7 @@ def get_options(): def ensure_connection(session): try: ret = session.getAPIVersion() - except xmlrpclib.ProtocolError: + except six.moves.xmlrpc_client.ProtocolError: error(_("Error: Unable to connect to server")) if ret != koji.API_VERSION: warn(_("WARNING: The server is at API version %d and the client is at %d" % (ret, koji.API_VERSION))) @@ -342,7 +342,7 @@ class TaskWatcher(object): error = None try: result = self.session.getTaskResult(self.id) - except (xmlrpclib.Fault,koji.GenericError),e: + except (six.moves.xmlrpc_client.Fault,koji.GenericError),e: error = e if error is None: # print("%s: complete" % self.str()) @@ -5917,7 +5917,7 @@ def handle_image_build(options, session, args): if not os.path.exists(task_options.config): parser.error(_("%s not found!" % task_options.config)) section = 'image-build' - config = ConfigParser.ConfigParser() + config = six.moves.configparser.ConfigParser() conf_fd = open(task_options.config) config.readfp(conf_fd) conf_fd.close() diff --git a/hub/kojihub.py b/hub/kojihub.py index 63c28ed..581b002 100644 --- a/hub/kojihub.py +++ b/hub/kojihub.py @@ -54,7 +54,7 @@ import tarfile import tempfile import time import types -import xmlrpclib +import six.moves.xmlrpc_client import zipfile from koji.context import context from six.moves import range @@ -401,7 +401,7 @@ class Task(object): if xml_request.find(' from __future__ import absolute_import -from ConfigParser import RawConfigParser +from six.moves.configparser import RawConfigParser import datetime import inspect import logging @@ -30,8 +30,8 @@ import traceback import types import pprint import resource -import xmlrpclib -from xmlrpclib import getparser, dumps, Fault +import six.moves.xmlrpc_client +from six.moves.xmlrpc_client import getparser, dumps, Fault from koji.server import WSGIWrapper import koji @@ -45,9 +45,9 @@ from six.moves import range # Workaround to allow xmlrpclib deal with iterators -class Marshaller(xmlrpclib.Marshaller): +class Marshaller(six.moves.xmlrpc_client.Marshaller): - dispatch = xmlrpclib.Marshaller.dispatch.copy() + dispatch = six.moves.xmlrpc_client.Marshaller.dispatch.copy() def dump_generator(self, value, write): dump = self.__dump @@ -63,7 +63,7 @@ class Marshaller(xmlrpclib.Marshaller): self.dump_string(value, write) dispatch[datetime.datetime] = dump_datetime -xmlrpclib.Marshaller = Marshaller +six.moves.xmlrpc_client.Marshaller = Marshaller class HandlerRegistry(object): diff --git a/koji/__init__.py b/koji/__init__.py index 131f99b..2f8c4b0 100644 --- a/koji/__init__.py +++ b/koji/__init__.py @@ -33,11 +33,11 @@ except ImportError: # pragma: no cover sys.stderr.flush() import base64 import datetime -import ConfigParser +import six.moves.configparser import errno import exceptions from fnmatch import fnmatch -import httplib +import six.moves.http_client import imp import logging import logging.handlers @@ -78,10 +78,10 @@ import urllib2 import urlparse from . import util import warnings -import xmlrpclib +import six.moves.xmlrpc_client import xml.sax import xml.sax.handler -from xmlrpclib import loads, dumps, Fault +from six.moves.xmlrpc_client import loads, dumps, Fault PROFILE_MODULES = {} # {module_name: module_instance} @@ -1663,7 +1663,7 @@ def read_config(profile_name, user_config=None): got_conf = False for configFile in configs: f = open(configFile) - config = ConfigParser.ConfigParser() + config = six.moves.configparser.ConfigParser() config.readfp(f) f.close() if config.has_section(profile_name): @@ -1946,7 +1946,7 @@ def is_conn_error(e): return True # else return False - if isinstance(e, httplib.BadStatusLine): + if isinstance(e, six.moves.http_client.BadStatusLine): return True if requests is not None: try: @@ -1956,7 +1956,7 @@ def is_conn_error(e): e2 = getattr(e, 'args', [None])[0] if isinstance(e2, requests.packages.urllib3.exceptions.ProtocolError): e3 = getattr(e2, 'args', [None, None])[1] - if isinstance(e3, httplib.BadStatusLine): + if isinstance(e3, six.moves.http_client.BadStatusLine): return True if isinstance(e2, socket.error): # same check as unwrapped socket error @@ -2368,7 +2368,7 @@ class ClientSession(object): return ret def _read_xmlrpc_response(self, response): - p, u = xmlrpclib.getparser() + p, u = six.moves.xmlrpc_client.getparser() for chunk in response.iter_content(8192): if self.opts.get('debug_xmlrpc', False): print("body: %r" % chunk) diff --git a/koji/compatrequests.py b/koji/compatrequests.py index d56f0f2..be04a5b 100644 --- a/koji/compatrequests.py +++ b/koji/compatrequests.py @@ -7,7 +7,7 @@ module that is based on the older codepaths in koji. It only provides the bits that koji needs. """ -import httplib +import six.moves.http_client import urlparse import urllib import sys @@ -84,11 +84,11 @@ class Session(object): # no verify ctx = pyssl._create_unverified_context() cnxOpts['context'] = ctx - cnxClass = httplib.HTTPSConnection + cnxClass = six.moves.http_client.HTTPSConnection default_port = 443 elif scheme == 'http': cnxOpts = {} - cnxClass = httplib.HTTPConnection + cnxClass = six.moves.http_client.HTTPConnection else: raise IOError("unsupported protocol: %s" % scheme) @@ -123,7 +123,7 @@ class Response(object): def raise_for_status(self): if self.response.status >= 400: - raise httplib.HTTPException("HTTP %s: %s" % (self.response.status, + raise six.moves.http_client.HTTPException("HTTP %s: %s" % (self.response.status, self.response.reason)) diff --git a/koji/context.py b/koji/context.py index 03e22ed..ef35a21 100755 --- a/koji/context.py +++ b/koji/context.py @@ -25,7 +25,7 @@ # - auth data from __future__ import absolute_import -import thread +import six.moves._thread from six.moves import range class _data(object): @@ -37,7 +37,7 @@ class ThreadLocal(object): # should probably be getattribute, but easier to debug this way def __getattr__(self, key): - id = thread.get_ident() + id = six.moves._thread.get_ident() tdict = object.__getattribute__(self, '_tdict') if id not in tdict: raise AttributeError(key) @@ -45,7 +45,7 @@ class ThreadLocal(object): return object.__getattribute__(data, key) def __setattr__(self, key, value): - id = thread.get_ident() + id = six.moves._thread.get_ident() tdict = object.__getattribute__(self, '_tdict') if id not in tdict: tdict[id] = _data() @@ -53,7 +53,7 @@ class ThreadLocal(object): return object.__setattr__(data, key, value) def __delattr__(self, key): - id = thread.get_ident() + id = six.moves._thread.get_ident() tdict = object.__getattribute__(self, '_tdict') if id not in tdict: raise AttributeError(key) @@ -64,14 +64,14 @@ class ThreadLocal(object): return ret def __str__(self): - id = thread.get_ident() + id = six.moves._thread.get_ident() tdict = object.__getattribute__(self, '_tdict') return "(current thread: %s) {" % id + \ ", ".join(["%s : %s" %(k, v.__dict__) for (k, v) in tdict.iteritems()]) + \ "}" def _threadclear(self): - id = thread.get_ident() + id = six.moves._thread.get_ident() tdict = object.__getattribute__(self, '_tdict') if id not in tdict: return @@ -100,7 +100,7 @@ if __name__ == '__main__': print(context) for x in range(1, 10): - thread.start_new_thread(test, ()) + six.moves._thread.start_new_thread(test, ()) time.sleep(4) print('') diff --git a/koji/daemon.py b/koji/daemon.py index c432c8b..b9a6e29 100644 --- a/koji/daemon.py +++ b/koji/daemon.py @@ -35,7 +35,7 @@ import time import sys import traceback import errno -import xmlrpclib +import six.moves.xmlrpc_client from six.moves import range @@ -1161,12 +1161,12 @@ class TaskManager(object): try: response = (handler.run(),) # note that we wrap response in a singleton tuple - response = xmlrpclib.dumps(response, methodresponse=1, allow_none=1) + response = six.moves.xmlrpc_client.dumps(response, methodresponse=1, allow_none=1) self.logger.info("RESPONSE: %r" % response) self.session.host.closeTask(handler.id, response) return - except xmlrpclib.Fault, fault: - response = xmlrpclib.dumps(fault) + except six.moves.xmlrpc_client.Fault, fault: + response = six.moves.xmlrpc_client.dumps(fault) tb = ''.join(traceback.format_exception(*sys.exc_info())).replace(r"\n", "\n") self.logger.warn("FAULT:\n%s" % tb) except (SystemExit, koji.tasks.ServerExit, KeyboardInterrupt): @@ -1185,7 +1185,7 @@ class TaskManager(object): if issubclass(e_class, koji.GenericError): #just pass it through tb = str(e) - response = xmlrpclib.dumps(xmlrpclib.Fault(faultCode, tb)) + response = six.moves.xmlrpc_client.dumps(six.moves.xmlrpc_client.Fault(faultCode, tb)) # if we get here, then we're handling an exception, so fail the task self.session.host.failTask(handler.id, response) diff --git a/koji/ssl/SSLCommon.py b/koji/ssl/SSLCommon.py index a1ab2bb..cbecedf 100644 --- a/koji/ssl/SSLCommon.py +++ b/koji/ssl/SSLCommon.py @@ -17,7 +17,7 @@ import os, sys from OpenSSL import SSL import SSLConnection -import httplib +import six.moves.http_client import socket def our_verify(connection, x509, errNum, errDepth, preverifyOK): @@ -46,13 +46,13 @@ def CreateSSLContext(certs): return ctx -class PlgHTTPSConnection(httplib.HTTPConnection): +class PlgHTTPSConnection(six.moves.http_client.HTTPConnection): "This class allows communication via SSL." - response_class = httplib.HTTPResponse + response_class = six.moves.http_client.HTTPResponse def __init__(self, host, port=None, ssl_context=None, strict=None, timeout=None): - httplib.HTTPConnection.__init__(self, host, port, strict) + six.moves.http_client.HTTPConnection.__init__(self, host, port, strict) self.ssl_ctx = ssl_context self._timeout = timeout diff --git a/koji/tasks.py b/koji/tasks.py index 05efca2..c2ac916 100644 --- a/koji/tasks.py +++ b/koji/tasks.py @@ -25,7 +25,7 @@ import koji import koji.util import os import logging -import xmlrpclib +import six.moves.xmlrpc_client import signal import urllib2 import shutil @@ -236,7 +236,7 @@ class BaseTaskHandler(object): continue try: self.session.getTaskResult(task) - except (koji.GenericError, xmlrpclib.Fault), task_error: + except (koji.GenericError, six.moves.xmlrpc_client.Fault), task_error: self.logger.info("task %s failed or was canceled" % task) failed = True break diff --git a/koji/util.py b/koji/util.py index 5a3c7b9..9fce070 100644 --- a/koji/util.py +++ b/koji/util.py @@ -31,7 +31,7 @@ import shutil import stat import sys import time -import ConfigParser +import six.moves.configparser from zlib import adler32 from six.moves import range @@ -588,7 +588,7 @@ def parse_maven_params(confs, chain=False, scratch=False): """ if not isinstance(confs, (list, tuple)): confs = [confs] - config = ConfigParser.ConfigParser() + config = six.moves.configparser.ConfigParser() for conf in confs: conf_fd = file(conf) config.readfp(conf_fd) diff --git a/plugins/builder/runroot.py b/plugins/builder/runroot.py index fe23bd0..f902659 100644 --- a/plugins/builder/runroot.py +++ b/plugins/builder/runroot.py @@ -2,7 +2,7 @@ import commands import koji -import ConfigParser +import six.moves.configparser import os import platform compat_mode = False @@ -56,7 +56,7 @@ class RunRootTask(tasks.BaseTaskHandler): return res def _read_config(self): - cp = ConfigParser.SafeConfigParser() + cp = six.moves.configparser.SafeConfigParser() cp.read(CONFIG_FILE) self.config = { 'default_mounts': [], @@ -84,7 +84,7 @@ class RunRootTask(tasks.BaseTaskHandler): 'fstype': cp.get(section_name, 'fstype'), 'options': cp.get(section_name, 'options'), }) - except ConfigParser.NoOptionError: + except six.moves.configparser.NoOptionError: raise koji.GenericError("bad config: missing options in %s section" % section_name) count += 1 diff --git a/plugins/builder/save_failed_tree.py b/plugins/builder/save_failed_tree.py index 138572f..0292382 100644 --- a/plugins/builder/save_failed_tree.py +++ b/plugins/builder/save_failed_tree.py @@ -1,7 +1,7 @@ import fnmatch import os import tarfile -import ConfigParser +import six.moves.configparser import koji import koji.tasks as tasks @@ -22,7 +22,7 @@ def omit_paths(tarinfo): def read_config(): global config - cp = ConfigParser.SafeConfigParser() + cp = six.moves.configparser.SafeConfigParser() cp.read(CONFIG_FILE) config = { 'path_filters': [], diff --git a/plugins/hub/messagebus.py b/plugins/hub/messagebus.py index 10c8b00..5bb2b01 100644 --- a/plugins/hub/messagebus.py +++ b/plugins/hub/messagebus.py @@ -6,7 +6,7 @@ from koji import PluginError from koji.plugin import callbacks, callback, ignore_error -import ConfigParser +import six.moves.configparser import logging import qpid.messaging import qpid.messaging.transports @@ -78,7 +78,7 @@ def get_sender(): session = None target = None - config = ConfigParser.SafeConfigParser() + config = six.moves.configparser.SafeConfigParser() config.read(CONFIG_FILE) if not config.has_option('broker', 'timeout'): config.set('broker', 'timeout', '60') diff --git a/plugins/hub/protonmsg.py b/plugins/hub/protonmsg.py index cf3a82c..0a65c4e 100644 --- a/plugins/hub/protonmsg.py +++ b/plugins/hub/protonmsg.py @@ -8,7 +8,7 @@ import koji from koji.plugin import callback, ignore_error from koji.context import context -import ConfigParser +import six.moves.configparser import logging import json import random @@ -246,7 +246,7 @@ def send_queued_msgs(cbtype, *args, **kws): log = logging.getLogger('koji.plugin.protonmsg') global CONFIG if not CONFIG: - conf = ConfigParser.SafeConfigParser() + conf = six.moves.configparser.SafeConfigParser() with open(CONFIG_FILE) as conffile: conf.readfp(conffile) CONFIG = conf diff --git a/plugins/hub/rpm2maven.py b/plugins/hub/rpm2maven.py index b1310ea..1a9b399 100644 --- a/plugins/hub/rpm2maven.py +++ b/plugins/hub/rpm2maven.py @@ -8,7 +8,7 @@ import koji from koji.context import context from koji.plugin import callback -import ConfigParser +import six.moves.configparser import fnmatch import os import shutil @@ -30,7 +30,7 @@ def maven_import(cbtype, *args, **kws): filepath = kws['filepath'] if not config: - config = ConfigParser.SafeConfigParser() + config = six.moves.configparser.SafeConfigParser() config.read(CONFIG_FILE) name_patterns = config.get('patterns', 'rpm_names').split() for pattern in name_patterns: diff --git a/plugins/hub/save_failed_tree.py b/plugins/hub/save_failed_tree.py index 3a98128..70caa26 100644 --- a/plugins/hub/save_failed_tree.py +++ b/plugins/hub/save_failed_tree.py @@ -1,5 +1,5 @@ import sys -import ConfigParser +import six.moves.configparser import koji from koji.context import context from koji.plugin import export @@ -28,7 +28,7 @@ def saveFailedTree(buildrootID, full=False, **opts): # read configuration only once if config is None: - config = ConfigParser.SafeConfigParser() + config = six.moves.configparser.SafeConfigParser() config.read(CONFIG_FILE) allowed_methods = config.get('permissions', 'allowed_methods').split() if len(allowed_methods) == 1 and allowed_methods[0] == '*': diff --git a/tests/test_compatrequests.py b/tests/test_compatrequests.py index c67f585..6a684ef 100644 --- a/tests/test_compatrequests.py +++ b/tests/test_compatrequests.py @@ -1,4 +1,4 @@ -import httplib +import six.moves.http_client import mock import unittest import urlparse @@ -59,7 +59,7 @@ class TestResponse(unittest.TestCase): self.response.response.status = 404 self.response.response.reason = 'Not Found' self.response.response.getheader.return_value = 42 - with self.assertRaises(httplib.HTTPException): + with self.assertRaises(six.moves.http_client.HTTPException): self.response.raise_for_status() diff --git a/tests/test_plugins/test_protonmsg.py b/tests/test_plugins/test_protonmsg.py index 02583b7..108be2e 100644 --- a/tests/test_plugins/test_protonmsg.py +++ b/tests/test_plugins/test_protonmsg.py @@ -4,7 +4,7 @@ import protonmsg from koji.context import context import tempfile from StringIO import StringIO -from ConfigParser import SafeConfigParser +from six.moves.configparser import SafeConfigParser class TestProtonMsg(unittest.TestCase): def tearDown(self): diff --git a/tests/test_plugins/test_runroot_builder.py b/tests/test_plugins/test_runroot_builder.py index e841d98..910c783 100644 --- a/tests/test_plugins/test_runroot_builder.py +++ b/tests/test_plugins/test_runroot_builder.py @@ -1,6 +1,6 @@ import unittest import mock -import ConfigParser +import six.moves.configparser # inject builder data from tests.test_builder.loadkojid import kojid @@ -40,7 +40,7 @@ class FakeConfigParser(object): try: return self.CONFIG[section][key] except KeyError: - raise ConfigParser.NoOptionError(section, key) + raise six.moves.configparser.NoOptionError(section, key) class TestRunrootConfig(unittest.TestCase): diff --git a/tests/test_utils.py b/tests/test_utils.py index 88cd1aa..ac533c1 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -4,7 +4,7 @@ from mock import call import os import optparse -import ConfigParser +import six.moves.configparser import koji import koji.util @@ -473,7 +473,7 @@ class MavenUtilTestCase(unittest.TestCase): self.assertEqual(cm.exception.args[0], 'total ordering not possible') def _read_conf(self, cfile): - config = ConfigParser.ConfigParser() + config = six.moves.configparser.ConfigParser() path = os.path.dirname(__file__) with open(path + cfile, 'r') as conf_file: config.readfp(conf_file) diff --git a/util/koji-gc b/util/koji-gc index 5fb1e23..fb29d54 100755 --- a/util/koji-gc +++ b/util/koji-gc @@ -15,7 +15,7 @@ except ImportError: # pragma: no cover import koji from koji.util import LazyDict, LazyValue import koji.policy -import ConfigParser +import six.moves.configparser from email.MIMEText import MIMEText import fnmatch import optparse @@ -25,7 +25,7 @@ import smtplib import socket # for socket.error import sys import time -import xmlrpclib # for ProtocolError and Fault +import six.moves.xmlrpc_client # for ProtocolError and Fault OptionParser = optparse.OptionParser @@ -114,7 +114,7 @@ def get_options(): defaults = parser.get_default_values() - config = ConfigParser.ConfigParser() + config = six.moves.configparser.ConfigParser() cf = getattr(options, 'config_file', None) if cf: if not os.access(cf, os.F_OK): @@ -339,7 +339,7 @@ def warn(msg): def ensure_connection(session): try: ret = session.getAPIVersion() - except xmlrpclib.ProtocolError: + except six.moves.xmlrpc_client.ProtocolError: error(_("Error: Unable to connect to server")) if ret != koji.API_VERSION: warn(_("WARNING: The server is at API version %d and the client is at %d" % (ret, koji.API_VERSION))) @@ -454,7 +454,7 @@ def handle_trash(): continue try: refs = session.buildReferences(binfo['id'], limit=10) - except xmlrpclib.Fault: + except six.moves.xmlrpc_client.Fault: print("[%i/%i] Error checking references for %s. Skipping" % (i, N, nvr)) continue #XXX - this is more data than we need @@ -656,7 +656,7 @@ def handle_delete(just_salvage=False): session.untagBuildBypass(trashcan_tag, binfo['id']) try: session.deleteBuild(binfo['id']) - except (xmlrpclib.Fault, koji.GenericError), e: + except (six.moves.xmlrpc_client.Fault, koji.GenericError), e: print("Warning: deletion failed: %s" % e) #server issue pass @@ -875,7 +875,7 @@ def handle_prune(): try: session.untagBuildBypass(taginfo['id'], entry['build_id'], force=bypass) untagged.setdefault(nvr, {})[tagname] = 1 - except (xmlrpclib.Fault, koji.GenericError), e: + except (six.moves.xmlrpc_client.Fault, koji.GenericError), e: print("Warning: untag operation failed: %s" % e) pass # if action == 'keep' do nothing @@ -909,7 +909,7 @@ def handle_prune(): print("Deleting untagged build: %s" % nvr) try: session.deleteBuild(build_id, strict=False) - except (xmlrpclib.Fault, koji.GenericError), e: + except (six.moves.xmlrpc_client.Fault, koji.GenericError), e: print("Warning: deletion failed: %s" % e) #server issue pass diff --git a/util/koji-shadow b/util/koji-shadow index a951771..d17f01c 100755 --- a/util/koji-shadow +++ b/util/koji-shadow @@ -30,7 +30,7 @@ try: except ImportError: # pragma: no cover pass import koji -import ConfigParser +import six.moves.configparser import fnmatch import optparse import os @@ -43,7 +43,7 @@ import sys import time import urllib2 import urlgrabber.grabber as grabber -import xmlrpclib # for ProtocolError and Fault +import six.moves.xmlrpc_client # for ProtocolError and Fault import rpm # koji.fp.o keeps stalling, probably network errors... @@ -163,7 +163,7 @@ def get_options(): (options, args) = parser.parse_args() defaults = parser.get_default_values() - config = ConfigParser.ConfigParser() + config = six.moves.configparser.ConfigParser() cf = getattr(options, 'config_file', None) if cf: if not os.access(cf, os.F_OK): @@ -299,7 +299,7 @@ def warn(msg): def ensure_connection(session): try: ret = session.getAPIVersion() - except xmlrpclib.ProtocolError: + except six.moves.xmlrpc_client.ProtocolError: error(_("Error: Unable to connect to server")) if ret != koji.API_VERSION: warn(_("WARNING: The server is at API version %d and the client is at " diff --git a/util/kojira b/util/kojira index 4a21332..c09c40b 100755 --- a/util/kojira +++ b/util/kojira @@ -29,7 +29,7 @@ import os import koji from koji.util import rmtree, parseStatus from optparse import OptionParser -from ConfigParser import ConfigParser +from six.moves.configparser import ConfigParser import errno import fnmatch import logging diff --git a/vm/kojikamid.py b/vm/kojikamid.py index 0499c74..87a8608 100755 --- a/vm/kojikamid.py +++ b/vm/kojikamid.py @@ -27,13 +27,13 @@ # in a cygwin shell. from optparse import OptionParser -from ConfigParser import ConfigParser +from six.moves.configparser import ConfigParser import os import subprocess import sys import tempfile import time -import xmlrpclib +import six.moves.xmlrpc_client import base64 import hashlib import logging @@ -586,13 +586,13 @@ def get_mgmt_server(): macaddr, gateway = find_net_info() logger.debug('found MAC address %s, connecting to %s:%s', macaddr, gateway, MANAGER_PORT) - server = xmlrpclib.ServerProxy('http://%s:%s/' % + server = six.moves.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 xmlrpclib.ServerProxy('http://%s:%s/' % (gateway, task_port), allow_none=True) + return six.moves.xmlrpc_client.ServerProxy('http://%s:%s/' % (gateway, task_port), allow_none=True) def get_options(): """handle usage and parse options""" diff --git a/www/kojiweb/index.py b/www/kojiweb/index.py index 9b03499..a7d8b74 100644 --- a/www/kojiweb/index.py +++ b/www/kojiweb/index.py @@ -26,7 +26,7 @@ import os.path import re import sys import mimetypes -import Cookie +import six.moves.http_cookies import datetime import logging import time @@ -56,7 +56,7 @@ def _setUserCookie(environ, user): shasum = sha1_constructor(value) shasum.update(options['Secret'].value) value = "%s:%s" % (shasum.hexdigest(), value) - cookies = Cookie.SimpleCookie() + cookies = six.moves.http_cookies.SimpleCookie() cookies['user'] = value c = cookies['user'] #morsel instance c['secure'] = True @@ -69,7 +69,7 @@ def _setUserCookie(environ, user): environ['koji.headers'].append(['Cache-Control', 'no-cache="set-cookie"']) def _clearUserCookie(environ): - cookies = Cookie.SimpleCookie() + cookies = six.moves.http_cookies.SimpleCookie() cookies['user'] = '' c = cookies['user'] #morsel instance c['path'] = os.path.dirname(environ['SCRIPT_NAME']) @@ -79,7 +79,7 @@ def _clearUserCookie(environ): def _getUserCookie(environ): options = environ['koji.options'] - cookies = Cookie.SimpleCookie(environ.get('HTTP_COOKIE', '')) + cookies = six.moves.http_cookies.SimpleCookie(environ.get('HTTP_COOKIE', '')) if 'user' not in cookies: return None value = cookies['user'].value diff --git a/www/kojiweb/wsgi_publisher.py b/www/kojiweb/wsgi_publisher.py index e2d427b..9bbb40b 100644 --- a/www/kojiweb/wsgi_publisher.py +++ b/www/kojiweb/wsgi_publisher.py @@ -29,7 +29,7 @@ import pprint import sys import traceback -from ConfigParser import RawConfigParser +from six.moves.configparser import RawConfigParser from koji.server import WSGIWrapper, ServerError, ServerRedirect from koji.util import dslice diff --git a/www/lib/kojiweb/util.py b/www/lib/kojiweb/util.py index 3d5212f..dd48295 100644 --- a/www/lib/kojiweb/util.py +++ b/www/lib/kojiweb/util.py @@ -30,7 +30,7 @@ import stat #a bunch of exception classes that explainError needs from socket import error as socket_error from socket import sslerror as socket_sslerror -from xmlrpclib import ProtocolError +from six.moves.xmlrpc_client import ProtocolError from xml.parsers.expat import ExpatError import cgi from six.moves import range