mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-12 08:16:06 -07:00
Update cherrypy==18.9.0
This commit is contained in:
parent
2fc618c01f
commit
51196a7fb1
137 changed files with 44442 additions and 11582 deletions
|
@ -452,6 +452,6 @@ class WSGIErrorHandler(logging.Handler):
|
|||
|
||||
class LazyRfc3339UtcTime(object):
|
||||
def __str__(self):
|
||||
"""Return now() in RFC3339 UTC Format."""
|
||||
now = datetime.datetime.now()
|
||||
return now.isoformat('T') + 'Z'
|
||||
"""Return utcnow() in RFC3339 UTC Format."""
|
||||
iso_formatted_now = datetime.datetime.utcnow().isoformat('T')
|
||||
return f'{iso_formatted_now!s}Z'
|
||||
|
|
|
@ -622,13 +622,15 @@ def autovary(ignore=None, debug=False):
|
|||
|
||||
|
||||
def convert_params(exception=ValueError, error=400):
|
||||
"""Convert request params based on function annotations, with error handling.
|
||||
"""Convert request params based on function annotations.
|
||||
|
||||
exception
|
||||
Exception class to catch.
|
||||
This function also processes errors that are subclasses of ``exception``.
|
||||
|
||||
status
|
||||
The HTTP error code to return to the client on failure.
|
||||
:param BaseException exception: Exception class to catch.
|
||||
:type exception: BaseException
|
||||
|
||||
:param error: The HTTP status code to return to the client on failure.
|
||||
:type error: int
|
||||
"""
|
||||
request = cherrypy.serving.request
|
||||
types = request.handler.callable.__annotations__
|
||||
|
|
|
@ -47,7 +47,9 @@ try:
|
|||
import pstats
|
||||
|
||||
def new_func_strip_path(func_name):
|
||||
"""Make profiler output more readable by adding `__init__` modules' parents
|
||||
"""Add ``__init__`` modules' parents.
|
||||
|
||||
This makes the profiler output more readable.
|
||||
"""
|
||||
filename, line, name = func_name
|
||||
if filename.endswith('__init__.py'):
|
||||
|
|
|
@ -188,7 +188,7 @@ class Parser(configparser.ConfigParser):
|
|||
|
||||
def dict_from_file(self, file):
|
||||
if hasattr(file, 'read'):
|
||||
self.readfp(file)
|
||||
self.read_file(file)
|
||||
else:
|
||||
self.read(file)
|
||||
return self.as_dict()
|
||||
|
|
|
@ -1,19 +1,18 @@
|
|||
"""Module with helpers for serving static files."""
|
||||
|
||||
import mimetypes
|
||||
import os
|
||||
import platform
|
||||
import re
|
||||
import stat
|
||||
import mimetypes
|
||||
import urllib.parse
|
||||
import unicodedata
|
||||
|
||||
import urllib.parse
|
||||
from email.generator import _make_boundary as make_boundary
|
||||
from io import UnsupportedOperation
|
||||
|
||||
import cherrypy
|
||||
from cherrypy._cpcompat import ntob
|
||||
from cherrypy.lib import cptools, httputil, file_generator_limited
|
||||
from cherrypy.lib import cptools, file_generator_limited, httputil
|
||||
|
||||
|
||||
def _setup_mimetypes():
|
||||
|
@ -185,7 +184,10 @@ def serve_fileobj(fileobj, content_type=None, disposition=None, name=None,
|
|||
|
||||
|
||||
def _serve_fileobj(fileobj, content_type, content_length, debug=False):
|
||||
"""Internal. Set response.body to the given file object, perhaps ranged."""
|
||||
"""Set ``response.body`` to the given file object, perhaps ranged.
|
||||
|
||||
Internal helper.
|
||||
"""
|
||||
response = cherrypy.serving.response
|
||||
|
||||
# HTTP/1.0 didn't have Range/Accept-Ranges headers, or the 206 code
|
||||
|
|
|
@ -494,7 +494,7 @@ class Bus(object):
|
|||
"Cannot reconstruct command from '-c'. "
|
||||
'Ref: https://github.com/cherrypy/cherrypy/issues/1545')
|
||||
except AttributeError:
|
||||
"""It looks Py_GetArgcArgv is completely absent in some environments
|
||||
"""It looks Py_GetArgcArgv's completely absent in some environments
|
||||
|
||||
It is known, that there's no Py_GetArgcArgv in MS Windows and
|
||||
``ctypes`` module is completely absent in Google AppEngine
|
||||
|
|
|
@ -136,6 +136,9 @@ class HTTPTests(helper.CPWebCase):
|
|||
self.assertStatus(200)
|
||||
self.assertBody(b'Hello world!')
|
||||
|
||||
response.close()
|
||||
c.close()
|
||||
|
||||
# Now send a message that has no Content-Length, but does send a body.
|
||||
# Verify that CP times out the socket and responds
|
||||
# with 411 Length Required.
|
||||
|
@ -159,6 +162,9 @@ class HTTPTests(helper.CPWebCase):
|
|||
self.status = str(response.status)
|
||||
self.assertStatus(411)
|
||||
|
||||
response.close()
|
||||
c.close()
|
||||
|
||||
def test_post_multipart(self):
|
||||
alphabet = 'abcdefghijklmnopqrstuvwxyz'
|
||||
# generate file contents for a large post
|
||||
|
@ -184,6 +190,9 @@ class HTTPTests(helper.CPWebCase):
|
|||
parts = ['%s * 65536' % ch for ch in alphabet]
|
||||
self.assertBody(', '.join(parts))
|
||||
|
||||
response.close()
|
||||
c.close()
|
||||
|
||||
def test_post_filename_with_special_characters(self):
|
||||
"""Testing that we can handle filenames with special characters.
|
||||
|
||||
|
@ -217,6 +226,9 @@ class HTTPTests(helper.CPWebCase):
|
|||
self.assertStatus(200)
|
||||
self.assertBody(fname)
|
||||
|
||||
response.close()
|
||||
c.close()
|
||||
|
||||
def test_malformed_request_line(self):
|
||||
if getattr(cherrypy.server, 'using_apache', False):
|
||||
return self.skip('skipped due to known Apache differences...')
|
||||
|
@ -264,6 +276,9 @@ class HTTPTests(helper.CPWebCase):
|
|||
self.body = response.fp.read(20)
|
||||
self.assertBody('Illegal header line.')
|
||||
|
||||
response.close()
|
||||
c.close()
|
||||
|
||||
def test_http_over_https(self):
|
||||
if self.scheme != 'https':
|
||||
return self.skip('skipped (not running HTTPS)... ')
|
||||
|
|
|
@ -150,6 +150,8 @@ class IteratorTest(helper.CPWebCase):
|
|||
self.assertStatus(200)
|
||||
self.assertBody('0')
|
||||
|
||||
itr_conn.close()
|
||||
|
||||
# Now we do the same check with streaming - some classes will
|
||||
# be automatically closed, while others cannot.
|
||||
stream_counts = {}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
"""Basic tests for the CherryPy core: request handling."""
|
||||
|
||||
import datetime
|
||||
import logging
|
||||
|
||||
from cheroot.test import webtest
|
||||
|
@ -197,6 +198,33 @@ def test_custom_log_format(log_tracker, monkeypatch, server):
|
|||
)
|
||||
|
||||
|
||||
def test_utc_in_timez(monkeypatch):
|
||||
"""Test that ``LazyRfc3339UtcTime`` is rendered as ``str`` using UTC timestamp."""
|
||||
utcoffset8_local_time_in_naive_utc = (
|
||||
datetime.datetime(
|
||||
year=2020,
|
||||
month=1,
|
||||
day=1,
|
||||
hour=1,
|
||||
minute=23,
|
||||
second=45,
|
||||
tzinfo=datetime.timezone(datetime.timedelta(hours=8)),
|
||||
)
|
||||
.astimezone(datetime.timezone.utc)
|
||||
.replace(tzinfo=None)
|
||||
)
|
||||
|
||||
class mock_datetime:
|
||||
@classmethod
|
||||
def utcnow(cls):
|
||||
return utcoffset8_local_time_in_naive_utc
|
||||
|
||||
monkeypatch.setattr('datetime.datetime', mock_datetime)
|
||||
rfc3339_utc_time = str(cherrypy._cplogging.LazyRfc3339UtcTime())
|
||||
expected_time = '2019-12-31T17:23:45Z'
|
||||
assert rfc3339_utc_time == expected_time
|
||||
|
||||
|
||||
def test_timez_log_format(log_tracker, monkeypatch, server):
|
||||
"""Test a customized access_log_format string, which is a
|
||||
feature of _cplogging.LogManager.access()."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue