Merge "Run pyupgrade to clean up Python 2 syntaxes"
This commit is contained in:
commit
9d66891b15
@ -1,6 +1,6 @@
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v4.5.0
|
||||
rev: v5.0.0
|
||||
hooks:
|
||||
- id: trailing-whitespace
|
||||
# Replaces or checks mixed line ending
|
||||
@ -19,17 +19,21 @@ repos:
|
||||
- id: check-yaml
|
||||
files: .*\.(yaml|yml)$
|
||||
- repo: https://opendev.org/openstack/hacking
|
||||
rev: 6.1.0
|
||||
rev: 7.0.0
|
||||
hooks:
|
||||
- id: hacking
|
||||
additional_dependencies: []
|
||||
- repo: https://github.com/PyCQA/bandit
|
||||
rev: 1.7.6
|
||||
rev: 1.7.10
|
||||
hooks:
|
||||
- id: bandit
|
||||
args: ['-x', 'tests']
|
||||
- repo: https://github.com/PyCQA/doc8
|
||||
rev: v1.1.1
|
||||
rev: v1.1.2
|
||||
hooks:
|
||||
- id: doc8
|
||||
|
||||
- repo: https://github.com/asottile/pyupgrade
|
||||
rev: v3.18.0
|
||||
hooks:
|
||||
- id: pyupgrade
|
||||
args: [--py3-only]
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2020 Red Hat, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -40,7 +40,7 @@ class EventletBackdoorConfigValueError(Exception):
|
||||
msg = (_('Invalid backdoor_port configuration %(range)s: %(ex)s. '
|
||||
'%(help)s') %
|
||||
{'range': port_range, 'ex': ex, 'help': help_msg})
|
||||
super(EventletBackdoorConfigValueError, self).__init__(msg)
|
||||
super().__init__(msg)
|
||||
self.port_range = port_range
|
||||
|
||||
|
||||
@ -50,7 +50,7 @@ def _dont_use_this():
|
||||
|
||||
def _dump_frame(f, frame_chapter):
|
||||
co = f.f_code
|
||||
print(" %s Frame: %s" % (frame_chapter, co.co_name))
|
||||
print(" {} Frame: {}".format(frame_chapter, co.co_name))
|
||||
print(" File: %s" % (co.co_filename))
|
||||
print(" Captured at line number: %s" % (f.f_lineno))
|
||||
co_locals = set(co.co_varnames)
|
||||
@ -64,7 +64,8 @@ def _dump_frame(f, frame_chapter):
|
||||
if set_locals:
|
||||
print(" %s set local variables:" % (len(set_locals)))
|
||||
for var_name in sorted(set_locals.keys()):
|
||||
print(" %s => %r" % (var_name, f.f_locals[var_name]))
|
||||
print(" {} => {!r}".format(
|
||||
var_name, f.f_locals[var_name]))
|
||||
else:
|
||||
print(" 0 set local variables.")
|
||||
if not_set:
|
||||
@ -80,7 +81,7 @@ def _dump_frame(f, frame_chapter):
|
||||
def _detailed_dump_frames(f, thread_index):
|
||||
i = 0
|
||||
while f is not None:
|
||||
_dump_frame(f, "%s.%s" % (thread_index, i + 1))
|
||||
_dump_frame(f, "{}.{}".format(thread_index, i + 1))
|
||||
f = f.f_back
|
||||
i += 1
|
||||
|
||||
@ -164,7 +165,7 @@ def _listen(host, start_port, end_port):
|
||||
while True:
|
||||
try:
|
||||
return _listen_func(host, try_port)
|
||||
except socket.error as exc:
|
||||
except OSError as exc:
|
||||
if (exc.errno != errno.EADDRINUSE or
|
||||
try_port >= end_port):
|
||||
raise
|
||||
@ -174,7 +175,7 @@ def _listen(host, start_port, end_port):
|
||||
def _try_open_unix_domain_socket(socket_path):
|
||||
try:
|
||||
return eventlet.listen(socket_path, socket.AF_UNIX)
|
||||
except socket.error as e:
|
||||
except OSError as e:
|
||||
if e.errno != errno.EADDRINUSE:
|
||||
# NOTE(harlowja): Some other non-address in use error
|
||||
# occurred, since we aren't handling those, re-raise
|
||||
|
@ -76,7 +76,7 @@ def _safe_wrapper(f, kind, func_name):
|
||||
return func
|
||||
|
||||
|
||||
class LoopingCallBase(object):
|
||||
class LoopingCallBase:
|
||||
_KIND = _("Unknown looping call")
|
||||
|
||||
_RUN_ONLY_ONE_MESSAGE = _("A looping call can only run one function"
|
||||
@ -315,7 +315,7 @@ class BackOffLoopingCall(LoopingCallBase):
|
||||
" only run one function at a time")
|
||||
|
||||
def __init__(self, f=None, *args, **kw):
|
||||
super(BackOffLoopingCall, self).__init__(f=f, *args, **kw)
|
||||
super().__init__(f=f, *args, **kw)
|
||||
self._error_time = 0
|
||||
self._interval = 1
|
||||
|
||||
@ -355,7 +355,7 @@ class BackOffLoopingCall(LoopingCallBase):
|
||||
return self._start(_idle_for, initial_delay=initial_delay)
|
||||
|
||||
|
||||
class RetryDecorator(object):
|
||||
class RetryDecorator:
|
||||
"""Decorator for retrying a function upon suggested exceptions.
|
||||
|
||||
The decorated function is retried for the given number of times, and the
|
||||
|
@ -125,7 +125,7 @@ class _PeriodicTasksMeta(type):
|
||||
|
||||
def __init__(cls, names, bases, dict_):
|
||||
"""Metaclass that allows us to collect decorated periodic tasks."""
|
||||
super(_PeriodicTasksMeta, cls).__init__(names, bases, dict_)
|
||||
super().__init__(names, bases, dict_)
|
||||
|
||||
# NOTE(sirp): if the attribute is not present then we must be the base
|
||||
# class, so, go ahead an initialize it. If the attribute is present,
|
||||
@ -170,7 +170,7 @@ def _nearest_boundary(last_run, spacing):
|
||||
|
||||
class PeriodicTasks(metaclass=_PeriodicTasksMeta):
|
||||
def __init__(self, conf):
|
||||
super(PeriodicTasks, self).__init__()
|
||||
super().__init__()
|
||||
self.conf = conf
|
||||
self.conf.register_opts(_options.periodic_opts)
|
||||
self._periodic_last_run = {}
|
||||
|
@ -120,7 +120,7 @@ class Singleton(type):
|
||||
def __call__(cls, *args, **kwargs):
|
||||
with lockutils.lock('singleton_lock', semaphores=cls._semaphores):
|
||||
if cls not in cls._instances:
|
||||
cls._instances[cls] = super(Singleton, cls).__call__(
|
||||
cls._instances[cls] = super().__call__(
|
||||
*args, **kwargs)
|
||||
return cls._instances[cls]
|
||||
|
||||
@ -128,20 +128,20 @@ class Singleton(type):
|
||||
class SignalHandler(metaclass=Singleton):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(SignalHandler, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
self.__setup_signal_interruption()
|
||||
|
||||
# Map all signal names to signal integer values and create a
|
||||
# reverse mapping (for easier + quick lookup).
|
||||
self._ignore_signals = ('SIG_DFL', 'SIG_IGN')
|
||||
self._signals_by_name = dict((name, getattr(signal, name))
|
||||
for name in dir(signal)
|
||||
if name.startswith("SIG") and
|
||||
name not in self._ignore_signals)
|
||||
self.signals_to_name = dict(
|
||||
(sigval, name)
|
||||
for (name, sigval) in self._signals_by_name.items())
|
||||
self._signals_by_name = {name: getattr(signal, name)
|
||||
for name in dir(signal)
|
||||
if name.startswith("SIG") and
|
||||
name not in self._ignore_signals}
|
||||
self.signals_to_name = {
|
||||
sigval: name
|
||||
for (name, sigval) in self._signals_by_name.items()}
|
||||
self._signal_handlers = collections.defaultdict(list)
|
||||
self.clear()
|
||||
|
||||
@ -193,7 +193,7 @@ class SignalHandler(metaclass=Singleton):
|
||||
interrupted_frame.filename == self.__hub_module_file) or
|
||||
(interrupted_frame.function == 'do_sleep' and
|
||||
interrupted_frame.filename == __file__)):
|
||||
raise IOError(errno.EINTR, 'Interrupted')
|
||||
raise OSError(errno.EINTR, 'Interrupted')
|
||||
|
||||
def __setup_signal_interruption(self):
|
||||
"""Set up to do the Right Thing with signals during poll() and sleep().
|
||||
@ -227,7 +227,7 @@ class SignalHandler(metaclass=Singleton):
|
||||
def sleep_wrapper(seconds):
|
||||
try:
|
||||
return do_sleep(time_sleep, seconds)
|
||||
except (IOError, InterruptedError) as err:
|
||||
except (OSError, InterruptedError) as err:
|
||||
if err.errno != errno.EINTR:
|
||||
raise
|
||||
|
||||
@ -244,7 +244,7 @@ class SignalHandler(metaclass=Singleton):
|
||||
return sig_name in self._signals_by_name
|
||||
|
||||
|
||||
class Launcher(object):
|
||||
class Launcher:
|
||||
"""Launch one or more services and wait for them to complete."""
|
||||
|
||||
def __init__(self, conf, restart_method='reload'):
|
||||
@ -311,7 +311,7 @@ class Launcher(object):
|
||||
|
||||
class SignalExit(SystemExit):
|
||||
def __init__(self, signo, exccode=1):
|
||||
super(SignalExit, self).__init__(exccode)
|
||||
super().__init__(exccode)
|
||||
self.signo = signo
|
||||
|
||||
|
||||
@ -323,7 +323,7 @@ class ServiceLauncher(Launcher):
|
||||
:param conf: an instance of ConfigOpts
|
||||
:param restart_method: passed to super
|
||||
"""
|
||||
super(ServiceLauncher, self).__init__(
|
||||
super().__init__(
|
||||
conf, restart_method=restart_method)
|
||||
self.signal_handler = SignalHandler()
|
||||
|
||||
@ -364,7 +364,7 @@ class ServiceLauncher(Launcher):
|
||||
self.conf.log_opt_values(LOG, logging.DEBUG)
|
||||
|
||||
try:
|
||||
super(ServiceLauncher, self).wait()
|
||||
super().wait()
|
||||
except SignalExit as exc:
|
||||
signame = self.signal_handler.signals_to_name[exc.signo]
|
||||
LOG.info('Caught %s, handling', signame)
|
||||
@ -391,11 +391,11 @@ class ServiceLauncher(Launcher):
|
||||
break
|
||||
self.restart()
|
||||
|
||||
super(ServiceLauncher, self).wait()
|
||||
super().wait()
|
||||
return status
|
||||
|
||||
|
||||
class ServiceWrapper(object):
|
||||
class ServiceWrapper:
|
||||
def __init__(self, service, workers):
|
||||
self.service = service
|
||||
self.workers = workers
|
||||
@ -403,7 +403,7 @@ class ServiceWrapper(object):
|
||||
self.forktimes = []
|
||||
|
||||
|
||||
class ProcessLauncher(object):
|
||||
class ProcessLauncher:
|
||||
"""Launch a service with a given number of workers."""
|
||||
|
||||
def __init__(self, conf, wait_interval=0.01, restart_method='reload'):
|
||||
@ -672,8 +672,8 @@ class ProcessLauncher(object):
|
||||
elif self.restart_method == 'mutate':
|
||||
self.conf.mutate_config_files()
|
||||
child_signal = signal.SIGHUP
|
||||
for service in set(
|
||||
[wrap.service for wrap in self.children.values()]):
|
||||
for service in {
|
||||
wrap.service for wrap in self.children.values()}:
|
||||
service.reset()
|
||||
|
||||
for pid in self.children:
|
||||
@ -697,8 +697,8 @@ class ProcessLauncher(object):
|
||||
self.running = False
|
||||
|
||||
LOG.debug("Stop services.")
|
||||
for service in set(
|
||||
[wrap.service for wrap in self.children.values()]):
|
||||
for service in {
|
||||
wrap.service for wrap in self.children.values()}:
|
||||
service.stop()
|
||||
|
||||
LOG.debug("Killing children.")
|
||||
@ -741,7 +741,7 @@ class Service(ServiceBase):
|
||||
self.tg.wait()
|
||||
|
||||
|
||||
class Services(object):
|
||||
class Services:
|
||||
|
||||
def __init__(self, restart_method='reload'):
|
||||
if restart_method not in _LAUNCHER_RESTART_METHODS:
|
||||
|
@ -43,7 +43,7 @@ def _sd_notify(unset_env, msg):
|
||||
sock.sendall(msg)
|
||||
if unset_env:
|
||||
del os.environ['NOTIFY_SOCKET']
|
||||
except EnvironmentError:
|
||||
except OSError:
|
||||
LOG.debug("Systemd notification failed", exc_info=True)
|
||||
|
||||
|
||||
|
@ -23,7 +23,7 @@ from oslo_service import sslutils
|
||||
class ServiceBaseTestCase(test_base.BaseTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(ServiceBaseTestCase, self).setUp()
|
||||
super().setUp()
|
||||
self.conf_fixture = self.useFixture(config.Config())
|
||||
self.conf_fixture.register_opts(_options.eventlet_backdoor_opts)
|
||||
self.conf_fixture.register_opts(_options.service_opts)
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
|
@ -20,7 +20,7 @@ from oslo_service import loopingcall
|
||||
|
||||
class FixtureTestCase(test_base.BaseTestCase):
|
||||
def setUp(self):
|
||||
super(FixtureTestCase, self).setUp()
|
||||
super().setUp()
|
||||
self.sleepfx = self.useFixture(fixture.SleepFixture())
|
||||
|
||||
def test_sleep_fixture(self):
|
||||
|
@ -25,7 +25,7 @@ from oslo_service import loopingcall
|
||||
class LoopingCallTestCase(test_base.BaseTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(LoopingCallTestCase, self).setUp()
|
||||
super().setUp()
|
||||
self.num_runs = 0
|
||||
|
||||
def test_return_true(self):
|
||||
@ -159,7 +159,7 @@ class LoopingCallTestCase(test_base.BaseTestCase):
|
||||
|
||||
class DynamicLoopingCallTestCase(test_base.BaseTestCase):
|
||||
def setUp(self):
|
||||
super(DynamicLoopingCallTestCase, self).setUp()
|
||||
super().setUp()
|
||||
self.num_runs = 0
|
||||
|
||||
def test_return_true(self):
|
||||
|
@ -41,7 +41,7 @@ class PeriodicTasksTestCase(base.ServiceBaseTestCase):
|
||||
# the periodic task decorator
|
||||
class AService(periodic_task.PeriodicTasks):
|
||||
def __init__(self, conf):
|
||||
super(AService, self).__init__(conf)
|
||||
super().__init__(conf)
|
||||
self.called = {'doit': 0, 'urg': 0, 'ticks': 0, 'tocks': 0}
|
||||
|
||||
@periodic_task.periodic_task
|
||||
@ -134,7 +134,7 @@ class PeriodicTasksTestCase(base.ServiceBaseTestCase):
|
||||
# the periodic task decorator
|
||||
class AService(periodic_task.PeriodicTasks):
|
||||
def __init__(self, conf):
|
||||
super(AService, self).__init__(conf)
|
||||
super().__init__(conf)
|
||||
self.called = {'ticks': 0}
|
||||
|
||||
@periodic_task.periodic_task(spacing=test_spacing)
|
||||
@ -155,7 +155,7 @@ class PeriodicTasksTestCase(base.ServiceBaseTestCase):
|
||||
|
||||
class AService(periodic_task.PeriodicTasks):
|
||||
def __init__(self, conf):
|
||||
super(AService, self).__init__(conf)
|
||||
super().__init__(conf)
|
||||
self.called = {'urg': 0, }
|
||||
|
||||
@periodic_task.periodic_task
|
||||
@ -174,7 +174,7 @@ class PeriodicTasksTestCase(base.ServiceBaseTestCase):
|
||||
def test_name(self):
|
||||
class AService(periodic_task.PeriodicTasks):
|
||||
def __init__(self, conf):
|
||||
super(AService, self).__init__(conf)
|
||||
super().__init__(conf)
|
||||
|
||||
@periodic_task.periodic_task(name='better-name')
|
||||
def tick(self, context):
|
||||
@ -234,7 +234,7 @@ class ManagerMetaTestCase(base.ServiceBaseTestCase):
|
||||
class ManagerTestCase(base.ServiceBaseTestCase):
|
||||
"""Tests the periodic tasks portion of the manager class."""
|
||||
def setUp(self):
|
||||
super(ManagerTestCase, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
def test_periodic_tasks_with_idle(self):
|
||||
class Manager(periodic_task.PeriodicTasks):
|
||||
|
@ -52,18 +52,18 @@ class ServiceManagerTestCase(test_base.BaseTestCase):
|
||||
|
||||
class ServiceWithTimer(service.Service):
|
||||
def __init__(self, ready_event=None):
|
||||
super(ServiceWithTimer, self).__init__()
|
||||
super().__init__()
|
||||
self.ready_event = ready_event
|
||||
|
||||
def start(self):
|
||||
super(ServiceWithTimer, self).start()
|
||||
super().start()
|
||||
self.timer_fired = 0
|
||||
self.tg.add_timer(1, self.timer_expired)
|
||||
|
||||
def wait(self):
|
||||
if self.ready_event:
|
||||
self.ready_event.set()
|
||||
super(ServiceWithTimer, self).wait()
|
||||
super().wait()
|
||||
|
||||
def timer_expired(self):
|
||||
self.timer_fired = self.timer_fired + 1
|
||||
@ -71,7 +71,7 @@ class ServiceWithTimer(service.Service):
|
||||
|
||||
class ServiceCrashOnStart(ServiceWithTimer):
|
||||
def start(self):
|
||||
super(ServiceCrashOnStart, self).start()
|
||||
super().start()
|
||||
raise ValueError
|
||||
|
||||
|
||||
@ -123,7 +123,7 @@ class ServiceTestBase(base.ServiceBaseTestCase):
|
||||
time.sleep(.1)
|
||||
|
||||
def setUp(self):
|
||||
super(ServiceTestBase, self).setUp()
|
||||
super().setUp()
|
||||
# NOTE(markmc): ConfigOpts.log_opt_values() uses CONF.config-file
|
||||
self.conf(args=[], default_config_files=[])
|
||||
self.addCleanup(self.conf.reset)
|
||||
@ -335,7 +335,7 @@ class ServiceRestartTest(ServiceTestBase):
|
||||
|
||||
class _Service(service.Service):
|
||||
def __init__(self):
|
||||
super(_Service, self).__init__()
|
||||
super().__init__()
|
||||
self.init = event.Event()
|
||||
self.cleaned_up = False
|
||||
|
||||
@ -344,7 +344,7 @@ class _Service(service.Service):
|
||||
|
||||
def stop(self):
|
||||
self.cleaned_up = True
|
||||
super(_Service, self).stop()
|
||||
super().stop()
|
||||
|
||||
|
||||
class LauncherTest(base.ServiceBaseTestCase):
|
||||
@ -418,7 +418,7 @@ class LauncherTest(base.ServiceBaseTestCase):
|
||||
initialize_if_enabled_mock.return_value = None
|
||||
launcher = service.Launcher(self.conf)
|
||||
|
||||
class FooService(object):
|
||||
class FooService:
|
||||
def __init__(self):
|
||||
pass
|
||||
serv = FooService()
|
||||
@ -552,7 +552,7 @@ class ProcessLauncherTest(base.ServiceBaseTestCase):
|
||||
pipe_mock.return_value = [None, None]
|
||||
launcher = service.ProcessLauncher(self.conf)
|
||||
|
||||
class FooService(object):
|
||||
class FooService:
|
||||
def __init__(self):
|
||||
pass
|
||||
serv = FooService()
|
||||
@ -593,7 +593,7 @@ class ProcessLauncherTest(base.ServiceBaseTestCase):
|
||||
|
||||
class GracefulShutdownTestService(service.Service):
|
||||
def __init__(self):
|
||||
super(GracefulShutdownTestService, self).__init__()
|
||||
super().__init__()
|
||||
self.finished_task = event.Event()
|
||||
|
||||
def start(self, sleep_amount):
|
||||
@ -628,7 +628,7 @@ class ServiceTest(test_base.BaseTestCase):
|
||||
|
||||
class EventletServerProcessLauncherTest(base.ServiceBaseTestCase):
|
||||
def setUp(self):
|
||||
super(EventletServerProcessLauncherTest, self).setUp()
|
||||
super().setUp()
|
||||
self.conf(args=[], default_config_files=[])
|
||||
self.addCleanup(self.conf.reset)
|
||||
self.workers = 3
|
||||
@ -708,5 +708,5 @@ class EventletServerProcessLauncherTest(base.ServiceBaseTestCase):
|
||||
|
||||
class EventletServerServiceLauncherTest(EventletServerProcessLauncherTest):
|
||||
def setUp(self):
|
||||
super(EventletServerServiceLauncherTest, self).setUp()
|
||||
super().setUp()
|
||||
self.workers = 1
|
||||
|
@ -33,7 +33,7 @@ class SslutilsTestCase(base.ServiceBaseTestCase):
|
||||
"""Test cases for sslutils."""
|
||||
|
||||
def setUp(self):
|
||||
super(SslutilsTestCase, self).setUp()
|
||||
super().setUp()
|
||||
self.cert_file_name = os.path.join(SSL_CERT_DIR, 'certificate.crt')
|
||||
self.key_file_name = os.path.join(SSL_CERT_DIR, 'privatekey.key')
|
||||
self.ca_file_name = os.path.join(SSL_CERT_DIR, 'ca.crt')
|
||||
|
@ -27,14 +27,14 @@ class SystemdTestCase(test_base.BaseTestCase):
|
||||
def test__abstractify(self):
|
||||
sock_name = '@fake_socket'
|
||||
res = systemd._abstractify(sock_name)
|
||||
self.assertEqual('\0{0}'.format(sock_name[1:]), res)
|
||||
self.assertEqual('\0{}'.format(sock_name[1:]), res)
|
||||
|
||||
@mock.patch.object(os, 'getenv', return_value='@fake_socket')
|
||||
def _test__sd_notify(self, getenv_mock, unset_env=False):
|
||||
self.ready = False
|
||||
self.closed = False
|
||||
|
||||
class FakeSocket(object):
|
||||
class FakeSocket:
|
||||
def __init__(self, family, type):
|
||||
pass
|
||||
|
||||
|
@ -29,7 +29,7 @@ from oslo_service import threadgroup
|
||||
class ThreadGroupTestCase(test_base.BaseTestCase):
|
||||
"""Test cases for thread group."""
|
||||
def setUp(self):
|
||||
super(ThreadGroupTestCase, self).setUp()
|
||||
super().setUp()
|
||||
self.tg = threadgroup.ThreadGroup()
|
||||
self.addCleanup(self.tg.stop)
|
||||
|
||||
|
@ -45,7 +45,7 @@ class WsgiTestCase(base.ServiceBaseTestCase):
|
||||
"""Base class for WSGI tests."""
|
||||
|
||||
def setUp(self):
|
||||
super(WsgiTestCase, self).setUp()
|
||||
super().setUp()
|
||||
self.conf(args=[], default_config_files=[])
|
||||
|
||||
|
||||
@ -53,7 +53,7 @@ class TestLoaderNothingExists(WsgiTestCase):
|
||||
"""Loader tests where os.path.exists always returns False."""
|
||||
|
||||
def setUp(self):
|
||||
super(TestLoaderNothingExists, self).setUp()
|
||||
super().setUp()
|
||||
mock_patcher = mock.patch.object(os.path, 'exists',
|
||||
lambda _: False)
|
||||
mock_patcher.start()
|
||||
@ -86,7 +86,7 @@ document_root = /tmp
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
super(TestLoaderNormalFilesystem, self).setUp()
|
||||
super().setUp()
|
||||
self.paste_config = tempfile.NamedTemporaryFile(mode="w+t")
|
||||
self.paste_config.write(self._paste_config.lstrip())
|
||||
self.paste_config.seek(0)
|
||||
@ -111,14 +111,14 @@ document_root = /tmp
|
||||
|
||||
def tearDown(self):
|
||||
self.paste_config.close()
|
||||
super(TestLoaderNormalFilesystem, self).tearDown()
|
||||
super().tearDown()
|
||||
|
||||
|
||||
class TestWSGIServer(WsgiTestCase):
|
||||
"""WSGI server tests."""
|
||||
|
||||
def setUp(self):
|
||||
super(TestWSGIServer, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
def test_no_app(self):
|
||||
server = wsgi.Server(self.conf, "test_app", None)
|
||||
@ -287,7 +287,7 @@ class TestWSGIServerWithSSL(WsgiTestCase):
|
||||
"""WSGI server with SSL tests."""
|
||||
|
||||
def setUp(self):
|
||||
super(TestWSGIServerWithSSL, self).setUp()
|
||||
super().setUp()
|
||||
cert_file_name = os.path.join(SSL_CERT_DIR, 'certificate.crt')
|
||||
key_file_name = os.path.join(SSL_CERT_DIR, 'privatekey.key')
|
||||
eventlet.monkey_patch(os=False, thread=False)
|
||||
|
@ -35,7 +35,7 @@ def _on_thread_done(_greenthread, group, thread):
|
||||
group.thread_done(thread)
|
||||
|
||||
|
||||
class Thread(object):
|
||||
class Thread:
|
||||
"""Wrapper around a greenthread.
|
||||
|
||||
Holds a reference to the :class:`ThreadGroup`. The Thread will notify
|
||||
@ -72,7 +72,7 @@ class Thread(object):
|
||||
self.thread.cancel(*throw_args)
|
||||
|
||||
|
||||
class ThreadGroup(object):
|
||||
class ThreadGroup:
|
||||
"""A group of greenthreads and timers.
|
||||
|
||||
The point of the ThreadGroup class is to:
|
||||
|
@ -139,7 +139,7 @@ class Server(service.ServiceBase):
|
||||
|
||||
try:
|
||||
sock = eventlet.listen(bind_addr, family, backlog=backlog)
|
||||
except EnvironmentError:
|
||||
except OSError:
|
||||
LOG.error("Could not bind to %(host)s:%(port)s",
|
||||
{'host': host, 'port': port})
|
||||
raise
|
||||
@ -245,7 +245,7 @@ class Request(webob.Request):
|
||||
pass
|
||||
|
||||
|
||||
class Router(object):
|
||||
class Router:
|
||||
"""WSGI middleware that maps incoming requests to WSGI apps."""
|
||||
|
||||
def __init__(self, mapper):
|
||||
@ -305,17 +305,17 @@ class Router(object):
|
||||
class ConfigNotFound(Exception):
|
||||
def __init__(self, path):
|
||||
msg = _('Could not find config at %(path)s') % {'path': path}
|
||||
super(ConfigNotFound, self).__init__(msg)
|
||||
super().__init__(msg)
|
||||
|
||||
|
||||
class PasteAppNotFound(Exception):
|
||||
def __init__(self, name, path):
|
||||
msg = (_("Could not load paste app '%(name)s' from %(path)s") %
|
||||
{'name': name, 'path': path})
|
||||
super(PasteAppNotFound, self).__init__(msg)
|
||||
super().__init__(msg)
|
||||
|
||||
|
||||
class Loader(object):
|
||||
class Loader:
|
||||
"""Used to load WSGI applications from paste configurations."""
|
||||
|
||||
def __init__(self, conf):
|
||||
|
@ -1,4 +1,3 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2020 Red Hat, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
Loading…
Reference in New Issue
Block a user