python-modernize -f libmodernize.fixes.fix_imports_six

This commit is contained in:
Tomas Kopecek 2017-05-03 11:32:38 +02:00
parent 73356b50e5
commit b1da150c01
28 changed files with 101 additions and 101 deletions

View file

@ -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)
@ -5635,7 +5635,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:
@ -5643,7 +5643,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
@ -5669,7 +5669,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))

View file

@ -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()

View file

@ -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('<?xml', 0, 10) == -1:
#handle older base64 encoded data
xml_request = base64.decodestring(xml_request)
params, method = xmlrpclib.loads(xml_request)
params, method = six.moves.xmlrpc_client.loads(xml_request)
return params
def getResult(self, raise_fault=True):
@ -420,8 +420,8 @@ class Task(object):
try:
# If the result is a Fault, then loads will raise it
# This is normally what we want to happen
result, method = xmlrpclib.loads(xml_result)
except xmlrpclib.Fault, fault:
result, method = six.moves.xmlrpc_client.loads(xml_result)
except six.moves.xmlrpc_client.Fault, fault:
if raise_fault:
raise
# Note that you can't really return a fault over xmlrpc, except by
@ -452,7 +452,7 @@ class Task(object):
if task['request'].find('<?xml', 0, 10) == -1:
#handle older base64 encoded data
task['request'] = base64.decodestring(task['request'])
task['request'] = xmlrpclib.loads(task['request'])[0]
task['request'] = six.moves.xmlrpc_client.loads(task['request'])[0]
return results
def runCallbacks(self, cbtype, old_info, attr, new_val):
@ -563,7 +563,7 @@ def make_task(method, arglist, **opts):
raise koji.GenericError("invalid channel policy")
# encode xmlrpc request
opts['request'] = xmlrpclib.dumps(tuple(arglist), methodname=method,
opts['request'] = six.moves.xmlrpc_client.dumps(tuple(arglist), methodname=method,
allow_none=1)
opts['state'] = koji.TASK_STATES['FREE']
opts['method'] = method
@ -10386,8 +10386,8 @@ class RootExports(object):
if val.find('<?xml', 0, 10) == -1:
#handle older base64 encoded data
val = base64.decodestring(val)
data, method = xmlrpclib.loads(val)
except xmlrpclib.Fault, fault:
data, method = six.moves.xmlrpc_client.loads(val)
except six.moves.xmlrpc_client.Fault, fault:
data = fault
task[f] = data
yield task
@ -10622,7 +10622,7 @@ class RootExports(object):
buildinfo = get_build(build)
if not buildinfo:
raise koji.GenericError('build does not exist: %s' % build)
elif isinstance(ts, xmlrpclib.DateTime):
elif isinstance(ts, six.moves.xmlrpc_client.DateTime):
#not recommended
#the xmlrpclib.DateTime class is almost useless
try:

View file

@ -19,7 +19,7 @@
# Mike McLean <mikem@redhat.com>
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):

View file

@ -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)

View file

@ -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))

View file

@ -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('')

View file

@ -35,7 +35,7 @@ import time
import sys
import traceback
import errno
import xmlrpclib
import six.moves.xmlrpc_client
from six.moves import range
@ -1190,12 +1190,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):
@ -1214,7 +1214,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)

View file

@ -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

View file

@ -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
@ -240,7 +240,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

View file

@ -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)

View file

@ -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

View file

@ -2,7 +2,7 @@ import fnmatch
import os
import sys
import tarfile
import ConfigParser
import six.moves.configparser
import koji
import koji.tasks as tasks
@ -27,7 +27,7 @@ def omit_paths3(tarinfo):
def read_config():
global config
cp = ConfigParser.SafeConfigParser()
cp = six.moves.configparser.SafeConfigParser()
cp.read(CONFIG_FILE)
config = {
'path_filters': [],

View file

@ -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')

View file

@ -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

View file

@ -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:

View file

@ -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] == '*':

View file

@ -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()

View file

@ -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):

View file

@ -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):

View file

@ -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)

View file

@ -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

View file

@ -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 "

View file

@ -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

View file

@ -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"""

View file

@ -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

View file

@ -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

View file

@ -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