Skip to content

Commit

Permalink
Update to python3.11 + recent libs.
Browse files Browse the repository at this point in the history
  • Loading branch information
tomimick committed May 6, 2023
1 parent 289fa10 commit b8873ac
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 20 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.9-slim-buster
FROM python:3.11-slim-bullseye

WORKDIR /app

Expand All @@ -13,7 +13,7 @@ RUN set -ex \
htop \
' \
&& apt-get update && apt-get install -y $buildDeps $deps --no-install-recommends && rm -rf /var/lib/apt/lists/* \
&& pip install uWSGI==2.0.19.1 \
&& pip install uWSGI==2.0.21 \
&& apt-get purge -y --auto-remove $buildDeps \
&& find /usr/local -depth \
\( \
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Open sourced on Sep 2018 after years of production use at multiple sites.

Update Sep 2020: Run in Raspberry with an SQLite database.

Update May 2023: Python and libraries updated to recent versions. Python 3.11 in use. Still a fine foundation for a new project - the architecture does not age, and simple outlives complex.

**Table of contents**

* [Features](#features)
Expand Down
20 changes: 12 additions & 8 deletions py/webutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import functools
from flask import Flask, request, session, g, redirect, abort, jsonify
from flask_session import Session
from flask.json import JSONEncoder
from flask.json.provider import DefaultJSONProvider

import db
import config
Expand Down Expand Up @@ -258,18 +258,22 @@ def _is_role_atleast(myrole, rolebase):
return False


class MyJSONEncoder(JSONEncoder):
class MyJSONEncoder(DefaultJSONProvider):
def default(self, obj):
if isinstance(obj, peewee.SelectQuery):
# print(type(obj))

if isinstance(obj, peewee.SelectBase):
return list(obj)
if isinstance(obj, db.BaseModel):
elif isinstance(obj, db.BaseModel):
return obj.serialize()
elif isinstance(obj, datetime.datetime):
# dt_local = util.utc2local(obj)
return obj.isoformat() if obj else None
return JSONEncoder.default(self, obj)
#elif isinstance(obj, sqlite3.Cursor):
#return list(obj)
#if isinstance(obj, psycopg2.extensions.cursor):
#return list(obj)
return DefaultJSONProvider.default(obj)

app.json_encoder = MyJSONEncoder
app.json = MyJSONEncoder(app)

init_logging()

19 changes: 9 additions & 10 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
Flask==1.1.2
Flask-Session==0.3.2
passlib==1.7.2
peewee==3.14.1
peewee-migrate==1.1.6
psycopg2-binary==2.8.6
pytz==2021.1
redis==3.5.3
requests==2.24

Flask==2.3.2
Flask-Session2==1.3.1
passlib==1.7.4
peewee==3.16.2
peewee-migrate==1.7.1
psycopg2-binary==2.9.6
pytz==2022.7.1
redis==4.5.4
requests==2.30.0

0 comments on commit b8873ac

Please sign in to comment.