diff --git a/common/settings.py b/common/settings.py index 10388a3..bcc8fa1 100644 --- a/common/settings.py +++ b/common/settings.py @@ -103,6 +103,9 @@ STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.ManifestStaticFilesSto ALLOWED_HOSTS = ['localhost', 'stages.pierre-coullery.ch'] +FABRIC_HOST = 'stages.pierre-coullery.ch' +FABRIC_USERNAME = '' + # Mapping between column names of a tabular file and Student field names STUDENT_IMPORT_MAPPING = { 'NOCLOEE': 'ext_id', diff --git a/scripts/fabfile.py b/scripts/fabfile.py index 996c4f0..e043448 100644 --- a/scripts/fabfile.py +++ b/scripts/fabfile.py @@ -3,21 +3,26 @@ import os import sys from fabric.api import cd, env, get, local, prefix, prompt, run +from fabric.contrib import django from fabric.utils import abort -env.hosts = ['stages.pierre-coullery.ch'] APP_DIR = '/var/www/epcstages' VIRTUALENV_DIR = '/var/virtualenvs/stages/bin/activate' +"""Read settings from Django settings""" +sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +django.settings_module('common.settings') +from common import settings + +env.hosts = [settings.FABRIC_HOST] +env.user = settings.FABRIC_USERNAME + def clone_remote_db(dbtype='sqlite'): """ Copy remote data (JSON dump), download it locally and recreate a local SQLite database with those data. """ - sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) - from common import settings - db_path = settings.DATABASES['default']['NAME'] if os.path.exists(db_path): rep = prompt('A local database (%s) already exists. Overwrite? (y/n)' % db_path)