python-modernize -f libmodernize.fixes.fix_imports_six
This commit is contained in:
parent
f03646bab5
commit
be535c2854
21 changed files with 81 additions and 81 deletions
|
|
@ -55,11 +55,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
|
||||
|
|
@ -2100,7 +2100,7 @@ class ChainMavenTask(MultiPlatformTask):
|
|||
del todo[package]
|
||||
try:
|
||||
results = self.wait(list(running.keys()))
|
||||
except (xmlrpclib.Fault, koji.GenericError) as e:
|
||||
except (six.moves.xmlrpc_client.Fault, koji.GenericError) as 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)
|
||||
|
|
@ -5915,7 +5915,7 @@ if __name__ == "__main__":
|
|||
options.serverca)
|
||||
except koji.AuthError as 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:
|
||||
|
|
@ -5923,7 +5923,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:
|
||||
krb_principal = options.krb_principal
|
||||
|
|
@ -5949,7 +5949,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))
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ import tempfile
|
|||
import time
|
||||
import traceback
|
||||
import urlparse
|
||||
import xmlrpclib
|
||||
import six.moves.xmlrpc_client
|
||||
import zipfile
|
||||
|
||||
import rpm
|
||||
|
|
@ -397,7 +397,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):
|
||||
|
|
@ -416,8 +416,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 as fault:
|
||||
result, method = six.moves.xmlrpc_client.loads(xml_result)
|
||||
except six.moves.xmlrpc_client.Fault as fault:
|
||||
if raise_fault:
|
||||
raise
|
||||
# Note that you can't really return a fault over xmlrpc, except by
|
||||
|
|
@ -448,7 +448,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):
|
||||
|
|
@ -10628,8 +10628,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 as fault:
|
||||
data, method = six.moves.xmlrpc_client.loads(val)
|
||||
except six.moves.xmlrpc_client.Fault as fault:
|
||||
data = fault
|
||||
task[f] = data
|
||||
yield task
|
||||
|
|
@ -10889,7 +10889,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:
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
# - auth data
|
||||
|
||||
from __future__ import absolute_import
|
||||
import thread
|
||||
import six.moves._thread
|
||||
from six.moves import range
|
||||
import six
|
||||
|
||||
|
|
@ -38,7 +38,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)
|
||||
|
|
@ -46,7 +46,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()
|
||||
|
|
@ -54,7 +54,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)
|
||||
|
|
@ -65,14 +65,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 six.iteritems(tdict)]) + \
|
||||
"}"
|
||||
|
||||
def _threadclear(self):
|
||||
id = thread.get_ident()
|
||||
id = six.moves._thread.get_ident()
|
||||
tdict = object.__getattribute__(self, '_tdict')
|
||||
if id not in tdict:
|
||||
return
|
||||
|
|
@ -101,7 +101,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('')
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import koji.plugin
|
|||
import koji.util
|
||||
import os
|
||||
import logging
|
||||
import xmlrpclib
|
||||
import six.moves.xmlrpc_client
|
||||
import signal
|
||||
import shutil
|
||||
import random
|
||||
|
|
@ -392,7 +392,7 @@ class BaseTaskHandler(object):
|
|||
try:
|
||||
self.session.getTaskResult(task)
|
||||
checked.add(task)
|
||||
except (koji.GenericError, xmlrpclib.Fault):
|
||||
except (koji.GenericError, six.moves.xmlrpc_client.Fault):
|
||||
self.logger.info("task %s failed or was canceled, cancelling unfinished tasks" % task)
|
||||
self.session.cancelTaskChildren(self.id)
|
||||
# reraise the original error now, rather than waiting for
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
from __future__ import absolute_import
|
||||
import commands
|
||||
import koji
|
||||
import ConfigParser
|
||||
import six.moves.configparser
|
||||
import os
|
||||
import platform
|
||||
import re
|
||||
|
|
@ -49,7 +49,7 @@ class RunRootTask(koji.tasks.BaseTaskHandler):
|
|||
return res
|
||||
|
||||
def _read_config(self):
|
||||
cp = ConfigParser.SafeConfigParser()
|
||||
cp = six.moves.configparser.SafeConfigParser()
|
||||
cp.read(CONFIG_FILE)
|
||||
self.config = {
|
||||
'default_mounts': [],
|
||||
|
|
@ -90,7 +90,7 @@ class RunRootTask(koji.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)
|
||||
|
||||
for path in self.config['default_mounts'] + self.config['safe_roots'] + [x[0] for x in self.config['path_subs']]:
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import fnmatch
|
|||
import os
|
||||
import sys
|
||||
import tarfile
|
||||
import ConfigParser
|
||||
import six.moves.configparser
|
||||
|
||||
import koji
|
||||
import koji.tasks as tasks
|
||||
|
|
@ -28,7 +28,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': [],
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ from __future__ import absolute_import
|
|||
from koji import PluginError
|
||||
from koji.context import context
|
||||
from koji.plugin import callbacks, callback, ignore_error, convert_datetime
|
||||
import ConfigParser
|
||||
import six.moves.configparser
|
||||
import logging
|
||||
import qpid.messaging
|
||||
import qpid.messaging.transports
|
||||
|
|
@ -79,7 +79,7 @@ def get_config():
|
|||
if config:
|
||||
return config
|
||||
|
||||
config = ConfigParser.SafeConfigParser()
|
||||
config = six.moves.configparser.SafeConfigParser()
|
||||
config.read(CONFIG_FILE)
|
||||
if not config.has_option('broker', 'timeout'):
|
||||
config.set('broker', 'timeout', '60')
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ from __future__ import absolute_import
|
|||
import koji
|
||||
from koji.plugin import callback, ignore_error, convert_datetime
|
||||
from koji.context import context
|
||||
import ConfigParser
|
||||
import six.moves.configparser
|
||||
import logging
|
||||
import json
|
||||
import random
|
||||
|
|
@ -270,7 +270,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
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import koji
|
|||
from koji.context import context
|
||||
from koji.plugin import callback
|
||||
from koji.util import rmtree
|
||||
import ConfigParser
|
||||
import six.moves.configparser
|
||||
import fnmatch
|
||||
import os
|
||||
import shutil
|
||||
|
|
@ -32,7 +32,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:
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from __future__ import absolute_import
|
||||
import sys
|
||||
import ConfigParser
|
||||
import six.moves.configparser
|
||||
import koji
|
||||
from koji.context import context
|
||||
from koji.plugin import export
|
||||
|
|
@ -29,7 +29,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] == '*':
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from __future__ import absolute_import
|
||||
import mock
|
||||
import xmlrpclib
|
||||
import six.moves.xmlrpc_client
|
||||
try:
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
|
|
@ -66,8 +66,8 @@ class TestTaskWaitResults(unittest.TestCase):
|
|||
task = self.getTask(t)
|
||||
task.getResult.return_value = "OK"
|
||||
task.isCanceled.return_value = False
|
||||
self.tasks[6].getResult.side_effect = xmlrpclib.Fault(1, "error")
|
||||
with self.assertRaises(xmlrpclib.Fault):
|
||||
self.tasks[6].getResult.side_effect = six.moves.xmlrpc_client.Fault(1, "error")
|
||||
with self.assertRaises(six.moves.xmlrpc_client.Fault):
|
||||
results = self.host_exports.taskWaitResults(parent, task_ids)
|
||||
self.assertEqual(results, [])
|
||||
self.tasks[6].getResult.side_effect = koji.GenericError('problem')
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ except ImportError:
|
|||
|
||||
from mock import patch, MagicMock
|
||||
from koji.context import context
|
||||
from ConfigParser import SafeConfigParser
|
||||
from six.moves.configparser import SafeConfigParser
|
||||
|
||||
class TestProtonMsg(unittest.TestCase):
|
||||
def tearDown(self):
|
||||
|
|
|
|||
16
util/koji-gc
16
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
|
||||
|
|
@ -116,7 +116,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):
|
||||
|
|
@ -341,7 +341,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)))
|
||||
|
|
@ -456,7 +456,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
|
||||
|
|
@ -658,7 +658,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
|
||||
|
|
@ -877,7 +877,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
|
||||
|
|
@ -911,7 +911,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
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ try:
|
|||
except ImportError: # pragma: no cover
|
||||
krbV = None
|
||||
import koji
|
||||
import ConfigParser
|
||||
import six.moves.configparser
|
||||
import fnmatch
|
||||
import optparse
|
||||
import os
|
||||
|
|
@ -41,7 +41,7 @@ import string
|
|||
import sys
|
||||
import time
|
||||
import urllib2
|
||||
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 "
|
||||
|
|
|
|||
|
|
@ -26,7 +26,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 logging
|
||||
import logging.handlers
|
||||
|
|
|
|||
|
|
@ -28,13 +28,13 @@
|
|||
|
||||
from __future__ import absolute_import
|
||||
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
|
||||
|
|
@ -588,13 +588,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"""
|
||||
|
|
|
|||
34
vm/kojivmd
34
vm/kojivmd
|
|
@ -29,7 +29,7 @@ from koji.tasks import RestartTask, RestartVerifyTask
|
|||
import sys
|
||||
import logging
|
||||
import os
|
||||
import xmlrpclib
|
||||
import six.moves.xmlrpc_client
|
||||
import signal
|
||||
import time
|
||||
import subprocess
|
||||
|
|
@ -37,13 +37,13 @@ import libvirt
|
|||
import libxml2
|
||||
import random
|
||||
import socket
|
||||
import SimpleXMLRPCServer
|
||||
import six.moves.xmlrpc_server
|
||||
import threading
|
||||
import base64
|
||||
import pwd
|
||||
import requests
|
||||
import fnmatch
|
||||
from ConfigParser import ConfigParser
|
||||
from six.moves.configparser import ConfigParser
|
||||
from contextlib import closing
|
||||
from optparse import OptionParser
|
||||
try:
|
||||
|
|
@ -246,14 +246,14 @@ def main(options, session):
|
|||
# Tasks for handling VM lifecycle
|
||||
####################
|
||||
|
||||
class DaemonXMLRPCServer(SimpleXMLRPCServer.SimpleXMLRPCServer):
|
||||
class DaemonXMLRPCServer(six.moves.xmlrpc_server.SimpleXMLRPCServer):
|
||||
allow_reuse_address = True
|
||||
|
||||
def __init__(self, addr, port):
|
||||
if sys.version_info[:2] <= (2, 4):
|
||||
SimpleXMLRPCServer.SimpleXMLRPCServer.__init__(self, (addr, port), logRequests=False)
|
||||
six.moves.xmlrpc_server.SimpleXMLRPCServer.__init__(self, (addr, port), logRequests=False)
|
||||
else:
|
||||
SimpleXMLRPCServer.SimpleXMLRPCServer.__init__(self, (addr, port), logRequests=False,
|
||||
six.moves.xmlrpc_server.SimpleXMLRPCServer.__init__(self, (addr, port), logRequests=False,
|
||||
allow_none=True)
|
||||
self.logger = logging.getLogger('koji.vm.DaemonXMLRPCServer')
|
||||
self.socket.settimeout(5)
|
||||
|
|
@ -261,7 +261,7 @@ class DaemonXMLRPCServer(SimpleXMLRPCServer.SimpleXMLRPCServer):
|
|||
|
||||
def server_close(self):
|
||||
self.active = False
|
||||
SimpleXMLRPCServer.SimpleXMLRPCServer.server_close(self)
|
||||
six.moves.xmlrpc_server.SimpleXMLRPCServer.server_close(self)
|
||||
|
||||
def handle_while_active(self):
|
||||
while self.active:
|
||||
|
|
@ -282,20 +282,20 @@ class DaemonXMLRPCServer(SimpleXMLRPCServer.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 = xmlrpclib.loads(data)
|
||||
params, method = six.moves.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 = xmlrpclib.dumps(response, methodresponse=1, allow_none=True)
|
||||
except xmlrpclib.Fault, fault:
|
||||
response = xmlrpclib.dumps(fault)
|
||||
response = six.moves.xmlrpc_client.dumps(response, methodresponse=1, allow_none=True)
|
||||
except six.moves.xmlrpc_client.Fault, fault:
|
||||
response = six.moves.xmlrpc_client.dumps(fault)
|
||||
except:
|
||||
# report exception back to server
|
||||
response = xmlrpclib.dumps(
|
||||
xmlrpclib.Fault(1, "%s:%s" % (sys.exc_type, sys.exc_value))
|
||||
response = six.moves.xmlrpc_client.dumps(
|
||||
six.moves.xmlrpc_client.Fault(1, "%s:%s" % (sys.exc_type, sys.exc_value))
|
||||
)
|
||||
return response
|
||||
|
||||
|
|
@ -417,7 +417,7 @@ class VMExecTask(BaseTaskHandler):
|
|||
|
||||
def __init__(self, *args, **kw):
|
||||
super(VMExecTask, self).__init__(*args, **kw)
|
||||
self.task_manager = xmlrpclib.ServerProxy('http://%s:%s/' % (self.options.privaddr, self.options.portbase),
|
||||
self.task_manager = six.moves.xmlrpc_client.ServerProxy('http://%s:%s/' % (self.options.privaddr, self.options.portbase),
|
||||
allow_none=True)
|
||||
self.port = None
|
||||
self.server = None
|
||||
|
|
@ -1090,7 +1090,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:
|
||||
|
|
@ -1098,7 +1098,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:
|
||||
krb_principal = options.krb_principal
|
||||
|
|
@ -1124,7 +1124,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))
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ import pprint
|
|||
import sys
|
||||
import traceback
|
||||
|
||||
from ConfigParser import RawConfigParser
|
||||
from six.moves.configparser import RawConfigParser
|
||||
from koji.server import ServerError, ServerRedirect
|
||||
from koji.util import dslice
|
||||
import six
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue