summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Sulfrian <asulfrian@zedat.fu-berlin.de>2022-01-06 18:02:00 +0100
committerAlexander Sulfrian <asulfrian@zedat.fu-berlin.de>2022-01-06 18:10:31 +0100
commit21f1860d598a2df4a5b97c624a18abc4ed9e1675 (patch)
tree52c6604ec41167f10f368abafe8f8c3d32b00b41
parente6c88107426c589157f61292d67bacc76320fb7b (diff)
downloadklausuren-21f1860d598a2df4a5b97c624a18abc4ed9e1675.tar.gz
klausuren-21f1860d598a2df4a5b97c624a18abc4ed9e1675.tar.bz2
klausuren-21f1860d598a2df4a5b97c624a18abc4ed9e1675.zip
Update to Python3
-rw-r--r--README5
-rw-r--r--app/backend.py15
-rw-r--r--app/forms.py2
-rw-r--r--app/main.py2
-rw-r--r--requirements.txt2
-rw-r--r--uwsgi.ini4
6 files changed, 11 insertions, 19 deletions
diff --git a/README b/README
index ef1b8da..476070d 100644
--- a/README
+++ b/README
@@ -12,7 +12,7 @@ Setup (dev)
$ cd klausurenarchiv
$ cp config.cfg.dist config.cfg # Konfigurationsdatei erstellen
$ vim/emacs/nano config.cfg
- $ virtualenv2 env
+ $ python3 -m venv env
$ . env/bin/activate
$ pip install -r requirements.txt # Abhängikeiten installieren
$ python manage.py runserver # Test-Server starten
@@ -26,8 +26,7 @@ Deployment Debian Wheezy
$ cd klausurenarchiv
$ cp config.cfg.dist config.cfg # Konfigurationsdatei erstellen
$ vim/emacs/nano config.cfg
- $ apt-get install python-flask python-flaskext.wtf python-virtualenv uwsgi uwsgi-plugin-python
- $ pip install flask-script
+ $ apt-get install python3-flask python3-flaskext.wtf python3-flask-script python3-magic python3-werkzeug python3-wtfforms
$ cp nginx.cfg ...
$ cp uwsgi.ini ...
diff --git a/app/backend.py b/app/backend.py
index 94e7c67..0f1b359 100644
--- a/app/backend.py
+++ b/app/backend.py
@@ -10,12 +10,12 @@ class Storage:
self.root = path_rel
def _join(self, *components):
- return os.path.join(self.path, *(ensureutf8(c) for c in components))
+ return os.path.join(self.path, *components)
def get_courses(self):
""" Lists all courses of a study """
- return [o.decode('utf-8') for o in os.listdir(self.path)
- if os.path.isdir(self._join(o))]
+ return [o for o in os.listdir(self.path)
+ if os.path.isdir(self._join(o))]
def exam_exists(self, course, year, name):
""" Exists if an exam (file) exists """
@@ -45,12 +45,5 @@ class Storage:
if year.isdigit():
# yield entries as tuples (name, path) grouped by years
func = partial(os.path.join, self.root, course, year)
- # filenames created by this app are always ascii-only, but let's
- # decode it nonetheless just to be sure...
- entries = [(f.decode('utf-8'), func(f)) for f in files]
+ entries = [(f, func(f)) for f in files]
yield (year, entries)
-
-def ensureutf8(s):
- if isinstance(s, unicode):
- return s.encode('utf-8')
- return s
diff --git a/app/forms.py b/app/forms.py
index 2870fca..94e9947 100644
--- a/app/forms.py
+++ b/app/forms.py
@@ -8,7 +8,7 @@ from wtforms.validators import ValidationError
year_start = date.today().year
year_end = current_app.config['FORM_START_YEAR']-1
-choices = [(str(x),x) for x in xrange(year_start, year_end, -1)]
+choices = [(str(x),x) for x in range(year_start, year_end, -1)]
class UploadForm(Form):
""" Upload Form class for validation """
study = TextField('Studiengang')
diff --git a/app/main.py b/app/main.py
index 180715e..0ca0d2a 100644
--- a/app/main.py
+++ b/app/main.py
@@ -36,7 +36,7 @@ def upload(study, course = None):
# dynamically fill form values
courses = set(current_app.config['STUDIES'][study] +
get_studies()[study].get_courses())
- choices = [(k,k) for k in sorted(courses, key=unicode.lower)]
+ choices = [(k,k) for k in sorted(courses, key=str.casefold)]
form.course.choices = choices
if 'new' not in dict(form.course.choices):
form.course.choices.append(('', u'---'))
diff --git a/requirements.txt b/requirements.txt
index f52c8cf..aa9da39 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -4,4 +4,4 @@ flask-script
Jinja2
WTForms
Werkzeug
-wsgiref
+python-magic
diff --git a/uwsgi.ini b/uwsgi.ini
index c80c96b..4df66d8 100644
--- a/uwsgi.ini
+++ b/uwsgi.ini
@@ -1,9 +1,9 @@
[uwsgi]
-plugins = python
+plugins = python3
socket = /run/uwsgi/app/klausuren/socket
master = true
processes = 2
-pythonpath = /var/www/<name>/env/lib/python2.7/site-packages/
+pythonpath = /var/www/<name>/env/lib/python3.7/site-packages/
chdir = /var/www/<name>
uid = www-data
gid = www-data