diff --git a/requirements.txt b/requirements.txt index e0fd734..0fbb1c5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,14 +1,5 @@ cherrypy==18.9.0 configobj==5.0.8 -Jinja2==3.1.3 -paver==1.3.4 -pip==24.0 psutil==5.9.8 pyyaml==6.0.1 redis==5.0.3 -requests==2.31.0 -rpctools==0.3.1 -sh==2.0.6 -six==1.16.0 -SQLAlchemy==1.4.52 -wheel==0.43.0 diff --git a/sideboard/__init__.py b/sideboard/__init__.py index 825ec9a..01d9146 100644 --- a/sideboard/__init__.py +++ b/sideboard/__init__.py @@ -2,7 +2,6 @@ import os import importlib -import six import cherrypy from sideboard._version import __version__ diff --git a/sideboard/lib/__init__.py b/sideboard/lib/__init__.py index 3d4b29c..5f31f26 100644 --- a/sideboard/lib/__init__.py +++ b/sideboard/lib/__init__.py @@ -1,19 +1,16 @@ from __future__ import unicode_literals -import six from sideboard.internal.autolog import log from sideboard.config import config, ConfigurationError, parse_config from sideboard.lib._utils import is_listy, listify, serializer, cached_property, request_cached_property, class_property, entry_point, RWGuard -from sideboard.lib._cp import stopped, on_startup, on_shutdown, mainloop, ajax, renders_template, render_with_templates, restricted, all_restricted, register_authenticator +from sideboard.lib._cp import stopped, on_startup, on_shutdown, mainloop, ajax, renders_template, restricted, all_restricted, register_authenticator from sideboard.lib._threads import threadlocal __all__ = ['log', 'ConfigurationError', 'parse_config', 'is_listy', 'listify', 'serializer', 'cached_property', 'class_property', 'entry_point', - 'stopped', 'on_startup', 'on_shutdown', 'mainloop', 'ajax', 'renders_template', 'render_with_templates', + 'stopped', 'on_startup', 'on_shutdown', 'mainloop', 'ajax', 'renders_template', 'restricted', 'all_restricted', 'register_authenticator', 'threadlocal', 'listify', 'serializer', 'cached_property', 'request_cached_property', 'is_listy', 'entry_point', 'RWGuard'] -if six.PY2: - __all__ = [s.encode('ascii') for s in __all__] diff --git a/sideboard/lib/_cp.py b/sideboard/lib/_cp.py index d409533..4b0e9b1 100644 --- a/sideboard/lib/_cp.py +++ b/sideboard/lib/_cp.py @@ -4,9 +4,6 @@ from functools import wraps from collections import defaultdict -from six.moves.urllib_parse import quote - -import jinja2 import cherrypy from sideboard.lib._redissession import RedisSession @@ -185,35 +182,6 @@ def _guess_autoescape(template_name): return ext in ('html', 'htm', 'xml') -class render_with_templates(object): - """ - Class decorator for CherryPy application objects which causes all of your page - handler methods which return dictionaries to render Jinja templates found in this - directory using those dictionaries. So if you have a page handler called my_page - which returns a dictionary, the template my_page.html in the template_dir - directory will be rendered with that dictionary. An "env" attribute gets added - to the class which is a Jinja environment. - - For convenience, if the optional "restricted" parameter is passed, this class is - also passed through the @all_restricted class decorator. - """ - def __init__(self, template_dir, restricted=False): - self.template_dir, self.restricted = template_dir, restricted - - def __call__(self, klass): - klass.env = jinja2.Environment(autoescape=_guess_autoescape, loader=jinja2.FileSystemLoader(self.template_dir)) - klass.env.filters['jsonify'] = lambda x: klass.env.filters['safe'](json.dumps(x, cls=serializer)) - - if self.restricted: - all_restricted(self.restricted)(klass) - - for name, func in list(klass.__dict__.items()): - if hasattr(func, '__call__'): - setattr(klass, name, renders_template(func)) - - return klass - - class all_restricted(object): """Invokes the @restricted decorator on all methods of a class.""" def __init__(self, ident): diff --git a/sideboard/lib/_threads.py b/sideboard/lib/_threads.py index 1fced9f..afcfae9 100644 --- a/sideboard/lib/_threads.py +++ b/sideboard/lib/_threads.py @@ -6,8 +6,6 @@ import traceback import threading -import six - from sideboard.lib import log, config, on_startup, on_shutdown, class_property from sideboard.debugging import register_diagnostics_status_function @@ -38,12 +36,8 @@ def _thread_name_insert(self): _set_current_thread_ids_from(self) threading.Thread._bootstrap_inner_original(self) -if six.PY3: threading.Thread._bootstrap_inner_original = threading.Thread._bootstrap_inner threading.Thread._bootstrap_inner = _thread_name_insert -else: - threading.Thread._bootstrap_inner_original = threading.Thread._Thread__bootstrap - threading.Thread._Thread__bootstrap = _thread_name_insert # set the ID's of the main thread threading.current_thread().name = 'sideboard_main' diff --git a/sideboard/server.py b/sideboard/server.py index a1b3133..53981b6 100755 --- a/sideboard/server.py +++ b/sideboard/server.py @@ -2,7 +2,6 @@ import os import sys -import six import cherrypy from sideboard.lib import config, threadlocal @@ -15,12 +14,10 @@ def reset_threadlocal(): cherrypy_config = {} for setting, value in config['cherrypy'].items(): - if isinstance(value, six.string_types): + if isinstance(value, str): if value.isdigit(): value = int(value) elif value.lower() in ['true', 'false']: value = value.lower() == 'true' - elif six.PY2: - value = value.encode('utf-8') cherrypy_config[setting] = value cherrypy.config.update(cherrypy_config) diff --git a/sideboard/tests/__init__.py b/sideboard/tests/__init__.py index c806b9e..ea4e728 100644 --- a/sideboard/tests/__init__.py +++ b/sideboard/tests/__init__.py @@ -4,10 +4,6 @@ from contextlib import closing import pytest -import sqlalchemy -from sqlalchemy import event -from sqlalchemy.orm import sessionmaker -from sqlalchemy.pool import NullPool from sideboard.lib import config @@ -46,17 +42,3 @@ def patch_config(value, *path, **kwargs): request.addfinalizer(lambda: conf.__setitem__(path[-1], orig_val)) conf[path[-1]] = value return patch_config - - -def patch_session(Session, request): - orig_engine, orig_factory = Session.engine, Session.session_factory - request.addfinalizer(lambda: setattr(Session, 'engine', orig_engine)) - request.addfinalizer(lambda: setattr(Session, 'session_factory', orig_factory)) - - name = Session.__module__.split('.')[0] - db_path = '/tmp/{}.db'.format(name) - Session.engine = sqlalchemy.create_engine('sqlite+pysqlite:///' + db_path, poolclass=NullPool) - event.listen(Session.engine, 'connect', lambda conn, record: conn.execute('pragma foreign_keys=ON')) - Session.session_factory = sessionmaker(bind=Session.engine, autoflush=False, autocommit=False, - query_cls=Session.QuerySubclass) - Session.initialize_db(drop=True) diff --git a/sideboard/tests/test_lib.py b/sideboard/tests/test_lib.py index aa11cb4..1d67429 100644 --- a/sideboard/tests/test_lib.py +++ b/sideboard/tests/test_lib.py @@ -7,7 +7,6 @@ from collections.abc import Sequence, Set from threading import current_thread, Thread -import six import pytest import cherrypy from mock import Mock @@ -80,8 +79,6 @@ class TestIsListy(TestCase): def test_sized_builtin(self): sized = [(), (1,), [], [1], set(), set([1]), frozenset(), frozenset([1]), bytearray(), bytearray(1)] - if six.PY2: - sized.extend([xrange(0), xrange(2), buffer(''), buffer('x')]) for x in sized: assert is_listy(x) diff --git a/sideboard/tests/test_logging.py b/sideboard/tests/test_logging.py index f0043ee..da5883a 100644 --- a/sideboard/tests/test_logging.py +++ b/sideboard/tests/test_logging.py @@ -2,7 +2,7 @@ import logging import unittest -from six import StringIO +from io import StringIO class LoggerSetupTest(unittest.TestCase):