mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-08-14 02:26:58 -07:00
Update cherrypy-18.6.1
This commit is contained in:
parent
b3ae6bd695
commit
ebffd124f6
57 changed files with 1269 additions and 1509 deletions
|
@ -1,11 +1,11 @@
|
|||
import sys
|
||||
import time
|
||||
import collections
|
||||
import operator
|
||||
from http.cookies import SimpleCookie, CookieError
|
||||
|
||||
import uuid
|
||||
|
||||
import six
|
||||
from six.moves.http_cookies import SimpleCookie, CookieError
|
||||
|
||||
from more_itertools import consume
|
||||
|
||||
import cherrypy
|
||||
|
@ -92,28 +92,36 @@ class HookMap(dict):
|
|||
|
||||
def run(self, point):
|
||||
"""Execute all registered Hooks (callbacks) for the given point."""
|
||||
exc = None
|
||||
hooks = self[point]
|
||||
hooks.sort()
|
||||
self.run_hooks(iter(sorted(self[point])))
|
||||
|
||||
@classmethod
|
||||
def run_hooks(cls, hooks):
|
||||
"""Execute the indicated hooks, trapping errors.
|
||||
|
||||
Hooks with ``.failsafe == True`` are guaranteed to run
|
||||
even if others at the same hookpoint fail. In this case,
|
||||
log the failure and proceed on to the next hook. The only
|
||||
way to stop all processing from one of these hooks is
|
||||
to raise a BaseException like SystemExit or
|
||||
KeyboardInterrupt and stop the whole server.
|
||||
"""
|
||||
assert isinstance(hooks, collections.abc.Iterator)
|
||||
quiet_errors = (
|
||||
cherrypy.HTTPError,
|
||||
cherrypy.HTTPRedirect,
|
||||
cherrypy.InternalRedirect,
|
||||
)
|
||||
safe = filter(operator.attrgetter('failsafe'), hooks)
|
||||
for hook in hooks:
|
||||
# Some hooks are guaranteed to run even if others at
|
||||
# the same hookpoint fail. We will still log the failure,
|
||||
# but proceed on to the next hook. The only way
|
||||
# to stop all processing from one of these hooks is
|
||||
# to raise SystemExit and stop the whole server.
|
||||
if exc is None or hook.failsafe:
|
||||
try:
|
||||
hook()
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
raise
|
||||
except (cherrypy.HTTPError, cherrypy.HTTPRedirect,
|
||||
cherrypy.InternalRedirect):
|
||||
exc = sys.exc_info()[1]
|
||||
except Exception:
|
||||
exc = sys.exc_info()[1]
|
||||
cherrypy.log(traceback=True, severity=40)
|
||||
if exc:
|
||||
raise exc
|
||||
try:
|
||||
hook()
|
||||
except quiet_errors:
|
||||
cls.run_hooks(safe)
|
||||
raise
|
||||
except Exception:
|
||||
cherrypy.log(traceback=True, severity=40)
|
||||
cls.run_hooks(safe)
|
||||
raise
|
||||
|
||||
def __copy__(self):
|
||||
newmap = self.__class__()
|
||||
|
@ -141,7 +149,7 @@ def hooks_namespace(k, v):
|
|||
# hookpoint per path (e.g. "hooks.before_handler.1").
|
||||
# Little-known fact you only get from reading source ;)
|
||||
hookpoint = k.split('.', 1)[0]
|
||||
if isinstance(v, six.string_types):
|
||||
if isinstance(v, str):
|
||||
v = cherrypy.lib.reprconf.attributes(v)
|
||||
if not isinstance(v, Hook):
|
||||
v = Hook(v)
|
||||
|
@ -704,12 +712,6 @@ class Request(object):
|
|||
'strings for this resource must be encoded with %r.' %
|
||||
self.query_string_encoding)
|
||||
|
||||
# Python 2 only: keyword arguments must be byte strings (type 'str').
|
||||
if six.PY2:
|
||||
for key, value in p.items():
|
||||
if isinstance(key, six.text_type):
|
||||
del p[key]
|
||||
p[key.encode(self.query_string_encoding)] = value
|
||||
self.params.update(p)
|
||||
|
||||
def process_headers(self):
|
||||
|
@ -786,11 +788,11 @@ class ResponseBody(object):
|
|||
|
||||
def __set__(self, obj, value):
|
||||
# Convert the given value to an iterable object.
|
||||
if isinstance(value, six.text_type):
|
||||
if isinstance(value, str):
|
||||
raise ValueError(self.unicode_err)
|
||||
elif isinstance(value, list):
|
||||
# every item in a list must be bytes...
|
||||
if any(isinstance(item, six.text_type) for item in value):
|
||||
if any(isinstance(item, str) for item in value):
|
||||
raise ValueError(self.unicode_err)
|
||||
|
||||
obj._body = encoding.prepare_iter(value)
|
||||
|
@ -903,9 +905,9 @@ class Response(object):
|
|||
if cookie:
|
||||
for line in cookie.split('\r\n'):
|
||||
name, value = line.split(': ', 1)
|
||||
if isinstance(name, six.text_type):
|
||||
if isinstance(name, str):
|
||||
name = name.encode('ISO-8859-1')
|
||||
if isinstance(value, six.text_type):
|
||||
if isinstance(value, str):
|
||||
value = headers.encode(value)
|
||||
h.append((name, value))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue