Example #1
0
def activate_env():
    """ Activates the virtual environment for this project."""

    error_msg = None

    try:
        virtualenv_dir = Path(os.environ['WORKON_HOME'])
    except KeyError:
        error_msg = "Error: 'WORKON_HOME' is not set."

    if error_msg:
        color_init()
        sys.stderr.write(Fore.RED + Style.BRIGHT + error_msg + "\n")
        sys.exit(1)

    filepath = Path(__file__).absolute()
    site_dir = filepath.ancestor(4).components()[-1]
    repo_dir = filepath.ancestor(3).components()[-1]

    # Add the app's directory to the PYTHONPATH
    sys.path.append(filepath.ancestor(2))
    sys.path.append(filepath.ancestor(1))

    # Set manually in environment
    #os.environ['DJANGO_SETTINGS_MODULE'] = 'settings.production'

    if os.environ['DJANGO_SETTINGS_MODULE'] == 'settings.production':
        bin_parent = site_dir
    else:
        bin_parent = repo_dir

    # Activate the virtual env
    activate_env = virtualenv_dir.child(bin_parent, "bin", "activate_this.py")
    execfile(activate_env, dict(__file__=activate_env))
Example #2
0
def activate_env():
    """ Activates the virtual environment for this project."""

    error_msg = None

    try:
        virtualenv_dir = Path(os.environ['WORKON_HOME'])
    except KeyError:
        error_msg = "Error: 'WORKON_HOME' is not set."

    if error_msg:
        color_init()
        sys.stderr.write(Fore.RED + Style.BRIGHT + error_msg + "\n")
        sys.exit(1)

    filepath = Path(__file__).absolute()
    site_dir = filepath.ancestor(4).components()[-1]
    repo_dir = filepath.ancestor(3).components()[-1]

    # Add the app's directory to the PYTHONPATH
    sys.path.append(filepath.ancestor(2))
    sys.path.append(filepath.ancestor(1))

    # Set manually in environment
    #os.environ['DJANGO_SETTINGS_MODULE'] = 'settings.production'

    if os.environ['DJANGO_SETTINGS_MODULE'] == 'settings.production':
        bin_parent = site_dir
    else:
        bin_parent = repo_dir

    # Activate the virtual env
    activate_env = virtualenv_dir.child(bin_parent, "bin", "activate_this.py")
    execfile(activate_env, dict(__file__=activate_env))
def get_closest_uid(path):
	path = Path(path)
	while not path.isdir():
		path = path.ancestor(1)
		if path == '/':
			return False
	return path.stat().st_uid
Example #4
0
def write_config(name, instance_name, config, config_type):
    path = Path(config_type.format(
        name=name,
        instance=instance_name,
    ))
    try:
        os.makedirs(path.ancestor(1))
    except OSError as (id, e):
        if id != 17:
            raise
Example #5
0
def write_config(name, instance_name, config, config_type):
    path = Path(config_type.format(
        name=name,
        instance=instance_name,
    ))
    try:
        os.makedirs(path.ancestor(1))
    except OSError as (id, e):
        if id != 17:
            raise
Example #6
0
from unipath import Path

# Full path to django project root.
BASE = Path(__file__).absolute().ancestor(3)

REPO_BASE = BASE.ancestor(1)

DJANGO_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
)
THIRD_PARTY_APPS = (
    'mptt',
    'rest_framework',
    'corsheaders',
    'south',
)
WOWTEST_APPS = (
    'store',
    'users',
)

INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + WOWTEST_APPS

MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
Example #7
0
from unipath import Path

PROJECT_DIR = Path(__file__).ancestor(2)
print "PROJECT_DIR: %s" % PROJECT_DIR
# Django settings for demo project.

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
    # ('Your Name', '*****@*****.**'),
)

MANAGERS = ADMINS

DB = PROJECT_DIR.ancestor(2) + '/d201305.db'
print "DB: %s" % DB

DATABASES = {
    'default': {
        'ENGINE':
        'django.db.backends.sqlite3',  # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': DB,  # Or path to database file if using sqlite3.
        # The following settings are not used with sqlite3:
        'USER': '',
        'PASSWORD': '',
        'HOST':
        '',  # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP.
        'PORT': '',  # Set to empty string for default.
    }
}
Example #8
0
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    },
    'destination': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}


# 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


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

STATIC_URL = '/static/'

GIT_DIR = BASE_DIR.ancestor(1)
Example #9
0
LANGUAGE_CODE = 'en-us'

# template search path
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.
    PROJECT_DIR.child("templates"),
)


TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


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

STATIC_URL = '/static/'
STATIC_ROOT = PROJECT_DIR.ancestor(1).child("static")
STATICFILES_DIRS = (
    ('assets', PROJECT_DIR.child("assets")),
)

print PROJECT_DIR.child("assets")
Example #10
0
__author__ = 'sauce'
import os
import sys
from unipath import Path

p = Path(__file__)
sys.path = [p.ancestor(1)] + sys.path
os.environ[
    'DJANGO_SETTINGS_MODULE'] = "CRF_Project.settings_produccion"
import django.core.handlers.wsgi

application = django.core.handlers.wsgi.WSGIHandler()
Example #11
0
def insert(data):
    # Blog
    logger.info("Adding blog...")

    blog_data = data["blog"]

    blog = Blog(
        title=blog_data["title"],
        tagline=blog_data["tagline"],
        language=blog_data["language"],
    )

    db.session.add(blog)

    # Authors
    logger.info("Adding authors...")

    author_reference = {}
    for user_data in data["authors"]:
        author = Author(login=user_data["login"],
                        nicename=user_data["display_name"],
                        email=user_data["email"],
                        display_name="%s %s" %
                        (user_data["first_name"], user_data["last_name"]))
        author_reference[user_data["login"]] = author

        db.session.add(author)

    db.session.commit()

    # Categories
    logger.info("Adding categories...")

    category_reference = _insert_categories(data["categories"])
    db.session.commit()

    # Tags
    logger.info("Adding tags...")

    tag_reference = {}
    for tag_data in data["tags"]:
        tag = Tag(
            name=tag_data["name"],
            slug=tag_data["slug"],
        )
        db.session.add(tag)

        tag_reference[tag_data["slug"]] = tag

    db.session.commit()

    # Posts
    logger.info("Inserting %s posts..." % len(data["posts"]))

    created_posts = []
    post_id_reference = {}

    data["posts"] = data["posts"][::-1]

    for post_data in data["posts"]:
        logger.info("Adding %s..." % post_data["title"])

        author = author_reference[post_data["creator"]]

        if post_data["post_date"] == "0000-00-00 00:00:00":
            post_data["post_date"] = "1970-01-01 00:00:00"

        date = datetime.strptime(post_data["post_date"], '%Y-%m-%d %H:%M:%S')

        post_content = None
        if post_data["content"]:
            post_content = _clean_post_content(blog_data["blog_url"],
                                               post_data["content"])

        post = Post(
            title=post_data["title"],
            author=author,
            date=date,
            modified=date,
            name=post_data["post_name"],
            content=post_content,
            excerpt=post_data["excerpt"],
            status=post_data["status"],
            order=post_data["menu_order"],
            type=post_data["post_type"],
        )

        # Save attachment
        if post_data["post_type"] == "attachment":
            file_url = post_data["guid"]
            site_url, relative_path = file_url.split("wp-content/uploads/")
            relative_path = Path(relative_path)

            _save_image(file_url)

            # Save thumbnails
            metadata = {}
            if "postmeta" in post_data:
                if "attachment_metadata" in post_data["postmeta"]:
                    metadata = post_data["postmeta"]["attachment_metadata"]

            if "sizes" in metadata:
                for size in metadata["sizes"]:
                    file_name = metadata["sizes"][size]["file"]
                    size_rel_path = relative_path.ancestor(1).child(file_name)
                    size_file_url = "/".join(
                        [site_url, "wp-content/uploads", size_rel_path])

                    _save_image(size_file_url)

            post.guid = relative_path

        for name in post_data["categories"]:
            category = category_reference[name]
            post.categories.append(category)

        for name in post_data["tags"]:
            tag = tag_reference[name]
            post.tags.append(tag)

        created_posts.append(post)
        db.session.add(post)

        post_id_reference[post_data["post_id"]] = post

    db.session.commit()

    # Add parents
    for post_data in data["posts"]:
        created_post = post_id_reference[post_data["post_id"]]
        has_parent = int(post_data["post_parent"])

        if has_parent:
            parent_post = post_id_reference[post_data["post_parent"]]
            created_post.parent = parent_post

    db.session.commit()

    logger.info("Import complete!")
Example #12
0
MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'app.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [BASE_DIR.ancestor(1).child('build')],
        '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 = 'app.wsgi.application'

# Database
Example #13
0
# along to gunicorn it's seen as a client supplied header, so prefixed
# with HTTP_ in the wsgi environ, As a result we need to look for
# HTTP_REMOTE_USER instead of REMOTE_USER.
REMOTE_USER_HEADER = "HTTP_REMOTE_USER"

# This url is where feeback from users to the application is sent.
FEEDBACK_URL = "http://feedback.caret.cam.ac.uk/project/timetables"

# This is the name of the server, used for generating event uids
INSTANCE_NAME = "timetables.caret.cam.ac.uk"

# In production this should be set to True, so that we maintain a cache of parsed UI Yaml ready for use.
CACHE_YAML = False

DJANGO_DIR = Path(__file__).absolute().ancestor(3)
REPO_ROOT_DIR = DJANGO_DIR.ancestor(2)

# The academic year to use when expanding date patterns which don't
# specify an academic year themselves. The number indicates the year the
# academic year starts in, e.g. 2013 is the 2013-2014 academic year.
DEFAULT_ACADEMIC_YEAR = 2013

##########################
# Standard Django settings
##########################

DEBUG = True
TEMPLATE_DEBUG = DEBUG

# This would be if you put all your tests within a top-level "tests" package.
TEST_DISCOVERY_ROOT = DJANGO_DIR
Example #14
0
    'message_quantity.xml')
xml_message_product_filename = base_dir.child('templates_xml').child(
    'message_product.xml')
xml_message_price_filename = base_dir.child('templates_xml').child(
    'message_price.xml')
xml_message_delete_product_filename = base_dir.child('templates_xml').child(
    'message_delete_product.xml')

# logs paths

main_log_path = base_dir.child('main.log')
profits_log_path = base_dir.child('profits.log')
finder_log_path = base_dir.child('finder.log')

if os_name == 'nt':
    default_log_path = base_dir.ancestor(1).child('logs').child(
        'default_err.log')
    workflow_log_path = base_dir.ancestor(1).child('logs').child(
        'workflow_err.log')
    repricer_log_path = base_dir.ancestor(1).child('logs').child(
        'repricer_err.log')

else:
    default_log_path = '/home/aver/logs/celery/default_err.log'
    workflow_log_path = '/home/aver/logs/celery/workflow_err.log'
    repricer_log_path = '/home/aver/logs/celery/repricer_err.log'

load_encoding = 'utf8'

# pairs models
asin_length = 10
sku_length = 12
Example #15
0
"""

import os
import sys
import logging
try:
    from unipath import Path
except ImportError:
    print 'Please run pip install Unipath, to install this module.'
    sys.exit(1)

PROJECT_ROOT = Path(__file__).ancestor(2)
# PROJECT_ROOT = os.path.realpath(os.path.dirname(__file__))
# sys.path.insert(0, PROJECT_ROOT)

LOG_PATH = PROJECT_ROOT.ancestor(1)
DEBUG = False
TEMPLATE_DEBUG = False

ADMINS = (
    # ('Your Name', '*****@*****.**'),
)

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.
# In a Windows environment this must be set to your system time zone.
TIME_ZONE = 'UTC'
Example #16
0
"""

import os
import sys
import logging
try:
    from unipath import Path
except ImportError:
    print 'Please run pip install Unipath, to install this module.'
    sys.exit(1)

PROJECT_ROOT = Path(__file__).ancestor(2)
# PROJECT_ROOT = os.path.realpath(os.path.dirname(__file__))
# sys.path.insert(0, PROJECT_ROOT)

LOG_PATH = PROJECT_ROOT.ancestor(1)
DEBUG = False
TEMPLATE_DEBUG = False

ADMINS = (
    # ('Your Name', '*****@*****.**'),
)

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.
# In a Windows environment this must be set to your system time zone.
TIME_ZONE = 'UTC'
Example #17
0
from django.utils.translation import ugettext_lazy as _
LANGUAGES = (
    ('en', _('English')),
    ('nl', _('Dutch')),
)

LOCALE_PATHS = (
    BASE_DIR.child('locale'),
)

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

STATIC_URL = '/static/'
STATIC_ROOT = BASE_DIR.ancestor(1).child("static")
STATICFILES_DIRS = (
    BASE_DIR.child("static"),
)

# Allauth related
LOGIN_REDIRECT_URL = "settings:set_language"
AUTHENTICATION_BACKENDS = (
    'django.contrib.auth.backends.ModelBackend',
    'allauth.account.auth_backends.AuthenticationBackend',
)

ACCOUNT_EMAIL_REQUIRED = True

LOGIN_URL = 'account_login'
LOGOUT_URL = 'account_logout'
Example #18
0
MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'backend.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [BASE_DIR.ancestor(1).child('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 = 'backend.wsgi.application'

# Password validation
Example #19
0
            error_msg = "Set the {} environment variable".format(var_name)
            raise ImproperlyConfigured(error_msg)
        else:
            return default
    except TypeError:
        raise ImproperlyConfigured('Unexpected Value Type')


def bool_(string):
    return bool(strtobool(string))


BASE_DIR = Path(__file__).ancestor(3)

# TODO really? the slash did it!
MEDIA_ROOT = BASE_DIR.ancestor(1).child("media") + '/'
MEDIA_URL = '/media/'

STATIC_ROOT = BASE_DIR.ancestor(1).child("static") + '/'
STATIC_URL = '/static/'
# STATICFILES_DIRS = (
#     BASE_DIR.ancestor(1).child("static"),
# )

# https forwarding, oh yeah
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')

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

# SECURITY WARNING: keep the secret key used in production secret!
Example #20
0
        'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME':
        'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]

# Internationalization

LANGUAGE_CODE = 'es-co'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True

# Static files (CSS, JavaScript, Images)

STATIC_ROOT = BASE_DIR.ancestor(1).child('static')

STATIC_URL = '/static/'

STATICFILES_DIRS = (BASE_DIR.child('static'), )

MEDIA_ROOT = BASE_DIR.ancestor(1).child('media')

MEDIA_URL = '/media/'
Example #21
0
    """

    try:
        return os.environ[name]
    except KeyError:
        error_msg = "Error: The %s environment variable is not set!" % name
        color_init()
        sys.stderr.write(Fore.RED + Style.BRIGHT + error_msg + "\n")
        sys.exit(1)


source_dir = Path(get_env_variable('PROJECT_HOME'))
virtualenv_dir = Path(get_env_variable('WORKON_HOME'))

filepath = Path(__file__).absolute()
site_dir = filepath.ancestor(4).components()[-1]
repo_dir = filepath.ancestor(3).components()[-1]
project_dir = filepath.ancestor(2).components()[-1]

# Add the site-packages of the chosen virtualenv to work with
site.addsitedir(virtualenv_dir.child(repo_dir, "lib", "python2.7", "site-packages"))

# Add the app's directory to the PYTHONPATH
sys.path.append(filepath.ancestor(2))
sys.path.append(filepath.ancestor(2).child(project_dir))

# Set manually in environment
#os.environ['DJANGO_SETTINGS_MODULE'] = 'settings.production'

# Activate the virtual env
activate_env = virtualenv_dir.child(site_dir, "bin", "activate_this.py")
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

GRAPPELLI_ADMIN_TITLE = 'Gestor de Proyectos Baética'
ROOT_URLCONF = 'base.urls'
WSGI_APPLICATION = 'base.wsgi.application'

from django.conf.global_settings import TEMPLATE_CONTEXT_PROCESSORS as TCP

TEMPLATE_CONTEXT_PROCESSORS = TCP + (
    'django.core.context_processors.request',
)

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': Path(PROJECT_DIR.ancestor(1), 'bd/db.sqlite3'),
    }
}

LANGUAGE_CODE = 'es-es'
TIME_ZONE = 'Europe/Madrid'
USE_I18N = True
USE_L10N = True
USE_TZ = True
Example #23
0
USE_I18N = True

USE_L10N = True

USE_TZ = True

# 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',
    #'django.contrib.staticfiles.finders.DefaultStorageFinder',
)

# Static files (CSS, JavaScript, Images)
STATIC_ROOT = BASE_DIR.ancestor(2).child("aane_static")

STATIC_URL = '/static/'

STATICFILES_DIRS = (BASE_DIR.child("local_static"), )

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [BASE_DIR.child("templates")],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
Example #24
0
from decouple import AutoConfig
from easy_thumbnails.conf import Settings as thumbnail_settings
from unipath import Path

config = AutoConfig()

MEDIA_DEV_LOCAL = config('MEDIA_DEV_LOCAL', default=False, cast=bool)

BASE_DIR = Path(__file__).ancestor(2)
PROJECT_DIR = Path(__file__).ancestor(3)

MEDIA_URL = '/media/'
MEDIA_ROOT = PROJECT_DIR.ancestor(1).child(
    "cmj_media{}".format('_local' if MEDIA_DEV_LOCAL else '')).child("media")
MEDIA_PROTECTED_ROOT = PROJECT_DIR.ancestor(1).child("cmj_media{}".format(
    '_local' if MEDIA_DEV_LOCAL else '')).child("media_protected")

FILTERS_HELP_TEXT_FILTER = False

IMAGE_CROPPING_SIZE_WARNING = True
IMAGE_CROPPING_JQUERY_URL = None
THUMBNAIL_PROCESSORS = ('image_cropping.thumbnail_processors.crop_corners',
                        ) + thumbnail_settings.THUMBNAIL_PROCESSORS

THUMBNAIL_SOURCE_GENERATORS = ('cmj.utils.pil_image', )

MAX_DOC_UPLOAD_SIZE = 1512 * 1024 * 1024  # 1512MB
MAX_IMAGE_UPLOAD_SIZE = 10 * 1024 * 1024  # 10MB

FILE_UPLOAD_MAX_MEMORY_SIZE = MAX_DOC_UPLOAD_SIZE
DATA_UPLOAD_MAX_MEMORY_SIZE = MAX_DOC_UPLOAD_SIZE
Example #25
0
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import json

from django.core.exceptions import ImproperlyConfigured
from .base import *

from unipath import Path


# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
TEMPLATE_DEBUG = True
INSTALLED_APPS += ("debug_toolbar",)

BASE_DIR = Path(__file__).absolute().ancestor(3)
SECRETS_FILE = os.path.join(BASE_DIR.ancestor(1), "config.json")

with open(SECRETS_FILE) as f:
    secrets = json.loads(f.read())


def get_secret(setting, secrets=secrets):
    try:
        return secrets[setting]
    except KeyError:
        error_msg = "Set the {0} environment variable".format(setting)
        raise ImproperlyConfigured(error_msg)


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

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.9/ref/settings/
"""

import os
import sys
from unipath import Path
from django.utils import timezone
from bcpp_interview.logging import LOGGING

from bcpp_interview.config import CORS_ORIGIN_WHITELIST, EDC_SYNC_ROLE
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = Path(os.path.dirname(os.path.realpath(__file__)))
ETC_DIR = os.path.join(BASE_DIR.ancestor(1), 'etc')

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

# SECURITY WARNING: keep the secret key used in production secret!
with open(os.path.join(ETC_DIR, 'secret_key.txt')) as f:
    SECRET_KEY = f.read().strip()

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = ['localhost', '127.0.0.1']

# Application definition

INSTALLED_APPS = [
Example #27
0
"""Common settings and globals."""

from os.path import basename, join, normpath
from sys import path
from unipath import Path
from logging.handlers import SysLogHandler

# ######### PATH CONFIGURATION
# Absolute filesystem path to the Django project directory:
DJANGO_ROOT = Path(__file__).ancestor(3)

# Absolute filesystem path to the top-level project folder:
SITE_ROOT = DJANGO_ROOT.ancestor(1)

# Site name:
SITE_NAME = basename(SITE_ROOT)

# Path to the project Configuration app
CONFIGURATION_APP_ROOT = Path(__file__).ancestor(2)

# Path to public files (served by the web server)
PUBLIC_ROOT = SITE_ROOT.child('public')

# Add our project to our pythonpath, this way we don't need to type our project
# name in our dotted import paths:
path.append(DJANGO_ROOT)
path.append(CONFIGURATION_APP_ROOT)
# ######### END PATH CONFIGURATION

# ######### DEBUG CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#debug
Example #28
0
# -*- coding: utf-8 -*-

from logging.handlers import SysLogHandler
from os.path import basename
from sys import path
from unipath import Path


########## PATH CONFIGURATION

# Absolute filesystem path to the Django project directory
DJANGO_ROOT = Path(__file__).ancestor(3)

# Absolute filesystem path to the top-level project folder
PROJECT_ROOT = DJANGO_ROOT.ancestor(1)

# Site name
SITE_NAME = basename(PROJECT_ROOT)

# Path to public files (served by the web server)
PUBLIC_ROOT = PROJECT_ROOT.child('public')

# Path to the project Configuration app
CONFIGURATION_APP_ROOT = Path(__file__).ancestor(2)

# Add our project to our pythonpath, this way we don't need to type our project
# name in our dotted import paths:
path.append(DJANGO_ROOT)
path.append(CONFIGURATION_APP_ROOT)

Example #29
0
from decouple import AutoConfig
from easy_thumbnails.conf import Settings as thumbnail_settings
from unipath import Path


config = AutoConfig()

BASE_DIR = Path(__file__).ancestor(2)
PROJECT_DIR = Path(__file__).ancestor(3)

MEDIA_URL = '/media/'
MEDIA_ROOT = PROJECT_DIR.ancestor(1).child("cmj_media").child("media")
MEDIA_PROTECTED_ROOT = PROJECT_DIR.ancestor(
    1).child("cmj_media").child("media_protected")

FILTERS_HELP_TEXT_FILTER = False

IMAGE_CROPPING_SIZE_WARNING = True
IMAGE_CROPPING_JQUERY_URL = None
THUMBNAIL_PROCESSORS = (
    'image_cropping.thumbnail_processors.crop_corners',
) + thumbnail_settings.THUMBNAIL_PROCESSORS

THUMBNAIL_SOURCE_GENERATORS = (
    'cmj.utils.pil_image',
)

MAX_DOC_UPLOAD_SIZE = 200 * 1024 * 1024  # 200MB
MAX_IMAGE_UPLOAD_SIZE = 10 * 1024 * 1024  # 10MB

# Django settings for adl_lrs project.
from unipath import Path

# Root of LRS
SETTINGS_PATH = Path(__file__)
PROJECT_ROOT = SETTINGS_PATH.ancestor(3)

# If you want to debug
DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
    # ('Your Name', '*****@*****.**'),
)
MANAGERS = ADMINS

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'lrs',
        'USER': '******',
        'PASSWORD': '******',
        'HOST': 'localhost',
        'PORT': '',
    }    
}

# 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
Example #31
0
    },
]

# Internationalization

LANGUAGE_CODE = 'es-CO'

TIME_ZONE = 'America/Bogota'

USE_I18N = True

USE_L10N = True

USE_TZ = True

# Static files (CSS, JavaScript, Images)

STATIC_URL = '/static/'

STATIC_ROOT = BASE_DIR.ancestor(2).child('static')

STATICFILES_DIRS = (BASE_DIR.ancestor(1).child('static'), )

# Media

MEDIA_ROOT = BASE_DIR.ancestor(2).child('media')

MEDIA_URL = '/media/'

CORS_ORIGIN_ALLOW_ALL = True
Example #32
0
# Django settings for adl_lrs project.
from unipath import Path

# Root of LRS
SETTINGS_PATH = Path(__file__)
PROJECT_ROOT = SETTINGS_PATH.ancestor(3)

# If you want to debug
DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
    # ('Your Name', '*****@*****.**'),
)
MANAGERS = ADMINS

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'lrs',
        'USER': '******',
        'PASSWORD': '******',
        'HOST': 'localhost',
        'PORT': '',
    }    
}

# 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
Example #33
0
import sys
from unipath import Path


PROJECT_DIR = Path(__file__).ancestor(3)
sys.path.append(PROJECT_DIR.child('apps'))
print "PROJECT_DIR: %s" % PROJECT_DIR

PUBLIC_DIR = PROJECT_DIR.ancestor(1).child('public')

DEBUG = False
TEMPLATE_DEBUG = False


ADMINS = (
    # ('Your Name', '*****@*****.**'),
)

MANAGERS = ADMINS

AUTH_USER_MODEL = 'users.User'


# 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.
# In a Windows environment this must be set to your system time zone.
TIME_ZONE = 'America/Chicago'

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
Example #34
0
https://docs.djangoproject.com/en/1.6/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.6/ref/settings/
"""

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

from unipath import Path

DEVELOPER_HOSTS = ['mac2-2.local']
BASE_DIR = Path(os.path.dirname(os.path.realpath(__file__)))
GIT_DIR = BASE_DIR.ancestor(1)
ETC_PATH = Path(os.path.dirname(
    os.path.realpath(__file__))).ancestor(1).child('etc')
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.6/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = ')-8xsg3omyyv^jbm5tp=p%!l#)!br+c+6k4e9$(4c3h+&anel+'

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

TEMPLATE_DEBUG = True

ALLOWED_HOSTS = []
Example #35
0
USE_L10N = True

USE_TZ = True


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

STATICFILES_DIRS = (
    PROJECT_PATH.child('static').absolute(),
)

STATIC_URL = '/static/'

STATIC_ROOT = PROJECT_PATH.ancestor(1).child('statics').absolute()


MEDIA_URL = '/media/'

MEDIA_ROOT = PROJECT_PATH.ancestor(1).child('uploads').absolute()

CSV_ROOT = PROJECT_PATH.ancestor(1).child('csvs').absolute()


COUPONS_ROOT = STATIC_ROOT.child('coupons').absolute()

# Crons

CRON_CLASSES = [
    "leads.cron.CsvCreation",
Example #36
0
import os
# import dj_database_url
# from decouple import config
from unipath import Path

BASE_DIR = Path(__file__).ancestor(3)
DIST_DIR = BASE_DIR.ancestor(1).child("dist")
APPS_DIR = BASE_DIR.child("apps")
TEMPLATE_DIR = BASE_DIR.child("templates")
STATIC_FILE_DIR = BASE_DIR.child("static")

SECRET_KEY = os.environ['SECRET_KEY']

DEBUG = True

ALLOWED_HOSTS = []

DJANGO_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
]
THIRD_PARTY_APPS = [
    'webpack_loader',
    'rest_framework',
]
PROJECT_APPS = [
    'api',
Example #37
0
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]

LANGUAGE_CODE = 'fr'

TIME_ZONE = 'CET'

USE_I18N = True

USE_L10N = True

USE_TZ = True

# Absolute filesystem path to the Django project directory
DJANGO_ROOT = Path(__file__).ancestor(3)

# Absolute filesystem path to the top-level project folder
PROJECT_ROOT = DJANGO_ROOT.ancestor(2)

# Path to public files (served by the web server)
CWD = os.getcwd()
STATIC_ROOT = os.path.join(CWD, "static")

PUBLIC_ROOT = PROJECT_ROOT.child('public')
STATIC_URL = '/static/'
Example #38
0
print("\n*** Path")
here = Path(__file__)
print(here)

# Path Properties
print("\n*** Path Properties")
print(here.components()
      )  # A list of all the directories and the file as Path instances.
print(here.name)  # The file name
print(here.ext)  # The file extension
print(here.stem)  # The  file name without the extension

# Methods ( All return a Path instance )
print("\n*** Path Methods")
print(here.parent)  # The path without the file name
print(here.ancestor(5))  # Up x entities ( same as calling parent x times).
print(here.ancestor(3).child("PythonSandBox", "StandardLibrary"))  # Returns

print("\n*** Expand, Expand User and Expand Vars")
print(Path("~").expand_user())  # Expands ~ to a absolute path name
print(Path("$HOME").expand_vars())  # Expands system variables
print(Path("/home/luke/..").norm())  # Expands .. and . notation
print(Path("$HOME/..").expand())  # Expands system variables, ~ and also ..

# Expands system variable and ~. Will also normalise the path ( remove redundant
# .. . incorrect slashes and correct capitalisation on case sensitive file systems. Calls os.path.normpath

# File Attributes and permissions
print("\n*** File Attributes and permissions")
# noinspection PyArgumentList
print(here.atime())  # Last access time; seconds past epcoh
Example #39
0
"""
Django settings for galleria project.

For more information on this file, see
https://docs.djangoproject.com/en/1.6/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.6/ref/settings/
"""
import os

# Build paths inside the project like this: BASE_DIR.child("media")

from unipath import Path
SETTINGS_DIR = Path(__file__).expand_user().expand_vars().norm().absolute()
BASE_DIR = SETTINGS_DIR.ancestor(3) #Root of Django project
BASE_APP_DIR = SETTINGS_DIR.ancestor(2) #Root of main app of Django project
PROJECT_NAME = BASE_DIR.name # eg galleria

#The BASE_PRIVATE_DIR is the root of settings that should not be in the public GIT they are the information
# that will customise the application to a specific client. So for development this should be very little but possible
# if you like to have something a particular way and vital for production.

BASE_PRIVATE_DIR = SETTINGS_DIR.ancestor(5).child(PROJECT_NAME + '_private')

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

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '5rg#+%$#&c@q6#5r=u^ji0q9&&+5*v(r5wd)y(autnmz5n0bd%'
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

WSGI_APPLICATION = 'example.wsgi.application'

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

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR.ancestor(1), 'db.sqlite3'),
    }
}

# ssh -f -N -L 10000:127.0.0.1:5432 [email protected]
# DATABASES = {
#     'default': {
#         'ENGINE': 'django.db.backends.postgresql_psycopg2',
#         'NAME': 'bcppi',
#         'USER': '******',
#         'PASSWORD': '******',
#         'HOST': 'localhost',
#         'PORT': '5432',  # 10000 if remote
#     }
# }
Example #41
0
# Internationalization
# https://docs.djangoproject.com/en/1.6/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'America/Sao_Paulo'

# Languages available on this system.
LANGUAGES = (
    ('en', _('English')),
    ('pt-br', _('Portuguese')),
)

LOCALE_PATHS = (
    BASE_DIR.ancestor(1).child('locale') + '/',
)

USE_I18N = True

USE_L10N = True

USE_TZ = True


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

STATIC_ROOT = BASE_DIR.child('staticfiles')
STATIC_URL = '/static/'
Example #42
0
# Django settings for adl_lrs project.
from unipath import Path

# Root of LRS
SETTINGS_PATH = Path(__file__)
PROJECT_ROOT = SETTINGS_PATH.ancestor(3)

# If you want to debug
DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
    # ('Your Name', '*****@*****.**'),
)
MANAGERS = ADMINS

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'lrs',
        'USER': '******',
        'PASSWORD': '******',
        'HOST': 'localhost',
        'PORT': '',
    }
}

# 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
# Path
print("\n*** Path")
here = Path(__file__)
print(here)

# Path Properties
print("\n*** Path Properties")
print(here.components())  # A list of all the directories and the file as Path instances.
print(here.name)  # The file name
print(here.ext)  # The file extension
print(here.stem)  # The  file name without the extension

# Methods ( All return a Path instance )
print("\n*** Path Methods")
print(here.parent)  # The path without the file name
print(here.ancestor(5))  # Up x entities ( same as calling parent x times).
print(here.ancestor(3).child("PythonSandBox", "StandardLibrary"))  # Returns

print("\n*** Expand, Expand User and Expand Vars")
print(Path("~").expand_user())  # Expands ~ to a absolute path name
print(Path("$HOME").expand_vars())  # Expands system variables
print(Path("/home/luke/..").norm())  # Expands .. and . notation
print(Path("$HOME/..").expand())  # Expands system variables, ~ and also ..


# Expands system variable and ~. Will also normalise the path ( remove redundant
# .. . incorrect slashes and correct capitalisation on case sensitive file systems. Calls os.path.normpath

# File Attributes and permissions
print("\n*** File Attributes and permissions")
# noinspection PyArgumentList
Example #44
0
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

WSGI_APPLICATION = 'example.wsgi.application'


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

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR.ancestor(1), 'db.sqlite3'),
    }
}

# ssh -f -N -L 10000:127.0.0.1:5432 [email protected]
# DATABASES = {
#     'default': {
#         'ENGINE': 'django.db.backends.postgresql_psycopg2',
#         'NAME': 'bcppi',
#         'USER': '******',
#         'PASSWORD': '******',
#         'HOST': 'localhost',
#         'PORT': '5432',  # 10000 if remote
#     }
# }
Example #45
0
"""Common settings and globals."""


from os.path import basename, join, normpath
from sys import path
from unipath import Path
from logging.handlers import SysLogHandler


# ######### PATH CONFIGURATION
# Absolute filesystem path to the Django project directory:
DJANGO_ROOT = Path(__file__).ancestor(3)

# Absolute filesystem path to the top-level project folder:
SITE_ROOT = DJANGO_ROOT.ancestor(1)

# Site name:
SITE_NAME = basename(SITE_ROOT)

# Path to the project Configuration app
CONFIGURATION_APP_ROOT = Path(__file__).ancestor(2)

# Path to public files (served by the web server)
PUBLIC_ROOT = SITE_ROOT.child('public')

# Add our project to our pythonpath, this way we don't need to type our project
# name in our dotted import paths:
path.append(DJANGO_ROOT)
path.append(CONFIGURATION_APP_ROOT)
# ######### END PATH CONFIGURATION
Example #46
0
from .base import *
from unipath import Path

PROJECT_DIR = Path(__file__).ancestor(2)
MEDIA_ROOT = PROJECT_DIR.ancestor(2).child("inoxtags_media")
STATIC_ROOT = PROJECT_DIR.ancestor(2).child("inoxtags_static")
STATICFILES_DIRS = (PROJECT_DIR.child("static"),)
TEMPLATE_DIRS = (PROJECT_DIR.child("templates"),)

# Path to the po|mo files
LOCALE_PATHS = PROJECT_DIR.child("locale")

CKEDITOR_UPLOAD_PATH = PROJECT_DIR.ancestor(2).child("inoxtags_media").child("ck_uploads")

DEBUG = False
TEMPLATE_DEBUG = DEBUG

DATABASES = {
    "default": {
        "ENGINE": "django.db.backends.postgresql_psycopg2",
        "NAME": get_env_variable("INOXTAGS_DB_NAME"),
        "USER": get_env_variable("INOXTAGS_DB_USER"),
        "PASSWORD": get_env_variable("INOXTAGS_DB_PASSWORD"),
    }
}

ALLOWED_HOSTS = [".inoxtags.com"]

MEDIA_URL = "https://www.inoxtags.com/media/"
STATIC_URL = "https://www.inoxtags.com/static/"
LOGIN_URL = '/{app_name}/login/'.format(app_name=APP_NAME)
LOGIN_REDIRECT_URL = '/{app_name}/'.format(app_name=APP_NAME)
LOGOUT_URL = '/{app_name}/logout/'.format(app_name=APP_NAME)

# 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',
)

# edc.crytpo_fields encryption keys
# developers should set by catching their hostname instead of setting
# explicitly

GIT_DIR = BASE_DIR.ancestor(1)

STUDY_OPEN_DATETIME = timezone.datetime(2015, 10, 18, 0, 0, 0)

APP_LABEL = 'tshilo_dikotla'
LABEL_PRINTER_MAKE_AND_MODEL = ['Zebra ZPL Label Printer']

SUBJECT_APP_LIST = ['maternal', 'infant']
SUBJECT_TYPES = ['maternal', 'infant']
MAX_SUBJECTS = {'maternal': 559, 'infant': 559}
MINIMUM_AGE_OF_CONSENT = 18
MAXIMUM_AGE_OF_CONSENT = 64
AGE_IS_ADULT = 18
GENDER_OF_CONSENT = ['F']
DISPATCH_APP_LABELS = []
Example #48
0
    """Get the environment variable or return exception"""
    try:
        return os.environ[var_name]
    except KeyError:
        error_msg = "Set the {var_name} environment variable".format(
            var_name=var_name)
        raise ImproperlyConfigured(error_msg)


DATABASE_URL = get_env_variable("DATABASE_URL")

DATABASES = {'default': dj_database_url.config(default=DATABASE_URL)}

PROJECT_ROOT = Path(__file__).ancestor(2)

PROJECT_NAME = str(PROJECT_ROOT.ancestor(1).name)

TIME_ZONE = 'America/Los_Angeles'

LANGUAGE_CODE = 'en-us'

SITE_ID = 1

USE_I18N = False

USE_L10N = True

USE_TZ = True

STATICFILES_DIRS = (PROJECT_ROOT.child("static"), )
Example #49
0
from unipath import Path

PROJECT_DIR = Path(__file__).ancestor(2)
print "PROJECT_DIR: %s" % PROJECT_DIR
# Django settings for demo project.

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
    # ('Your Name', '*****@*****.**'),
)

MANAGERS = ADMINS

DB = PROJECT_DIR.ancestor(2) + '/d201305.db'
print "DB: %s" % DB

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',  # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': DB,                      # Or path to database file if using sqlite3.
        # The following settings are not used with sqlite3:
        'USER': '',
        'PASSWORD': '',
        'HOST': '',                      # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP.
        'PORT': '',                      # Set to empty string for default.
    }
}

# Hosts/domain names that are valid for this site; required if DEBUG is False
# Can be used to attempt to access an environment variable, and if it is unavailable,
#   gives a more useful error message and traceback so the variable can be set by a
#   sysadmin.
def get_env_variable(var_name):
    try:
        return os.environ[var_name]
    except KeyError:
        error_msg = msg % var_name
        raise ImproperlyConfigured(error_msg)

SECRET_KEY = get_env_variable("DJANGO_SECRET_KEY")

# Set this_file to  '/path/to/electricemberwebsite/ElectricEmberWebsite/settings/base.py'
#   so that other important directories can be defined relative to it.
this_file = Path(__file__).absolute()
PROJECT_DIR = this_file.ancestor(3)  # PROJECT_DIR = '/path/to/electricemberwebsite/'
PROJECT_APPS_DIR = PROJECT_DIR.child("ElectricEmberWebsite")
MEDIA_ROOT = PROJECT_APPS_DIR.child("media")
STATIC_ROOT = PROJECT_APPS_DIR.child("static")
TEMPLATE_DIRS = (
    PROJECT_APPS_DIR.child("templates"),
)

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://example.com/media/", "http://media.example.com/"
MEDIA_URL = '/media/'
STATIC_URL = '/static/'
STATICFILES_DIRS = (
#    (PROJECT_APPS_DIR.child("static").child("bootstrap").child("js")),
    PROJECT_APPS_DIR.child("static"),
Example #51
0
#!/usr/bin/env python

import textwrap
from collections import OrderedDict
from inspect import getsourcefile
from os.path import abspath
from string import Template

from pyexcel_ods3 import get_data
from unipath import Path

# Directory where this file is found
basedir = Path(abspath(getsourcefile(lambda: 0))).ancestor(1)
SOURCE_ROOT = basedir.ancestor(1)
TESTS_DIR = SOURCE_ROOT.child('tests')
RES_DIR = TESTS_DIR.child('res')
TEST_CASES_DIR = RES_DIR.child('test_cases')
VARIANT_TESTS_DIR = TESTS_DIR.child('tessellation')


class SpecGenerator(object):

    VARIANTS = ['sokoban', 'trioban', 'hexoban', 'octoban']
    TEST_TYPES = ['board', 'tessellation']

    DIRECTIONS = ['l', 'r', 'u', 'd', 'nw', 'sw', 'ne', 'se']
    DIRECTIONS_HASH = dict(
        zip(
            DIRECTIONS, [
                "Direction.LEFT", "Direction.RIGHT", "Direction.UP",
                "Direction.DOWN", "Direction.NORTH_WEST",
Example #52
0
    ('en', _('English')),
    ('nl', _('Dutch')),
]

LANGUAGE_CODE = 'nl'
TIME_ZONE = 'Europe/Amsterdam'

# TIME_ZONE = 'UTC'

USE_I18N = False

USE_L10N = True

USE_TZ = True

MEDIA_ROOT = BASE_DIR.ancestor(1).child('dynamic').child('public')
MEDIA_URL = '/media/'  # Must have trailing slash
STATIC_ROOT = BASE_DIR.ancestor(1).child('static_collected')
STATIC_URL = '/static/'  # Must have trailing slash
PRIVATE_ROOT = BASE_DIR.ancestor(1).child('dynamic').child('private')

STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    'compressor.finders.CompressorFinder',
)

try:
    os.makedirs(PRIVATE_ROOT)
except OSError:
    pass
Example #53
0
LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = False


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

STATIC_URL = '/static/'

GIT_DIR = BASE_DIR.ancestor(1)

SITE_CODE = '10'
DEVICE_ID = '10'
SERVER_DEVICE_ID_LIST = [99]
MIDDLEMAN_DEVICE_ID_LIST = []
PROJECT_ROOT = BASE_DIR.ancestor(1)
FIELD_MAX_LENGTH = 'default'
IS_SECURE_DEVICE = True
KEY_PATH = os.path.join(BASE_DIR.ancestor(1), 'crypto_fields')
KEY_PREFIX = 'user'
ALLOW_MODEL_SERIALIZATION = False
DISPATCH_APP_LABELS = []
Example #54
0
limitations under the License.
"""


import os
import sys

try:
    from unipath import Path
except ImportError:
    print 'Please run pip install Unipath, to install this module.'
    sys.exit(1)

PROJECT_ROOT = Path(__file__).ancestor(2)

LOG_PATH = PROJECT_ROOT.ancestor(1).child('logs')

if not os.path.isdir(LOG_PATH):
    os.mkdir(LOG_PATH)

DEBUG = False

TEMPLATE_DEBUG = False

ADMINS = (
    # ('Your Name', '*****@*****.**'),
)

MANAGERS = ADMINS

Example #55
0
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.10/ref/settings/
"""

from logging.handlers import SysLogHandler
import os

from django.core.urlresolvers import reverse_lazy

import getconf
from unipath import Path

# Build paths inside the project like this: BASE_DIR.child(...)
CONFIGURATION_APP_ROOT = Path(os.path.abspath(__file__)).ancestor(1)
BASE_DIR = CONFIGURATION_APP_ROOT.ancestor(1)
PROJECT_ROOT = BASE_DIR.ancestor(1)
SITE_NAME = os.path.basename(PROJECT_ROOT)
PUBLIC_ROOT = PROJECT_ROOT.child('public')

CONFIG = getconf.ConfigGetter(SITE_NAME, [
    '/etc/%s/settings/' % SITE_NAME,
    PROJECT_ROOT.child('local_settings.ini'),
])

ENVIRONMENT = CONFIG.getstr('environment', 'dev')
assert ENVIRONMENT in ('prod', 'dev', 'test')


# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = CONFIG.getstr('django.secret_key', 'unsecure')
Example #56
0
import os

from django.contrib import messages
from unipath import Path

SETTINGS_DIR = Path(os.path.abspath(__file__))
SOURCE_ROOT = SETTINGS_DIR.ancestor(2)
PROJECT_ROOT = SETTINGS_DIR.ancestor(3)

# Application definition
INSTALLED_APPS = (
    'django_admin_bootstrapped',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',

    'markdownx',
    'annoying',  # django-annoying
    'kkwp.glyphiconfield',

    'kkwp.cms',
    'kkwp.archive',
    'kkwp.finance',
)

if 'SENTRY_DSN' in os.environ:
    INSTALLED_APPS += (
        'raven.contrib.django',
Example #57
0
class Project(TimeStampedModel):
    domain = models.CharField(max_length=100,
                              blank=False,
                              unique=True,
                              validators=[DomainValidator])
    path = models.CharField(max_length=255, blank=True)
    status = models.BooleanField(default=True)

    _unipath = None

    def __unicode__(self):
        return self.domain

    """ --------------------------------------------------------- """

    def save(self, *args, **kwargs):
        self.path = Path('/data/www', self.safe_domain_name())

        # create directory before create object
        if self.pk == None:
            # @todo do not allowed create on root permission
            if not self.path.isdir():
                uid = 0
                gid = 0
                # find uid and gid of closest parent directory
                iterator = self.path.ancestor(1)
                component = len(iterator.components())
                for i in xrange(component):
                    if iterator.isdir():
                        stat = iterator.stat()
                        uid = stat.st_uid
                        gid = stat.st_gid
                        break
                    iterator = iterator.ancestor(1)
                # create all neccesary files and directories
                self.path.child('public').mkdir(True)
                self.path.child('logs').mkdir(True)
                self.apache_vhost_file().write_file('')
                self.apache_access_log().write_file('')
                self.apache_error_log().write_file('')
                # need 777 or apache won't sent errors here
                self.php_error_log().write_file('')
                self.php_error_log().chmod(0777)
                # make files available to user
                shell_exec(["chown", "-R", "%d:%d" % (uid, gid), iterator])
        else:
            # get its previous domain value, if it changes, rename virtualhost file
            old = Project.objects.get(pk=self.pk)
            if self.domain != old.domain:
                old.apache_vhost_file().rename(self.apache_vhost_file())

        # update database, /etc/hosts and apache virtualhost then reload apache
        super(Project, self).save(*args, **kwargs)
        #update_hostfile()
        self.apache_vhost_file().write_file(
            render_to_string("vhost.html", {'project': self}))
        Apache().reload()

    def clean_all(self, *args, **kwargs):
        self.apache_vhost_file().remove()
        self.get_path().rmtree()
        update_hostfile()
        Apache().reload()

    def safe_domain_name(self):
        return re.sub(r"[^a-zA-Z0-9\.\-]+", "-", self.domain)

    def get_path(self):
        if self._unipath == None:
            self._unipath = Path(self.path)
        return self._unipath

    def document_root(self):
        return Path(self.path).child('public')

    def apache_vhost_file(self):
        return Path('/data/vhosts/%s.conf' % self.safe_domain_name())

    def apache_access_log(self):
        return self.get_path().child('logs', 'access.log')

    def apache_error_log(self):
        return self.get_path().child('logs', 'error.log')

    def php_error_log(self):
        return self.get_path().child('logs', 'error-php.log')
Example #58
0
}

# 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

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

STATIC_URL = '/static/'

GIT_DIR = BASE_DIR.ancestor(1)

KEY_PATH = os.path.join(BASE_DIR.ancestor(1), 'crypto_fields')
KEY_PREFIX = 'test'
PROJECT_ROOT = BASE_DIR

SERVER_DEVICE_ID_LIST = []
MIDDLEMAN_DEVICE_ID_LIST = []
FIELD_MAX_LENGTH = 'default'
IS_SECURE_DEVICE = True