Пример #1
0
#!/bin/env python
import sys
sys.path.append('.')

import subprocess
from migrate_data.env import get_app_env, get_data_dir, get_data_filename, python, pythonpath, manage_py, models

app_env = get_app_env()
env = {
    'DJANGO_GALLERY_ENVIRONMENT': app_env,
    'PYTHONPATH': pythonpath,
}
subprocess.call(['mkdir', '-p', get_data_dir(app_env)])
for model in models:
    filename = get_data_filename(app_env, model)
    print "dumping %s to %s" % (model, filename)
    output = open(filename, 'w')
    subprocess.Popen([python, manage_py, 'dumpdata', '--indent', '2', model], env=env, stdout=output)
    output.close()
Пример #2
0
#!/bin/env python
import sys
sys.path.append('.')
from migrate_data.env import get_app_env, get_data_filename, pythonpath, models, model_fields
import os
import re
import json
import copy
import datetime

for path in pythonpath.split(':'):
    sys.path.append(path)
(source_env, target_env) = get_app_env(target=True)
os.environ['DJANGO_SETTINGS_MODULE'] = 'gallery.settings'
os.environ['DJANGO_GALLERY_ENVIRONMENT'] = target_env

import django
django.setup()

from django.apps import apps
from django.db import connection
from django.utils.crypto import get_random_string
from django_adelaidex.lti.models import User, Cohort

# Get or create cohort
try:
    cohort = Cohort.objects.get(oauth_key=source_env)
    created = False
except Cohort.DoesNotExist:
    oauth_secret = get_random_string(50,'[email protected]#$%^&*(-_=+)')
    cohort = Cohort.objects.create(