mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-08-19 12:59:42 -07:00
Update cherrpy to 17.4.2
This commit is contained in:
parent
f28e741ad7
commit
4d6279a626
131 changed files with 15864 additions and 10389 deletions
|
@ -1,18 +1,17 @@
|
|||
"""Manage HTTP servers with CherryPy."""
|
||||
|
||||
import warnings
|
||||
import six
|
||||
|
||||
import cherrypy
|
||||
from cherrypy.lib import attributes
|
||||
from cherrypy._cpcompat import basestring, py3k
|
||||
from cherrypy.lib.reprconf import attributes
|
||||
from cherrypy._cpcompat import text_or_bytes
|
||||
from cherrypy.process.servers import ServerAdapter
|
||||
|
||||
# We import * because we want to export check_port
|
||||
# et al as attributes of this module.
|
||||
from cherrypy.process.servers import *
|
||||
|
||||
__all__ = ('Server', )
|
||||
|
||||
|
||||
class Server(ServerAdapter):
|
||||
|
||||
"""An adapter for an HTTP server.
|
||||
|
||||
You can set attributes (like socket_host and socket_port)
|
||||
|
@ -28,26 +27,26 @@ class Server(ServerAdapter):
|
|||
|
||||
_socket_host = '127.0.0.1'
|
||||
|
||||
def _get_socket_host(self):
|
||||
return self._socket_host
|
||||
|
||||
def _set_socket_host(self, value):
|
||||
if value == '':
|
||||
raise ValueError("The empty string ('') is not an allowed value. "
|
||||
"Use '0.0.0.0' instead to listen on all active "
|
||||
"interfaces (INADDR_ANY).")
|
||||
self._socket_host = value
|
||||
socket_host = property(
|
||||
_get_socket_host,
|
||||
_set_socket_host,
|
||||
doc="""The hostname or IP address on which to listen for connections.
|
||||
@property
|
||||
def socket_host(self): # noqa: D401; irrelevant for properties
|
||||
"""The hostname or IP address on which to listen for connections.
|
||||
|
||||
Host values may be any IPv4 or IPv6 address, or any valid hostname.
|
||||
The string 'localhost' is a synonym for '127.0.0.1' (or '::1', if
|
||||
your hosts file prefers IPv6). The string '0.0.0.0' is a special
|
||||
IPv4 entry meaning "any active interface" (INADDR_ANY), and '::'
|
||||
is the similar IN6ADDR_ANY for IPv6. The empty string or None are
|
||||
not allowed.""")
|
||||
not allowed.
|
||||
"""
|
||||
return self._socket_host
|
||||
|
||||
@socket_host.setter
|
||||
def socket_host(self, value):
|
||||
if value == '':
|
||||
raise ValueError("The empty string ('') is not an allowed value. "
|
||||
"Use '0.0.0.0' instead to listen on all active "
|
||||
'interfaces (INADDR_ANY).')
|
||||
self._socket_host = value
|
||||
|
||||
socket_file = None
|
||||
"""If given, the name of the UNIX socket to use instead of TCP/IP.
|
||||
|
@ -61,11 +60,11 @@ class Server(ServerAdapter):
|
|||
|
||||
socket_timeout = 10
|
||||
"""The timeout in seconds for accepted connections (default 10)."""
|
||||
|
||||
|
||||
accepted_queue_size = -1
|
||||
"""The maximum number of requests which will be queued up before
|
||||
the server refuses to accept it (default -1, meaning no limit)."""
|
||||
|
||||
|
||||
accepted_queue_timeout = 10
|
||||
"""The timeout in seconds for attempting to add a request to the
|
||||
queue when the queue is full (default 10)."""
|
||||
|
@ -96,7 +95,8 @@ class Server(ServerAdapter):
|
|||
|
||||
instance = None
|
||||
"""If not None, this should be an HTTP server instance (such as
|
||||
CPWSGIServer) which cherrypy.server will control. Use this when you need
|
||||
cheroot.wsgi.Server) which cherrypy.server will control.
|
||||
Use this when you need
|
||||
more control over object instantiation than is available in the various
|
||||
configuration options."""
|
||||
|
||||
|
@ -113,20 +113,23 @@ class Server(ServerAdapter):
|
|||
ssl_private_key = None
|
||||
"""The filename of the private key to use with SSL."""
|
||||
|
||||
if py3k:
|
||||
ssl_ciphers = None
|
||||
"""The ciphers list of SSL."""
|
||||
|
||||
if six.PY3:
|
||||
ssl_module = 'builtin'
|
||||
"""The name of a registered SSL adaptation module to use with
|
||||
the builtin WSGI server. Builtin options are: 'builtin' (to
|
||||
use the SSL library built into recent versions of Python).
|
||||
You may also register your own classes in the
|
||||
wsgiserver.ssl_adapters dict."""
|
||||
cheroot.server.ssl_adapters dict."""
|
||||
else:
|
||||
ssl_module = 'pyopenssl'
|
||||
"""The name of a registered SSL adaptation module to use with the
|
||||
builtin WSGI server. Builtin options are 'builtin' (to use the SSL
|
||||
library built into recent versions of Python) and 'pyopenssl' (to
|
||||
use the PyOpenSSL project, which you must install separately). You
|
||||
may also register your own classes in the wsgiserver.ssl_adapters
|
||||
may also register your own classes in the cheroot.server.ssl_adapters
|
||||
dict."""
|
||||
|
||||
statistics = False
|
||||
|
@ -141,9 +144,29 @@ class Server(ServerAdapter):
|
|||
which declares it covers WSGI version 1.0.1 but still mandates the
|
||||
wsgi.version (1, 0)] and ('u', 0), an experimental unicode version.
|
||||
You may create and register your own experimental versions of the WSGI
|
||||
protocol by adding custom classes to the wsgiserver.wsgi_gateways dict."""
|
||||
protocol by adding custom classes to the cheroot.server.wsgi_gateways dict.
|
||||
"""
|
||||
|
||||
peercreds = False
|
||||
"""If True, peer cred lookup for UNIX domain socket will put to WSGI env.
|
||||
|
||||
This information will then be available through WSGI env vars:
|
||||
* X_REMOTE_PID
|
||||
* X_REMOTE_UID
|
||||
* X_REMOTE_GID
|
||||
"""
|
||||
|
||||
peercreds_resolve = False
|
||||
"""If True, username/group will be looked up in the OS from peercreds.
|
||||
|
||||
This information will then be available through WSGI env vars:
|
||||
* REMOTE_USER
|
||||
* X_REMOTE_USER
|
||||
* X_REMOTE_GROUP
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
"""Initialize Server instance."""
|
||||
self.bus = cherrypy.engine
|
||||
self.httpserver = None
|
||||
self.interrupt = None
|
||||
|
@ -156,7 +179,7 @@ class Server(ServerAdapter):
|
|||
if httpserver is None:
|
||||
from cherrypy import _cpwsgi_server
|
||||
httpserver = _cpwsgi_server.CPWSGIServer(self)
|
||||
if isinstance(httpserver, basestring):
|
||||
if isinstance(httpserver, text_or_bytes):
|
||||
# Is anyone using this? Can I add an arg?
|
||||
httpserver = attributes(httpserver)(self)
|
||||
return httpserver, self.bind_addr
|
||||
|
@ -165,22 +188,28 @@ class Server(ServerAdapter):
|
|||
"""Start the HTTP server."""
|
||||
if not self.httpserver:
|
||||
self.httpserver, self.bind_addr = self.httpserver_from_self()
|
||||
ServerAdapter.start(self)
|
||||
super(Server, self).start()
|
||||
start.priority = 75
|
||||
|
||||
def _get_bind_addr(self):
|
||||
@property
|
||||
def bind_addr(self):
|
||||
"""Return bind address.
|
||||
|
||||
A (host, port) tuple for TCP sockets or a str for Unix domain sockts.
|
||||
"""
|
||||
if self.socket_file:
|
||||
return self.socket_file
|
||||
if self.socket_host is None and self.socket_port is None:
|
||||
return None
|
||||
return (self.socket_host, self.socket_port)
|
||||
|
||||
def _set_bind_addr(self, value):
|
||||
@bind_addr.setter
|
||||
def bind_addr(self, value):
|
||||
if value is None:
|
||||
self.socket_file = None
|
||||
self.socket_host = None
|
||||
self.socket_port = None
|
||||
elif isinstance(value, basestring):
|
||||
elif isinstance(value, text_or_bytes):
|
||||
self.socket_file = value
|
||||
self.socket_host = None
|
||||
self.socket_port = None
|
||||
|
@ -189,17 +218,14 @@ class Server(ServerAdapter):
|
|||
self.socket_host, self.socket_port = value
|
||||
self.socket_file = None
|
||||
except ValueError:
|
||||
raise ValueError("bind_addr must be a (host, port) tuple "
|
||||
"(for TCP sockets) or a string (for Unix "
|
||||
"domain sockets), not %r" % value)
|
||||
bind_addr = property(
|
||||
_get_bind_addr,
|
||||
_set_bind_addr,
|
||||
doc='A (host, port) tuple for TCP sockets or '
|
||||
'a str for Unix domain sockets.')
|
||||
raise ValueError('bind_addr must be a (host, port) tuple '
|
||||
'(for TCP sockets) or a string (for Unix '
|
||||
'domain sockets), not %r' % value)
|
||||
|
||||
def base(self):
|
||||
"""Return the base (scheme://host[:port] or sock file) for this server.
|
||||
"""Return the base for this server.
|
||||
|
||||
e.i. scheme://host[:port] or sock file
|
||||
"""
|
||||
if self.socket_file:
|
||||
return self.socket_file
|
||||
|
@ -215,12 +241,12 @@ class Server(ServerAdapter):
|
|||
port = self.socket_port
|
||||
|
||||
if self.ssl_certificate:
|
||||
scheme = "https"
|
||||
scheme = 'https'
|
||||
if port != 443:
|
||||
host += ":%s" % port
|
||||
host += ':%s' % port
|
||||
else:
|
||||
scheme = "http"
|
||||
scheme = 'http'
|
||||
if port != 80:
|
||||
host += ":%s" % port
|
||||
host += ':%s' % port
|
||||
|
||||
return "%s://%s" % (scheme, host)
|
||||
return '%s://%s' % (scheme, host)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue