SSU TimeTables is a project maintained by Plain Solutions, group of several students, which is created to bring university schedules to your palm - your mobile devices.
pytt is a new backend server for the project. It's written in Python and intended to be faster, simpler and better than its predecessor, which was faithfully serving us for a year. |
Project is a typical API-orientated web application written in Django, which uses gunicorn
for load balancing, nginx
for security and MariaDB
as database backend, because I love seals (and it's quite a fast and a good solution).
REST API completed with Django REST Framework, which is quite a mess, but still a good solution.
Let's look through main files:
models.py
– description of modelsurls.py
- descirption of all available requestsserializers.py
- JSON serialisation moduleviews.py
– core logic hereparse.py
– incoming data parsing (from XML)fetch.py
– downloading module
Also, there are a few Django commands under pytt/management/commands/
, mainly for maintenance/initial setup:
create_pr.py
– caluclate parities of weeks and save them to the DB. Should be run withcron
each 1st Septembercreate_tr.py
– create table of time references: correlation between class index and actual time for each differing departmentreset_index.py
–Model.objects.all().delete()
doesn't reset indices, so this command runsALTER
query on all the required tables.update_tt.py
– command, which atomically drops previous DB and fills it once again. Should be run withcron
according to desired frequency of updates.
Other desicrptions are available on the project wiki.
First, please check, that you executed all the steps of Setup article.
Pytt is intended to run with Gunicorn behind nginx. Sample nginx.conf
can be found on Wiki page and in conf
directory of the repo.
Then, you should run gunicorn -w NUMBER_OF_WORKERS --bind 0.0.0.0:8000 pytt.wsgi:application
from the root of the repo and restart nginx
.
- Any Linux system, preferably Ubuntu/Debian
- Python 2.7.x
- MariaDB 10.0.x
- memcached 1.4
- Python libraries requirements are listed in
requirements.txt
for simpler installation viapip
:- Django 1.7.5
- djangorestframework 3.1.3
- requests 2.2.1
- mysql-connector-python 2.0.4
- python-memcached 1.54
- gunicorn 19.3.0
- httpretty 0.8.10 (for tests only)
BSD
- Alexey Kornev
- Vadim Kiselev