Installing TAPAS

Dependencies

This software requires Python 3.4 and a web server to run. It has been tested thoroughly with Apache2, but NGINX should work too, with some configuration (which is not included here).

In addition to Python 3.4, the software also requires Python modules to run. These are found below:
  • django
  • django-registration-redux
  • django-haystack
  • whoosh (my preferred search engine)
  • djangorestframework

Optional:

  • mysqlclient

Development only:

  • sphinx
  • sphinx_rtd_theme

All of which can be installed using:

pip3 install package-name

Installation

These installation instructions apply to Ubuntu 14.04 LTS, but should work similarly if not the same on any Debian derivative. The best way to download TAPAS is using git.

Firstly, we need to install our dependencies:

sudo apt-get install python3 apache2 mysql-server

sudo pip3 install django

sudo pip3 install django-registration-redux

sudo pip3 install django-haystack

sudo pip3 install whoosh

sudo pip3 install djangorestframework

sudo pip3 install mysqlclient

lucid-utils is also a required dependency, but is not avaliable via pip - you’ll need to get it via git

Now we can download TAPAS itself - it’s up to you where it is installed, /var/www is used as an example here - just as long as www-data can read and write there:

sudo apt-get install git

cd /var/www

sudo git clone https://github.com/willfurnell/tapas.git

Once TAPAS is downloaded, you need to create a MySQL database, and a user for it with read/write privileges.

Now is time to edit the settings.py file to suit your environment, a sample is included below:

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = ''

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'webanalysis',
    'django.contrib.sites',
    'registration',
    'haystack',
    'rest_framework',
    'rest_framework.authtoken',
)

MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'django.middleware.security.SecurityMiddleware',
)

ROOT_URLCONF = 'analysis.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'templates')]
        ,
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

WSGI_APPLICATION = 'analysis.wsgi.application'


# Database
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'analysis',
        'USER': 'analysis',
        'PASSWORD': 'passwordgoeshere',
        'HOST': 'localhost',
        'PORT': '3306',
    }
}


# Internationalization
# https://docs.djangoproject.com/en/1.8/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'static/'),
)

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.8/howto/static-files/

STATIC_URL = "/tapas/static/"

# Uploads

MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = "/media/"

OUTPUT_DIRECTORY = "/output/directory/full/path"  # Where we want to drop uploads


# django-registration-redux requirements

ACCOUNT_ACTIVATION_DAYS = 7 # One-week activation window; you may, of course, use a different value.
REGISTRATION_AUTO_LOGIN = False # Don't automatically log the user in.

LOGIN_REDIRECT_URL = '/tapas'
ACTIVATION_REDIRECT_URL = '/tapas/accounts/update-profile/'

LOGIN_URL = '/tapas/accounts/login/'

SECRET_WORD = "secret"

SITE_ID = 1

EMAIL_HOST = '127.0.0.1'
EMAIL_PORT = 25
DEFAULT_FROM_EMAIL = 'TAPAS <starserver@thelangton.kent.sch.uk>'
EMAIL_USE_TLS = False

HAYSTACK_CONNECTIONS = {
'default': {
    'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine',
    'PATH': os.path.join(os.path.dirname(__file__), 'whoosh_index'),
},
}

HAYSTACK_SIGNAL_PROCESSOR = 'haystack.signals.RealtimeSignalProcessor'

REST_FRAMEWORK = {
    'DEFAULT_PERMISSION_CLASSES': [
        'rest_framework.permissions.IsAuthenticated',
    ],

    'DEFAULT_AUTHENTICATION_CLASSES': (
        'rest_framework.authentication.TokenAuthentication',
        'rest_framework.authentication.BasicAuthentication',
        'rest_framework.authentication.SessionAuthentication',
    ),
    'PAGE_SIZE': 500
}

Once this is done, it’s time to configure Apache2 - a sample for this, in the default vhost is included below: (Note: Only TAPAS relevant info is included here):

WSGIDaemonProcess tapas
WSGIProcessGroup tapas

Alias /tapas/static /var/www/tapas/static
WSGIScriptAlias /tapas /var/www/tapas/analysis/wsgi.py process-group=tapas

Finally, the database needs to be set up. Thankfully, Django can do this all for you. You’ll need to type the following commands, in the ‘tapas’ directory.:

sudo python3 manage.py makemigrations

sudo python3 manage.py migrate

Once all this is complete, Apache2 will need to be reloaded:

sudo service apache2 reload

You also need to set up a symbolic link from the frame image directory, used by the analysis daemon to /var/www/tapas/static/frame_images/ This can be done with a command similar to the following

ln -s /media/data/tapas/frame_images/ /var/www/tapas/static/frame_images/

You will now be able to access TAPAS at the URL you have configured, for example:

http://starserver.thelangton.org.uk/tapas