Commit 2cb1d50b authored by Janez K's avatar Janez K
Browse files

merge simpson

parents 2434257a 6fceec6b
......@@ -20,6 +20,8 @@ atlassian-ide-plugin.xml
/mothra/public/media
/mothra/public/files
/mothra/backup
mothra-env/
build/
# SQLite
/mothra/mothra.db
/mothra/mothra.db
\ No newline at end of file
......@@ -26,7 +26,7 @@ source bin/activate
Obtain the url to your git repository.
```bash
git clone git@workflow.ijs.si:mothra.git
git clone git@source.ijs.si:mothra.git mothra
```
### Install requirements ###
......
ServerName workflows.ijs.si
WSGIScriptAlias / /srv/django-projects/mothra/mothra/wsgi.py
WSGIScriptAlias / /srv/django-projects/mothra/apache/wsgi_app.py
<Directory /srv/django-projects/mothra/apache>
Order allow,deny
Allow from all
......@@ -15,4 +15,5 @@ Alias /media /srv/django-projects/mothra/mothra/public/media
<Directory /srv/django-projects/mothra/mothra/public/media>
Order allow,deny
Allow from all
</Directory>
\ No newline at end of file
</Directory>
WSGIApplicationGroup %{GLOBAL}
"""
WSGI config for mothra project.
This module contains the WSGI application used by Django's development server
and any production WSGI deployments. It should expose a module-level variable
named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover
this application via the ``WSGI_APPLICATION`` setting.
Usually you will have the standard Django WSGI application here, but it also
might make sense to replace the whole Django WSGI application with a custom one
that later delegates to the Django one. For example, you could introduce WSGI
middleware here, or combine a Django application with an application of another
framework.
"""
import os
import sys
import site
site.addsitedir('/srv/django-envs/mothra/lib/python2.7/site-packages')
project_path = '/srv/django-projects/mothra'
if project_path not in sys.path:
sys.path.append(project_path)
os.environ["DJANGO_SETTINGS_MODULE"] = "mothra.settings"
# This application object is used by any WSGI server configured to use this
# file. This includes Django's development server, if the WSGI_APPLICATION
# setting points here.
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
# Apply WSGI middleware here.
# from helloworld.wsgi import HelloWorldApplication
# application = HelloWorldApplication(application)
from __future__ import with_statement
from fabric.api import *
from fabric.colors import *
from fabric.utils import puts, abort
env.use_ssh_config = True
apps_to_migrate = ('workflows',)
def live():
""" doloci live server kot aktivni """
env.os = 'ubuntu'
env.hosts = ['git@workflow.ijs.si']
env.branch = 'master'
def deploy():
""" deploy na serverju
uporaba:
$ fab live deploy
"""
with prefix('source /srv/django-envs/mothra/bin/activate'):
with cd('/srv/django-projects/mothra'):
puts(yellow("[Pulling from origin, on branch %s]" % (env.branch,)))
run('git pull origin %s' % (env.branch,))
run('git checkout %s' % (env.branch,))
puts(yellow("[Installing packages]"))
run('pip install -qr requirements.txt')
puts(yellow("[Migrating apps]"))
for app in apps_to_migrate:
puts("--> [Migrating %s]" % (app,))
run('python manage.py migrate %s --no-initial-data' % (app, ))
puts(yellow("[Collecting static files]"))
run("python manage.py collectstatic --noinput")
puts(yellow("[Auto importing packages]"))
run("python manage.py auto_import_packages")
#puts(yellow("[Compressing]"))
#run('python manage.py compress')
def apache_restart():
"""restarta apache service
primer:
$ fab dev apache_restart
$ fab live apache_restart
"""
if env.os == 'ubuntu':
sudo('service apache2 restart')
elif env.os == 'arch':
sudo('rc.d restart httpd')
else:
abort('env.os ni definiran, kaj je zdej to')
This file is placed here by pip to indicate the source was put
here by pip.
Once this package is successfully installed this source code will be
deleted (unless you remove this file).
# Global settings for mothra project.
import django.conf.global_settings as DEFAULT_SETTINGS
import os
PROJECT_DIR = os.path.dirname(__file__)
PUBLIC_DIR = os.path.join(PROJECT_DIR, 'public')
BACKUP_DIR = os.path.join(PROJECT_DIR, 'backup')
DEBUG = False
TEMPLATE_DEBUG = True
ADMINS = (
# ('Your Name', 'your_email@example.com'),
)
MANAGERS = ADMINS
# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# On Unix systems, a value of None will cause Django to use the same
# timezone as the operating system.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = 'UTC'
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'
SITE_ID = 1
# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True
# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale.
USE_L10N = True
# If you set this to False, Django will not use timezone-aware datetimes.
USE_TZ = True
# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/home/media/media.lawrence.com/media/"
MEDIA_ROOT = os.path.join(PUBLIC_DIR, 'media')
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
MEDIA_URL = '/media/'
# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = os.path.join(PUBLIC_DIR, 'static')
# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = '/static/'
# Additional locations of static files
STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
os.path.join(PROJECT_DIR, 'static'),
)
# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
)
MIDDLEWARE_CLASSES = (
'django.middleware.cache.UpdateCacheMiddleware', # must be first
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.cache.FetchFromCacheMiddleware', # must be last
)
CACHE_MIDDLEWARE_ALIAS = 'default'
CACHE_MIDDLEWARE_SECONDS = 10
CACHE_MIDDLEWARE_KEY_PREFIX = 'mothra'
ROOT_URLCONF = 'mothra.urls'
# Python dotted path to the WSGI application used by Django's runserver.
WSGI_APPLICATION = 'mothra.wsgi.application'
TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
os.path.join(PROJECT_DIR, 'templates'),
)
TEMPLATE_CONTEXT_PROCESSORS = (
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'django.core.context_processors.debug',
'django.core.context_processors.i18n',
'django.core.context_processors.media',
'django.core.context_processors.static',
'django.core.context_processors.request',
)
FIXTURE_DIRS = (
os.path.join(PROJECT_DIR, 'fixtures'),
)
# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error when DEBUG=False.
# See http://docs.djangoproject.com/en/dev/topics/logging for
# more details on how to customize your logging configuration.
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
'handlers': {
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler'
}
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
}
}
try:
LOCAL_SETTINGS
except NameError:
try:
from local_settings import *
except ImportError:
pass
INSTALLED_APPS_DEFAULT = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'south',
'website',
'signuplogin',
'django_extensions',
'django.contrib.humanize',
'orderable_inlines',
'workflows',
)
INSTALLED_APPS_CONCUR = (
'djcelery',
) if USE_CONCURRENCY else (
'streams',
)
INSTALLED_APPS_WORKFLOWS_SUB = (
'workflows.base',
'workflows.latino',
'workflows.decision_support',
'workflows.bioinformatics',
'workflows.subgroup_discovery',
'workflows.nlp',
'workflows.nl_toolkit',
#WORKFLOWS_SUBAPP_PLACEHOLDER
)
INSTALLED_APPS = \
INSTALLED_APPS_DEFAULT +\
INSTALLED_APPS_CONCUR +\
INSTALLED_APPS_WORKFLOWS_SUB
TEMPLATE_CONTEXT_PROCESSORS = DEFAULT_SETTINGS.TEMPLATE_CONTEXT_PROCESSORS
TEMPLATES_FOLDER = os.path.join(PROJECT_DIR, 'templates')
PROJECT_FOLDER = PROJECT_DIR
TEMPLATE_DIRS = (TEMPLATES_FOLDER,)
AUTH_PROFILE_MODULE = 'workflows.UserProfile'
LOGIN_URL = '/login/'
LOGIN_REDIRECT_URL = '/'
STATIC_DOC_ROOT = os.path.join(os.getcwd(), 'mothra/public/media')
# Global settings for mothra project.
import django.conf.global_settings as DEFAULT_SETTINGS
import os
PROJECT_DIR = os.path.dirname(__file__)
PUBLIC_DIR = os.path.join(PROJECT_DIR, 'public')
BACKUP_DIR = os.path.join(PROJECT_DIR, 'backup')
DEBUG = False
TEMPLATE_DEBUG = True
ADMINS = (
# ('Your Name', 'your_email@example.com'),
)
MANAGERS = ADMINS
# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# On Unix systems, a value of None will cause Django to use the same
# timezone as the operating system.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = 'UTC'
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'
SITE_ID = 1
# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True
# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale.
USE_L10N = True
# If you set this to False, Django will not use timezone-aware datetimes.
USE_TZ = True
# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/home/media/media.lawrence.com/media/"
MEDIA_ROOT = os.path.join(PUBLIC_DIR, 'media')
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
MEDIA_URL = '/media/'
# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = os.path.join(PUBLIC_DIR, 'static')
# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = '/static/'
# Additional locations of static files
STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
os.path.join(PROJECT_DIR, 'static'),
)
# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
)
MIDDLEWARE_CLASSES = (
'django.middleware.cache.UpdateCacheMiddleware', # must be first
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.cache.FetchFromCacheMiddleware', # must be last
)
CACHE_MIDDLEWARE_ALIAS = 'default'
CACHE_MIDDLEWARE_SECONDS = 10
CACHE_MIDDLEWARE_KEY_PREFIX = 'mothra'
ROOT_URLCONF = 'mothra.urls'
# Python dotted path to the WSGI application used by Django's runserver.
WSGI_APPLICATION = 'mothra.wsgi.application'
TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
os.path.join(PROJECT_DIR, 'templates'),
)
TEMPLATE_CONTEXT_PROCESSORS = (
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'django.core.context_processors.debug',
'django.core.context_processors.i18n',
'django.core.context_processors.media',
'django.core.context_processors.static',
'django.core.context_processors.request',
)
FIXTURE_DIRS = (
os.path.join(PROJECT_DIR, 'fixtures'),
)
# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error when DEBUG=False.
# See http://docs.djangoproject.com/en/dev/topics/logging for
# more details on how to customize your logging configuration.
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
'handlers': {
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler'
}
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
}
}
try:
LOCAL_SETTINGS
except NameError:
try:
from local_settings import *
except ImportError:
pass
INSTALLED_APPS_DEFAULT = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'south',
'website',
'signuplogin',
'django_extensions',
'django.contrib.humanize',
'orderable_inlines',
'workflows',
'picklefield'
)
INSTALLED_APPS_CONCUR = (
'djcelery',
) if USE_CONCURRENCY else (
'streams',
)
INSTALLED_APPS_WORKFLOWS_SUB = (
'workflows.base',
'workflows.latino',
'workflows.decision_support',
'workflows.segmine',
'workflows.subgroup_discovery',
'workflows.nlp',
'workflows.nl_toolkit',
'workflows.ilp',
'workflows.weka',
'workflows.cforange',
'workflows.perfeval',
'workflows.mysql',
'workflows.lemmagen',
'workflows.crossbee',
#WORKFLOWS_SUBAPP_PLACEHOLDER
)
INSTALLED_APPS = \
INSTALLED_APPS_DEFAULT +\
INSTALLED_APPS_CONCUR +\
INSTALLED_APPS_WORKFLOWS_SUB
TEMPLATE_CONTEXT_PROCESSORS = DEFAULT_SETTINGS.TEMPLATE_CONTEXT_PROCESSORS
TEMPLATES_FOLDER = os.path.join(PROJECT_DIR, 'templates')
PROJECT_FOLDER = PROJECT_DIR
TEMPLATE_DIRS = (TEMPLATES_FOLDER,)
AUTH_PROFILE_MODULE = 'workflows.UserProfile'
LOGIN_URL = '/login/'
LOGIN_REDIRECT_URL = '/'
STATIC_DOC_ROOT = os.path.join(os.getcwd(), 'mothra/public/media')
"""Pickle field implementation for Django."""
DEFAULT_PROTOCOL = 2
from picklefield.fields import PickledObjectField # reexport
"""Pickle field implementation for Django."""
from copy import deepcopy
from base64 import b64encode, b64decode
from zlib import compress, decompress
try:
from cPickle import loads, dumps
except ImportError:
from pickle import loads, dumps
from django.db import models
from django.utils.encoding import force_unicode
from picklefield import DEFAULT_PROTOCOL
class PickledObject(str):
"""
A subclass of string so it can be told whether a string is a pickled
object or not (if the object is an instance of this class then it must
[well, should] be a pickled one).
Only really useful for passing pre-encoded values to ``default``
with ``dbsafe_encode``, not that doing so is necessary. If you
remove PickledObject and its references, you won't be able to pass
in pre-encoded values anymore, but you can always just pass in the
python objects themselves.
"""
class _ObjectWrapper(object):
"""
A class used to wrap object that have properties that may clash with the
ORM internals.
For example, objects with the `prepare_database_save` property such as
`django.db.Model` subclasses won't work under certain conditions and the
same apply for trying to retrieve any `callable` object.
"""
__slots__ = ('_obj',)
def __init__(self, obj):
self._obj = obj
def wrap_conflictual_object(obj):
if hasattr(obj, 'prepare_database_save') or callable(obj):
obj = _ObjectWrapper(obj)
return obj
def dbsafe_encode(value, compress_object=False, pickle_protocol=DEFAULT_PROTOCOL):
# We use deepcopy() here to avoid a problem with cPickle, where dumps
# can generate different character streams for same lookup value if
# they are referenced differently.
# The reason this is important is because we do all of our lookups as