Convert all old-style classes to new-style
This cleanup has been slowly happening for a while; let's finish it. Change-Id: I1561e3540d524834e0cc5bc725ab80936eae1f0e
This commit is contained in:
parent
b9434b5c3e
commit
09ef06fd99
@ -136,7 +136,7 @@ class UnknownCommandError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class Manager():
|
||||
class Manager(object):
|
||||
"""Main class for performing commands on groups of servers.
|
||||
|
||||
:param servers: list of server names as strings
|
||||
@ -324,7 +324,7 @@ class Manager():
|
||||
return f(**kwargs)
|
||||
|
||||
|
||||
class Server():
|
||||
class Server(object):
|
||||
"""Manage operations on a server or group of servers of similar type
|
||||
|
||||
:param server: name of server
|
||||
|
@ -711,7 +711,7 @@ class GreenthreadSafeIterator(object):
|
||||
return self.unsafe_iter.next()
|
||||
|
||||
|
||||
class NullLogger():
|
||||
class NullLogger(object):
|
||||
"""A no-op logger for eventlet wsgi."""
|
||||
|
||||
def write(self, *args):
|
||||
|
@ -306,7 +306,7 @@ class Connection(object):
|
||||
return self.response.status
|
||||
|
||||
|
||||
class Base:
|
||||
class Base(object):
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
|
@ -67,7 +67,7 @@ class FakeBroker(object):
|
||||
return self.info
|
||||
|
||||
|
||||
class FakeAccountBroker():
|
||||
class FakeAccountBroker(object):
|
||||
def __init__(self, containers):
|
||||
self.containers = containers
|
||||
|
||||
@ -87,7 +87,7 @@ class FakeAccountBroker():
|
||||
return False
|
||||
|
||||
|
||||
class FakeRing():
|
||||
class FakeRing(object):
|
||||
def __init__(self):
|
||||
self.nodes = [{'id': '1',
|
||||
'ip': '10.10.10.1',
|
||||
|
@ -49,8 +49,8 @@ def lock_parent_directory(filename):
|
||||
yield True
|
||||
|
||||
|
||||
class FakeRing:
|
||||
class Ring:
|
||||
class FakeRing(object):
|
||||
class Ring(object):
|
||||
devs = []
|
||||
|
||||
def __init__(self, path, reload_time=15, ring_name=None):
|
||||
@ -66,8 +66,8 @@ class FakeRing:
|
||||
return []
|
||||
|
||||
|
||||
class FakeRingWithSingleNode:
|
||||
class Ring:
|
||||
class FakeRingWithSingleNode(object):
|
||||
class Ring(object):
|
||||
devs = [dict(
|
||||
id=1, weight=10.0, zone=1, ip='1.1.1.1', port=6000, device='sdb',
|
||||
meta='', replication_ip='1.1.1.1', replication_port=6000
|
||||
@ -86,8 +86,8 @@ class FakeRingWithSingleNode:
|
||||
return (d for d in self.devs)
|
||||
|
||||
|
||||
class FakeRingWithNodes:
|
||||
class Ring:
|
||||
class FakeRingWithNodes(object):
|
||||
class Ring(object):
|
||||
devs = [dict(
|
||||
id=1, weight=10.0, zone=1, ip='1.1.1.1', port=6000, device='sdb',
|
||||
meta=''
|
||||
@ -120,7 +120,7 @@ class FakeRingWithNodes:
|
||||
return (d for d in self.devs[3:])
|
||||
|
||||
|
||||
class FakeProcess:
|
||||
class FakeProcess(object):
|
||||
def __init__(self, *codes):
|
||||
self.codes = iter(codes)
|
||||
self.args = None
|
||||
@ -130,7 +130,7 @@ class FakeProcess:
|
||||
self.args = args
|
||||
self.kwargs = kwargs
|
||||
|
||||
class Failure:
|
||||
class Failure(object):
|
||||
def communicate(innerself):
|
||||
next = self.codes.next()
|
||||
if isinstance(next, int):
|
||||
@ -148,7 +148,7 @@ def _mock_process(*args):
|
||||
db_replicator.subprocess.Popen = orig_process
|
||||
|
||||
|
||||
class ReplHttp:
|
||||
class ReplHttp(object):
|
||||
def __init__(self, response=None, set_status=200):
|
||||
self.response = response
|
||||
self.set_status = set_status
|
||||
@ -158,7 +158,7 @@ class ReplHttp:
|
||||
def replicate(self, *args):
|
||||
self.replicated = True
|
||||
|
||||
class Response:
|
||||
class Response(object):
|
||||
status = self.set_status
|
||||
data = self.response
|
||||
|
||||
@ -167,7 +167,7 @@ class ReplHttp:
|
||||
return Response()
|
||||
|
||||
|
||||
class ChangingMtimesOs:
|
||||
class ChangingMtimesOs(object):
|
||||
def __init__(self):
|
||||
self.mtime = 0
|
||||
|
||||
@ -176,7 +176,7 @@ class ChangingMtimesOs:
|
||||
return self.mtime
|
||||
|
||||
|
||||
class FakeBroker:
|
||||
class FakeBroker(object):
|
||||
db_file = __file__
|
||||
get_repl_missing_table = False
|
||||
stub_replication_info = None
|
||||
@ -280,7 +280,7 @@ class TestDBReplicator(unittest.TestCase):
|
||||
self.assertEquals(method, 'REPLICATE')
|
||||
self.assertEquals(headers['Content-Type'], 'application/json')
|
||||
|
||||
class Resp:
|
||||
class Resp(object):
|
||||
def read(self):
|
||||
return 'data'
|
||||
resp = Resp()
|
||||
|
@ -30,7 +30,7 @@ from swift.common import manager
|
||||
DUMMY_SIG = 1
|
||||
|
||||
|
||||
class MockOs():
|
||||
class MockOs(object):
|
||||
RAISE_EPERM_SIG = 99
|
||||
|
||||
def __init__(self, pids):
|
||||
@ -77,7 +77,7 @@ class TestManagerModule(unittest.TestCase):
|
||||
len(manager.REST_SERVERS))
|
||||
|
||||
def test_setup_env(self):
|
||||
class MockResource():
|
||||
class MockResource(object):
|
||||
def __init__(self, error=None):
|
||||
self.error = error
|
||||
self.called_with_args = []
|
||||
@ -144,7 +144,7 @@ class TestManagerModule(unittest.TestCase):
|
||||
self.assert_(myfunc.publicly_accessible)
|
||||
|
||||
def test_watch_server_pids(self):
|
||||
class MockOs():
|
||||
class MockOs(object):
|
||||
WNOHANG = os.WNOHANG
|
||||
|
||||
def __init__(self, pid_map={}):
|
||||
@ -164,7 +164,7 @@ class TestManagerModule(unittest.TestCase):
|
||||
else:
|
||||
return rv
|
||||
|
||||
class MockTime():
|
||||
class MockTime(object):
|
||||
def __init__(self, ticks=None):
|
||||
self.tock = time()
|
||||
if not ticks:
|
||||
@ -182,7 +182,7 @@ class TestManagerModule(unittest.TestCase):
|
||||
def sleep(*args):
|
||||
return
|
||||
|
||||
class MockServer():
|
||||
class MockServer(object):
|
||||
|
||||
def __init__(self, pids, run_dir=manager.RUN_DIR, zombie=0):
|
||||
self.heartbeat = (pids for _ in range(zombie))
|
||||
@ -843,7 +843,7 @@ class TestServer(unittest.TestCase):
|
||||
def test_spawn(self):
|
||||
|
||||
# mocks
|
||||
class MockProcess():
|
||||
class MockProcess(object):
|
||||
|
||||
NOTHING = 'default besides None'
|
||||
STDOUT = 'stdout'
|
||||
@ -857,7 +857,7 @@ class TestServer(unittest.TestCase):
|
||||
def Popen(self, args, **kwargs):
|
||||
return MockProc(self.pids.next(), args, **kwargs)
|
||||
|
||||
class MockProc():
|
||||
class MockProc(object):
|
||||
|
||||
def __init__(self, pid, args, stdout=MockProcess.NOTHING,
|
||||
stderr=MockProcess.NOTHING):
|
||||
@ -1014,7 +1014,7 @@ class TestServer(unittest.TestCase):
|
||||
print >>self._stdout, 'mock process finished'
|
||||
self.finished = True
|
||||
|
||||
class MockTime():
|
||||
class MockTime(object):
|
||||
|
||||
def time(self):
|
||||
return time()
|
||||
@ -1073,7 +1073,7 @@ class TestServer(unittest.TestCase):
|
||||
manager.time = old_time
|
||||
|
||||
def test_interact(self):
|
||||
class MockProcess():
|
||||
class MockProcess(object):
|
||||
|
||||
def __init__(self, fail=False):
|
||||
self.returncode = None
|
||||
@ -1113,7 +1113,7 @@ class TestServer(unittest.TestCase):
|
||||
)
|
||||
|
||||
#mocks
|
||||
class MockSpawn():
|
||||
class MockSpawn(object):
|
||||
|
||||
def __init__(self, pids=None):
|
||||
self.conf_files = []
|
||||
@ -1332,7 +1332,7 @@ class TestManager(unittest.TestCase):
|
||||
self.assert_(str(s) in replicators)
|
||||
|
||||
def test_status(self):
|
||||
class MockServer():
|
||||
class MockServer(object):
|
||||
|
||||
def __init__(self, server, run_dir=manager.RUN_DIR):
|
||||
self.server = server
|
||||
@ -1368,7 +1368,7 @@ class TestManager(unittest.TestCase):
|
||||
def mock_setup_env():
|
||||
getattr(mock_setup_env, 'called', []).append(True)
|
||||
|
||||
class MockServer():
|
||||
class MockServer(object):
|
||||
def __init__(self, server, run_dir=manager.RUN_DIR):
|
||||
self.server = server
|
||||
self.called = defaultdict(list)
|
||||
@ -1430,7 +1430,7 @@ class TestManager(unittest.TestCase):
|
||||
manager.Server = old_swift_server
|
||||
|
||||
def test_no_wait(self):
|
||||
class MockServer():
|
||||
class MockServer(object):
|
||||
def __init__(self, server, run_dir=manager.RUN_DIR):
|
||||
self.server = server
|
||||
self.called = defaultdict(list)
|
||||
@ -1480,7 +1480,7 @@ class TestManager(unittest.TestCase):
|
||||
manager.Server = orig_swift_server
|
||||
|
||||
def test_no_daemon(self):
|
||||
class MockServer():
|
||||
class MockServer(object):
|
||||
|
||||
def __init__(self, server, run_dir=manager.RUN_DIR):
|
||||
self.server = server
|
||||
@ -1515,7 +1515,7 @@ class TestManager(unittest.TestCase):
|
||||
manager.Server = orig_swift_server
|
||||
|
||||
def test_once(self):
|
||||
class MockServer():
|
||||
class MockServer(object):
|
||||
|
||||
def __init__(self, server, run_dir=manager.RUN_DIR):
|
||||
self.server = server
|
||||
@ -1552,8 +1552,8 @@ class TestManager(unittest.TestCase):
|
||||
manager.Server = orig_swift_server
|
||||
|
||||
def test_stop(self):
|
||||
class MockServerFactory():
|
||||
class MockServer():
|
||||
class MockServerFactory(object):
|
||||
class MockServer(object):
|
||||
def __init__(self, pids, run_dir=manager.RUN_DIR):
|
||||
self.pids = pids
|
||||
|
||||
@ -1641,7 +1641,7 @@ class TestManager(unittest.TestCase):
|
||||
self.assertEquals(m.start_was_called, True)
|
||||
|
||||
def test_reload(self):
|
||||
class MockManager():
|
||||
class MockManager(object):
|
||||
called = defaultdict(list)
|
||||
|
||||
def __init__(self, servers):
|
||||
|
@ -58,7 +58,7 @@ from swift.common.swob import Response
|
||||
from test.unit import FakeLogger
|
||||
|
||||
|
||||
class MockOs():
|
||||
class MockOs(object):
|
||||
|
||||
def __init__(self, pass_funcs=[], called_funcs=[], raise_funcs=[]):
|
||||
self.closed_fds = []
|
||||
@ -99,7 +99,7 @@ class MockOs():
|
||||
return getattr(os, name)
|
||||
|
||||
|
||||
class MockUdpSocket():
|
||||
class MockUdpSocket(object):
|
||||
def __init__(self):
|
||||
self.sent = []
|
||||
|
||||
@ -110,7 +110,7 @@ class MockUdpSocket():
|
||||
pass
|
||||
|
||||
|
||||
class MockSys():
|
||||
class MockSys(object):
|
||||
|
||||
def __init__(self):
|
||||
self.stdin = TemporaryFile('w')
|
||||
@ -2667,7 +2667,7 @@ class TestStatsdLoggingDelegation(unittest.TestCase):
|
||||
def test_no_fdatasync(self):
|
||||
called = []
|
||||
|
||||
class NoFdatasync:
|
||||
class NoFdatasync(object):
|
||||
pass
|
||||
|
||||
def fsync(fd):
|
||||
@ -2681,7 +2681,7 @@ class TestStatsdLoggingDelegation(unittest.TestCase):
|
||||
def test_yes_fdatasync(self):
|
||||
called = []
|
||||
|
||||
class YesFdatasync:
|
||||
class YesFdatasync(object):
|
||||
|
||||
def fdatasync(self, fd):
|
||||
called.append(fd)
|
||||
@ -2692,7 +2692,7 @@ class TestStatsdLoggingDelegation(unittest.TestCase):
|
||||
|
||||
def test_fsync_bad_fullsync(self):
|
||||
|
||||
class FCNTL:
|
||||
class FCNTL(object):
|
||||
|
||||
F_FULLSYNC = 123
|
||||
|
||||
@ -2705,7 +2705,7 @@ class TestStatsdLoggingDelegation(unittest.TestCase):
|
||||
def test_fsync_f_fullsync(self):
|
||||
called = []
|
||||
|
||||
class FCNTL:
|
||||
class FCNTL(object):
|
||||
|
||||
F_FULLSYNC = 123
|
||||
|
||||
@ -2720,7 +2720,7 @@ class TestStatsdLoggingDelegation(unittest.TestCase):
|
||||
def test_fsync_no_fullsync(self):
|
||||
called = []
|
||||
|
||||
class FCNTL:
|
||||
class FCNTL(object):
|
||||
pass
|
||||
|
||||
def fsync(fd):
|
||||
|
@ -223,7 +223,7 @@ class TestWSGI(unittest.TestCase):
|
||||
}
|
||||
|
||||
# mocks
|
||||
class MockSocket():
|
||||
class MockSocket(object):
|
||||
def __init__(self):
|
||||
self.opts = defaultdict(dict)
|
||||
|
||||
@ -233,7 +233,7 @@ class TestWSGI(unittest.TestCase):
|
||||
def mock_listen(*args, **kwargs):
|
||||
return MockSocket()
|
||||
|
||||
class MockSsl():
|
||||
class MockSsl(object):
|
||||
def __init__(self):
|
||||
self.wrap_socket_called = []
|
||||
|
||||
@ -289,7 +289,7 @@ class TestWSGI(unittest.TestCase):
|
||||
def mock_sleep(*args):
|
||||
pass
|
||||
|
||||
class MockTime():
|
||||
class MockTime(object):
|
||||
"""Fast clock advances 10 seconds after every call to time
|
||||
"""
|
||||
def __init__(self):
|
||||
|
@ -1831,7 +1831,7 @@ class TestObjectController(unittest.TestCase):
|
||||
|
||||
def test_max_upload_time(self):
|
||||
|
||||
class SlowBody():
|
||||
class SlowBody(object):
|
||||
|
||||
def __init__(self):
|
||||
self.sent = 0
|
||||
@ -1861,7 +1861,7 @@ class TestObjectController(unittest.TestCase):
|
||||
|
||||
def test_short_body(self):
|
||||
|
||||
class ShortBody():
|
||||
class ShortBody(object):
|
||||
|
||||
def __init__(self):
|
||||
self.sent = False
|
||||
@ -3146,7 +3146,7 @@ class TestObjectController(unittest.TestCase):
|
||||
|
||||
def test_PUT_with_full_drive(self):
|
||||
|
||||
class IgnoredBody():
|
||||
class IgnoredBody(object):
|
||||
|
||||
def __init__(self):
|
||||
self.read_called = False
|
||||
|
@ -1590,7 +1590,7 @@ class TestObjectController(unittest.TestCase):
|
||||
dev['ip'] = '127.0.0.1'
|
||||
dev['port'] = 1
|
||||
|
||||
class SlowBody():
|
||||
class SlowBody(object):
|
||||
|
||||
def __init__(self):
|
||||
self.sent = 0
|
||||
@ -1639,7 +1639,7 @@ class TestObjectController(unittest.TestCase):
|
||||
dev['ip'] = '127.0.0.1'
|
||||
dev['port'] = 1
|
||||
|
||||
class SlowBody():
|
||||
class SlowBody(object):
|
||||
|
||||
def __init__(self):
|
||||
self.sent = 0
|
||||
@ -2555,7 +2555,7 @@ class TestObjectController(unittest.TestCase):
|
||||
|
||||
def test_chunked_put(self):
|
||||
|
||||
class ChunkedFile():
|
||||
class ChunkedFile(object):
|
||||
|
||||
def __init__(self, bytes):
|
||||
self.bytes = bytes
|
||||
|
Loading…
Reference in New Issue
Block a user