Skip to content

Commit

Permalink
Removing unused requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbyt3r committed Apr 17, 2024
1 parent b875183 commit aa88b78
Show file tree
Hide file tree
Showing 9 changed files with 4 additions and 79 deletions.
9 changes: 0 additions & 9 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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
1 change: 0 additions & 1 deletion sideboard/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import os
import importlib

import six
import cherrypy

from sideboard._version import __version__
Expand Down
7 changes: 2 additions & 5 deletions sideboard/lib/__init__.py
Original file line number Diff line number Diff line change
@@ -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__]
32 changes: 0 additions & 32 deletions sideboard/lib/_cp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down
6 changes: 0 additions & 6 deletions sideboard/lib/_threads.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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'
Expand Down
5 changes: 1 addition & 4 deletions sideboard/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import os
import sys

import six
import cherrypy

from sideboard.lib import config, threadlocal
Expand All @@ -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)
18 changes: 0 additions & 18 deletions sideboard/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
3 changes: 0 additions & 3 deletions sideboard/tests/test_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion sideboard/tests/test_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import logging
import unittest

from six import StringIO
from io import StringIO


class LoggerSetupTest(unittest.TestCase):
Expand Down

0 comments on commit aa88b78

Please sign in to comment.