Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade Python dependencies #12165

Merged
merged 4 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion kolibri/deployment/default/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from django.conf import locale
from morango.constants import settings as morango_settings
from tzlocal import get_localzone
from tzlocal.utils import ZoneInfoNotFoundError

import kolibri
from kolibri.deployment.default.cache import CACHES
Expand Down Expand Up @@ -309,7 +310,7 @@

try:
TIME_ZONE = get_localzone().zone
except (pytz.UnknownTimeZoneError, ValueError):
except (pytz.UnknownTimeZoneError, ValueError, ZoneInfoNotFoundError):
# Do not fail at this point because a timezone was not
# detected.
TIME_ZONE = pytz.utc.zone
Expand Down
6 changes: 2 additions & 4 deletions kolibri/utils/kolibri_whitenoise.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import stat
from collections import OrderedDict
from gzip import GzipFile
from http import HTTPStatus
from io import BufferedIOBase
from urllib.parse import parse_qs
from urllib.parse import urljoin
Expand All @@ -13,7 +14,6 @@
from django.core.files.storage import FileSystemStorage
from django.utils._os import safe_join
from whitenoise import WhiteNoise
from whitenoise.httpstatus_backport import HTTPStatus
from whitenoise.responders import FileEntry
from whitenoise.responders import MissingFileError
from whitenoise.responders import NOT_ALLOWED_RESPONSE
Expand All @@ -27,8 +27,6 @@

compressed_file_extensions = ("gz",)

not_found_status = HTTPStatus(404, "Not Found")


class NotFoundStaticFile(object):
"""
Expand All @@ -37,7 +35,7 @@ class NotFoundStaticFile(object):
"""

def get_response(self, method, request_headers):
return Response(not_found_status, [], None)
return Response(status=HTTPStatus.NOT_FOUND, headers=[], file=None)


NOT_FOUND = NotFoundStaticFile()
Expand Down
23 changes: 1 addition & 22 deletions kolibri/utils/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
import os
from logging.handlers import TimedRotatingFileHandler

from colorlog import ColoredFormatter
from colorlog import TTYColoredFormatter as BaseTTYColoredFormatter


GET_FILES_TO_DELETE = "getFilesToDelete"
DO_ROLLOVER = "doRollover"
Expand Down Expand Up @@ -168,24 +165,6 @@ def filter(self, record):
return record.levelno < logging.ERROR


class TTYColoredFormatter(BaseTTYColoredFormatter):
"""
A logging formatter that can be used to colorize output to a TTY.
Subclassed from the base TTY formatter to allow slightly more more permissive
color formatting when we are running using the NPM concurrently package,
which does not register as a TTY context.
"""

def color(self, log_colors, level_name):
"""
Only returns colors if STDOUT is a TTY, or if we are running in a
NPM concurrently context.
"""
if not self.stream.isatty() and "FORCE_COLOR" not in os.environ:
log_colors = {}
return ColoredFormatter.color(self, log_colors, level_name)


def get_default_logging_config(LOG_ROOT, debug=False, debug_database=False):
"""
A minimal logging config for just kolibri without any Django
Expand Down Expand Up @@ -255,7 +234,7 @@ def get_default_logging_config(LOG_ROOT, debug=False, debug_database=False):
},
"simple_date": {"format": "%(levelname)s %(asctime)s %(name)s %(message)s"},
"color": {
"()": "kolibri.utils.logger.TTYColoredFormatter",
"()": "colorlog.ColoredFormatter",
"format": "%(log_color)s%(levelname)-8s %(asctime)s %(message)s",
"log_colors": LOG_COLORS,
},
Expand Down
2 changes: 1 addition & 1 deletion kolibri/utils/tests/test_kolibri_whitenoise.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
import re
import tempfile
from gzip import GzipFile
from http import HTTPStatus

import pytest
from mock import MagicMock
from mock import mock_open
from mock import patch
from whitenoise.httpstatus_backport import HTTPStatus
from whitenoise.responders import Response

from kolibri.utils.kolibri_whitenoise import COMPRESSED_FILE_FOR_REGULAR_PATH
Expand Down
28 changes: 14 additions & 14 deletions requirements/base.txt
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
diskcache==4.1.0
diskcache==5.6.3
django-filter==21.1
django-js-reverse==0.10.2
djangorestframework==3.14.0
django==3.2.25
colorlog==3.2.0 # pyup: <4.0.0
configobj==5.0.6
colorlog==6.8.2
configobj==5.0.8
django-mptt==0.14.0
requests==2.27.1
cheroot==8.6.0
cheroot==10.0.1
magicbus==4.1.2
le-utils==0.2.6
jsonfield==3.1.0
morango==0.8.1
tzlocal==2.1
pytz==2022.1
python-dateutil==2.8.2
sqlalchemy==1.4.49
semver==2.8.1
tzlocal==4.2
pytz==2024.1
python-dateutil==2.9.0.post0
sqlalchemy==1.4.52
semver==2.13.0
django-redis-cache==3.0.1
redis==3.2.1
redis==3.5.3
html5lib==1.1
zeroconf-py2compat==0.19.17
Click==7.0
whitenoise==4.1.4
Click==8.0.4
whitenoise==5.3.0
idna==3.7
ifaddr==0.1.7 # Pin as version 0.2.0 only supports Python 3.7 and above
importlib-metadata==2.1.1
importlib_resources==3.3.1
importlib-metadata==4.8.3
importlib_resources==5.4.0
json-schema-validator==2.4.1
Loading