World of Tanks CW Attendance Tracker
This web application helps a clan keep track of the clan war attendance of its players and with gold payouts.
- Python 2.7 (Python 2.6 probably works too)
- Various Python libraries. See below for installation instructions.
- A relational database - MySQL/MariaDB (tested) / PostgreSQL
- A somewhat recent Linux distribution. Windows and Mac OS X most likely work too but are not considered in the installation examples below.
Start off by configuring the application:
local_config.pyand adjust the settings.
- Put your clan's logo into
whyattend/static/img/header.jpgwith an image of your choice.
sqlalchemy.urlto the same value as
Now the initial database schema should be generated by
python initdb.py from the shell. It is important that this script
runs without errors or it might leave the database in a broken state.
Make sure the
replay_blob column in the generated replay table is large enough to hold
WoT replay files. In MySQL, for example, the default BLOB type can only store
around 64 kB. This can be changed by running the SQL statement
ALTER TABLE replay MODIFY replay_blob LONGBLOB and
ALTER TABLE replay MODIFY replay_pickle LONGBLOB, for example. Additionally, MySQL
max_allowed_packet size in
my.cnf, which might have to be increased.
The application requires several Python libraries listed in requirements.txt These should be installed into a virtual Python environment to isolate them from the globally installed Python packages that come with your Linux distribution, for example.
In bash, run
> virtualenv ./myenv > source ./myenv/bin/activate > pip install -r requirements.txt
These commands will create a environment in the "myenv" folder and then install the required libraries. Some of these libraries might need to be compiled which requires further build dependencies. For such libraries it might be easier to use a binary package provided by your Linux distribution.
As a Python WSGI application, this web application can be deployed in various ways. See the Flask documentation (http://flask.pocoo.org/docs/deploying/) for further information. The following examples show tested and popular options.
Apache + mod_wsgi
Follow the instructions from example 2 to install a virtual Python environment
and use the provided
wsgi_app.wsgi file as example.
The apache2 virtual host configuration could look like this:
WSGIDaemonProcess clanwars processes=1 threads=5 WSGIProcessGroup clanwars WSGIScriptAlias /clanwars /var/www/clanwars/wsgi_app.wsgi Alias /clanwars/static/ /var/www/clanwars/whyattend/static/ <Directory /var/www/clanwars/whyattend/static> Order allow,deny Allow from all </Directory>
Tornado (+ Reverse Proxy)
First, install Tornado into your virtual Python environment:
> source ./myenv/bin/activate > pip install tornado
To start the server you can use the provided runtornado.py script:
> source ./myenv/bin/activate > python runtornado.py
This will start a Tornado server listening on port 5001. It is recommended to let Tornado listen only on localhost and put it behind a web server such as Nginx or Apache with mod_proxy that runs on port 80.
Docker is a program that automates deployment of applications inside containers, which are similar to virtual machines but uses OS level isolation features. The provided Dockerfiles can also serve as guide on how to install the tracker on Ubuntu.
First, adjust the settings in docker_config.py.
To build docker containers with a PostgreSQL database and another one with the whyattend web application simply run the following commands:
docker build -t whyattend_postgresql docker/postgresql docker build -t webapp .
Then start the database container with:
docker run -d --name db whyattend_postgresql docker run -d -P --name web --link db:db webapp
docker ps -a will then show you on which port the web application runs on the host
Clan member synchronisation
The clan member roles can be synchronized with Wargaming's server by
/sync-players/<clanid>/?API_KEY=<configured API KEY>. The tracker will
query the Wargaming API for all clan members which should show up in the list
of players right away.
config.API_TOKEN is used to authenticate your application instance with the Wargaming API.
Tokens can be generated on the Wargaming Developer Partner program website, e.g.
config.API_KEY should be set to something random and secret, so only you
can trigger the synchronization.
This can be automated by a cron script, e.g:
#!/bin/bash # Synchronize WHY members curl "http://myserver.com/sync-players/500014725?API_KEY=<configured API KEY>"
Whenever you update your installation to the latest source code you should check if a database migration is required.
Database migration is required, when the data model changes and table structures have to be changed accordingly.
For database migration we use Alembic. Whenever updating to the latest source code,
alembic upgrade head, which will issue the necessary SQL statements and bring the database
up to date.
Note for developers: When making changes to the data model in
model.py, you should create an Alembic
migration file and check it into version control along the code changes. See the Alembic documentation on how to
create migration files.
For developing the builtin development HTTP server is sufficient. To install the required dependencies
simply run the following commands (assuming a bash shell and
virtualenv using Python 2.7)
cd topleveldir virtualenv devenv source devenv/bin/activate pip install -r requirements.txt python server.py
which will start a web server listening on port 5000. The development server will automatically restart when it detects changes to the code.