forked from adlnet/ADL_LRS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fabfile.py
78 lines (58 loc) · 2.41 KB
/
fabfile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import os
import sys
from fabric.api import local
def setup_env():
# INSTALL_STEPS = [
# 'virtualenv ../env;. ../env/bin/activate;pip install -r requirements.txt;deactivate']
# for step in INSTALL_STEPS:
# local(step)
pass
def setup_lrs():
# Media folder names
agent_profile = 'agent_profile'
activity_profile = 'activity_profile'
activity_state = 'activity_state'
statement_attachments = 'attachment_payloads'
# # Add env packages and project to the path
# cwd = os.path.dirname(os.path.abspath(__file__))
if cwd not in sys.path:
sys.path.append(cwd)
# env_dir = os.path.join(cwd, '../env/lib/python2.7/site-packages')
# if env_dir not in sys.path:
# sys.path.append(env_dir)
log_dir = os.path.join(cwd, '../logs')
if not os.path.exists(log_dir):
os.makedirs(log_dir)
celery_log_dir = os.path.join(log_dir, 'celery')
if not os.path.exists(celery_log_dir):
os.makedirs(celery_log_dir)
supervisord_log_dir = os.path.join(log_dir, 'supervisord')
if not os.path.exists(supervisord_log_dir):
os.makedirs(supervisord_log_dir)
uwsgi_log_dir = os.path.join(log_dir, 'uwsgi')
if not os.path.exists(uwsgi_log_dir):
os.makedirs(uwsgi_log_dir)
nginx_log_dir = os.path.join(log_dir, 'nginx')
if not os.path.exists(nginx_log_dir):
os.makedirs(nginx_log_dir)
# Add settings module so fab file can see it
os.environ['DJANGO_SETTINGS_MODULE'] = "adl_lrs.settings"
from django.conf import settings
adldir = settings.MEDIA_ROOT
# Create media directories
if not os.path.exists(os.path.join(adldir, activity_profile)):
os.makedirs(os.path.join(adldir, activity_profile))
if not os.path.exists(os.path.join(adldir, activity_state)):
os.makedirs(os.path.join(adldir, activity_state))
if not os.path.exists(os.path.join(adldir, agent_profile)):
os.makedirs(os.path.join(adldir, agent_profile))
if not os.path.exists(os.path.join(adldir, statement_attachments)):
os.makedirs(os.path.join(adldir, statement_attachments))
# Create cache tables and sync the db
local('./manage.py createcachetable')
local('./manage.py migrate')
local('./manage.py makemigrations adl_lrs lrs oauth_provider')
local('./manage.py migrate')
local('./manage.py createsuperuser')
def test_lrs():
local('./manage.py test lrs.tests')