Browse Source

Update to Python 3.10

bootstrap-5
rubenwardy 8 months ago
parent
commit
c2fbf7603a
  1. 2
      Dockerfile
  2. 2
      app/__init__.py
  3. 2
      app/models/packages.py
  4. 43
      app/sass.py
  5. 26
      requirements.lock.txt
  6. 2
      requirements.txt
  7. 2
      utils/ci/config.cfg

2
Dockerfile

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
FROM python:3.6
FROM python:3.10
RUN groupadd -g 5123 cdb && \
useradd -r -u 5123 -g cdb cdb

2
app/__init__.py

@ -65,7 +65,7 @@ login_manager.init_app(app) @@ -65,7 +65,7 @@ login_manager.init_app(app)
login_manager.login_view = "users.login"
from .sass import sass
from .sass import init_app as sass
sass(app)

2
app/models/packages.py

@ -407,7 +407,7 @@ class Package(db.Model): @@ -407,7 +407,7 @@ class Package(db.Model):
lazy="dynamic", order_by=db.asc("package_screenshot_order"), cascade="all, delete, delete-orphan")
main_screenshot = db.relationship("PackageScreenshot", uselist=False, foreign_keys="PackageScreenshot.package_id",
lazy=True, order_by=db.asc("package_screenshot_order"),
lazy=True, order_by=db.asc("package_screenshot_order"), viewonly=True,
primaryjoin="and_(Package.id==PackageScreenshot.package_id, PackageScreenshot.approved)")
cover_image_id = db.Column(db.Integer, db.ForeignKey("package_screenshot.id"), nullable=True, default=None)

43
app/sass.py

@ -12,16 +12,16 @@ Code unabashedly adapted from https://github.com/weapp/flask-coffee2js @@ -12,16 +12,16 @@ Code unabashedly adapted from https://github.com/weapp/flask-coffee2js
import os
import os.path
import codecs
from flask import *
from scss import Scss
import sass
from flask import send_from_directory
def _convert(dir, src, dst):
def _convert(dir_path, src, dst):
original_wd = os.getcwd()
os.chdir(dir)
os.chdir(dir_path)
css = Scss()
source = codecs.open(src, 'r', encoding='utf-8').read()
output = css.compile(source)
output = sass.compile(string=source)
os.chdir(original_wd)
@ -29,8 +29,9 @@ def _convert(dir, src, dst): @@ -29,8 +29,9 @@ def _convert(dir, src, dst):
outfile.write(output)
outfile.close()
def _getDirPath(app, originalPath, create=False):
path = originalPath
def _get_dir_path(app, original_path, create=False):
path = original_path
if not os.path.isdir(path):
path = os.path.join(app.root_path, path)
@ -39,25 +40,25 @@ def _getDirPath(app, originalPath, create=False): @@ -39,25 +40,25 @@ def _getDirPath(app, originalPath, create=False):
if create:
os.mkdir(path)
else:
raise IOError("Unable to find " + originalPath)
raise IOError("Unable to find " + original_path)
return path
def sass(app, inputDir='scss', outputPath='static', force=False, cacheDir="public/static"):
static_url_path = app.static_url_path
inputDir = _getDirPath(app, inputDir)
cacheDir = _getDirPath(app, cacheDir or outputPath, True)
def init_app(app, input_dir='scss', dest='static', force=False, cache_dir="public/static"):
input_dir = _get_dir_path(app, input_dir)
cache_dir = _get_dir_path(app, cache_dir or dest, True)
def _sass(filepath):
sassfile = "%s/%s.scss" % (inputDir, filepath)
cacheFile = "%s/%s.css" % (cacheDir, filepath)
scss_file = "%s/%s.scss" % (input_dir, filepath)
cache_file = "%s/%s.css" % (cache_dir, filepath)
# Source file exists, and needs regenerating
if os.path.isfile(sassfile) and (force or not os.path.isfile(cacheFile) or
os.path.getmtime(sassfile) > os.path.getmtime(cacheFile)):
_convert(inputDir, sassfile, cacheFile)
app.logger.debug('Compiled %s into %s' % (sassfile, cacheFile))
if os.path.isfile(scss_file) and (force or not os.path.isfile(cache_file) or
os.path.getmtime(scss_file) > os.path.getmtime(cache_file)):
_convert(input_dir, scss_file, cache_file)
app.logger.debug('Compiled %s into %s' % (scss_file, cache_file))
return send_from_directory(cacheDir, filepath + ".css")
return send_from_directory(cache_dir, filepath + ".css")
app.add_url_rule("/%s/<path:filepath>.css" % outputPath, 'sass', _sass)
app.add_url_rule("/%s/<path:filepath>.css" % dest, 'sass', _sass)

26
requirements.lock.txt

@ -7,17 +7,15 @@ beautifulsoup4==4.10.0 @@ -7,17 +7,15 @@ beautifulsoup4==4.10.0
billiard==3.6.4.0
bleach==4.1.0
blinker==1.4
cached-property==1.5.2
celery==5.1.2
celery==5.2.3
certifi==2021.10.8
cffi==1.15.0
charset-normalizer==2.0.10
click==7.1.2
click==8.0.3
click-didyoumean==0.3.0
click-plugins==1.1.1
click-repl==0.2.0
coverage==6.2
dataclasses==0.8
coverage==6.3
decorator==5.1.1
Deprecated==1.2.13
dnspython==2.2.0
@ -34,31 +32,29 @@ Flask-WTF==1.0.0 @@ -34,31 +32,29 @@ Flask-WTF==1.0.0
git-archive-all==1.23.0
gitdb==4.0.9
GitHub-Flask==3.2.0
GitPython==3.1.18
GitPython==3.1.26
greenlet==1.1.2
gunicorn==20.1.0
idna==3.3
importlib-metadata==4.8.3
importlib-resources==5.4.0
iniconfig==1.1.1
itsdangerous==2.0.1
Jinja2==3.0.3
kombu==5.1.0
kombu==5.2.3
libsass==0.21.0
lxml==4.7.1
Mako==1.1.6
Markdown==3.3.6
MarkupSafe==2.0.1
packaging==21.3
passlib==1.7.4
Pillow==8.4.0
Pillow==9.0.0
pluggy==1.0.0
prompt-toolkit==3.0.26
psycopg2-binary==2.9.3
psycopg2==2.9.3
py==1.11.0
pycparser==2.21
Pygments==2.11.2
pyparsing==3.0.7
pyScss==1.3.7
pytest==6.2.5
pytest-cov==3.0.0
pytz==2021.3
@ -72,8 +68,7 @@ SQLAlchemy==1.4.31 @@ -72,8 +68,7 @@ SQLAlchemy==1.4.31
SQLAlchemy-Searchable==1.4.1
SQLAlchemy-Utils==0.38.2
toml==0.10.2
tomli==1.2.3
typing_extensions==4.0.1
tomli==2.0.0
ua-parser==0.10.0
urllib3==1.26.8
user-agents==2.2.0
@ -83,6 +78,5 @@ wcwidth==0.2.5 @@ -83,6 +78,5 @@ wcwidth==0.2.5
webencodings==0.5.1
Werkzeug==2.0.2
wrapt==1.13.3
WTForms==3.0.0
WTForms==3.0.1
WTForms-SQLAlchemy==0.3
zipp==3.6.0

2
requirements.txt

@ -24,7 +24,7 @@ GitPython @@ -24,7 +24,7 @@ GitPython
git-archive-all
lxml
pillow
pyScss
libsass
redis
psycopg2

2
utils/ci/config.cfg

@ -5,7 +5,7 @@ BASE_URL="http://" + SERVER_NAME @@ -5,7 +5,7 @@ BASE_URL="http://" + SERVER_NAME
SECRET_KEY="changeme"
WTF_CSRF_SECRET_KEY="changeme"
SQLALCHEMY_DATABASE_URI = "postgres://contentdb:password@db:5432/contentdb"
SQLALCHEMY_DATABASE_URI = "postgresql://contentdb:password@db:5432/contentdb"
GITHUB_CLIENT_ID = ""
GITHUB_CLIENT_SECRET = ""

Loading…
Cancel
Save