Skip to content

Commit

Permalink
Merge pull request #110 from magfest/next
Browse files Browse the repository at this point in the history
Updating python libraries
  • Loading branch information
bitbyt3r authored Apr 14, 2024
2 parents 83fec4e + dab23cf commit 5701f91
Show file tree
Hide file tree
Showing 26 changed files with 230 additions and 686 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/ci-docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@ jobs:
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build Test Docker Image
uses: docker/build-push-action@v2
with:
context: "."
push: false
tags: ghcr.io/${{ github.repository }}:${{ github.ref_name }}-test
target: test

- name: Execute Tests
run: docker run ghcr.io/${{ github.repository }}:${{ github.ref_name }}-test

- name: Build and Push Docker Image
uses: docker/build-push-action@v2
with:
Expand Down
20 changes: 16 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.6.14
FROM python:3.12.3 as build
MAINTAINER RAMS Project "code@magfest.org"
LABEL version.sideboard ="1.0"
WORKDIR /app
Expand Down Expand Up @@ -69,11 +69,23 @@ RUN curl -SLO "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-
# required for python-prctl
RUN apt-get update && apt-get install -y libcap-dev && rm -rf /var/lib/apt/lists/*

ADD . /app/
RUN pip3 install virtualenv \
&& virtualenv --always-copy /app/env \
&& /app/env/bin/pip3 install paver "setuptools<58"
&& /app/env/bin/pip3 install paver

ADD requirements.txt requirements.txt
ADD test_requirements.txt test_requirements.txt
ADD setup.py setup.py
ADD sideboard/_version.py sideboard/_version.py
ADD pavement.py pavement.py

RUN /app/env/bin/paver install_deps
ADD . /app/

FROM build as test
RUN /app/env/bin/pip install mock pytest
CMD /app/env/bin/python3 -m pytest

FROM build as release
CMD /app/env/bin/python3 /app/sideboard/run_server.py
EXPOSE 8282
EXPOSE 8282
29 changes: 0 additions & 29 deletions pavement.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import os
import sys
import glob
import pkg_resources
from itertools import chain
from os.path import abspath, dirname, exists, join

Expand Down Expand Up @@ -110,28 +109,6 @@ def pull_plugins():
sh('cd "{}";git pull'.format(plugin_dir))


@task
def assert_all_files_import_unicode_literals():
"""
error if a python file is found in sideboard or plugins that does not import unicode_literals; \
this is skipped for Python 3
"""
if sys.version_info[0] == 2:
all_files_found = []
cmd = ("find '%s' -name '*.py' ! -size 0 "
"-exec grep -RL 'from __future__ import.*unicode_literals.*$' {} \;")
for test_dir in chain(['sideboard'], collect_plugin_dirs(module=True)):
output = sh(cmd % test_dir, capture=True)
if output:
all_files_found.append(output)

if all_files_found:
print('the following files did not include "from __future__ import unicode_literals":')
print(''.join(all_files_found))
raise BuildFailure("there were files that didn't include "
'"from __future__ import unicode_literals"')


@task
def assert_all_projects_correctly_define_a_version():
"""
Expand Down Expand Up @@ -180,12 +157,6 @@ def run_all_assertions():
def create_plugin(options):
"""create a plugin skeleton to start a new project"""

# this is actually needed thanks to the skeleton using jinja2 (and six, although that's changeable)
try:
pkg_resources.get_distribution("sideboard")
except pkg_resources.DistributionNotFound:
raise BuildFailure("This command must be run from within a configured virtual environment.")

plugin_name = options.create_plugin.name

if getattr(options.create_plugin, 'drop', False) and (PLUGINS_DIR / path(plugin_name.replace('_', '-'))).exists():
Expand Down
31 changes: 15 additions & 16 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
cherrypy==17.3.0
configobj>=5.0.5
Jinja2>=2.7
logging_unterpolation>=0.2.0
paver>=1.2.2
pip>=1.5.6
psutil>=5.4.1
python-prctl>=1.6.1; 'linux' in sys_platform
redis==4.3.6
requests>=2.2.1
rpctools>=0.3.1
sh>=1.09
six>=1.5.2
SQLAlchemy>=1.1.0
wheel>=0.24.0
ws4py>=0.3.2
cherrypy==18.9.0
configobj==5.0.8
Jinja2==3.1.3
paver==1.3.4
pip==24.0
psutil==5.9.8
python-prctl==1.8.1; 'linux' in sys_platform
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
ws4py==0.5.1
2 changes: 1 addition & 1 deletion sideboard/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import re

from os import unlink
from collections import Sized, Iterable, Mapping
from collections.abc import Sized, Iterable, Mapping
from copy import deepcopy
from tempfile import NamedTemporaryFile

Expand Down
5 changes: 1 addition & 4 deletions sideboard/configspec.ini
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ ws.call_timeout = integer(default=10) # seconds
ws.poll_interval = integer(default=300) # seconds
ws.reconnect_interval = integer(default=60) # seconds

# Sideboard exposes two websocket endpoints. The first is at /wsrpc and doesn't
# require authentication, with the expectation being that the frontend webserver
# which reverse proxies to Sideboard will either block or require a client cert
# for this endpoint. The second is at /ws and by default requires a logged-in
# Sideboard exposes a websocket at /ws and by default requires a logged-in
# user to work. This setting can turn off that authentication check, which is
# useful for development or for applications which require no authentication.
ws.auth_required = boolean(default=True)
Expand Down
3 changes: 0 additions & 3 deletions sideboard/internal/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
import os
import logging.config

import logging_unterpolation

from sideboard.config import config, get_config_root


Expand All @@ -20,7 +18,6 @@ def format(self, record):


def _configure_logging():
logging_unterpolation.patch_logging()
fname = os.path.join(get_config_root(), 'logging.cfg')
if os.path.exists(fname):
logging.config.fileConfig(fname, disable_existing_loggers=True)
Expand Down
9 changes: 4 additions & 5 deletions sideboard/jsonrpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import traceback

import cherrypy
from cherrypy.lib.jsontools import json_decode

from sideboard.lib import log, config, serializer
from sideboard.websockets import trigger_delayed_notifications
Expand Down Expand Up @@ -31,7 +30,7 @@ def force_json_in():
if cherrypy.request.method in ('POST', 'PUT'):
body = request.body.fp.read()
try:
cherrypy.serving.request.json = json_decode(body.decode('utf-8'))
cherrypy.serving.request.json = json.loads(body.decode('utf-8'))
except ValueError:
raise cherrypy.HTTPError(400, 'Invalid JSON document')

Expand All @@ -49,14 +48,14 @@ def jsonrpc_handler(self=None):

def error(code, message):
body = {'jsonrpc': '2.0', 'id': id, 'error': {'code': code, 'message': message}}
log.warn('returning error message: {!r}', body)
log.warning('returning error message: %s', body)
return body

body = cherrypy.request.json
if not isinstance(body, dict):
return error(ERR_INVALID_JSON, 'invalid json input {!r}'.format(cherrypy.request.body))

log.debug('jsonrpc request body: {!r}', body)
log.debug('jsonrpc request body: %s', body)

id, params = body.get('id'), body.get('params', [])
if 'method' not in body:
Expand All @@ -83,7 +82,7 @@ def error(code, message):
try:
response = {'jsonrpc': '2.0', 'id': id,
'result': getattr(service, function)(*args, **kwargs)}
log.debug('returning success message: {!r}', response)
log.debug('returning success message: %s', response)
return response
except Exception as e:
errback(e, 'unexpected jsonrpc error calling ' + method)
Expand Down
2 changes: 1 addition & 1 deletion sideboard/lib/_cp.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def _run_shutdown():
try:
func()
except Exception:
log.warn('Ignored exception during shutdown', exc_info=True)
log.warning('Ignored exception during shutdown', exc_info=True)

stopped = Event()
on_startup(stopped.clear, priority=0)
Expand Down
Loading

0 comments on commit 5701f91

Please sign in to comment.