Esempio n. 1
0
def initialize_database(options):
    if options.db_postgresql:
        commands = ('CREATE USER {} WITH PASSWORD \'{}\';'.format(
            options.db_user, options.db_password),
                    'ALTER ROLE {} SET client_encoding TO \'utf8\';'.format(
                        options.db_user),
                    'ALTER ROLE {} SET default_transaction_isolation '
                    'TO \'read committed\';'.format(options.db_user),
                    'ALTER ROLE {} SET timezone TO \'UTC\';'.format(
                        options.db_user),
                    'CREATE DATABASE {} WITH OWNER {}'.format(
                        options.db_name, options.db_user))
        __psql(options, superuser=True, commands=commands)
        django_command([argv[0], 'makemigrations', 'log'])
    elif not exists('campaign-data'):
        mkdir('campaign-data')
    django_command([argv[0], 'migrate'])
Esempio n. 2
0
def run_django_command(options):
    command = [argv[0] + ' ' + options.command]
    for item in options.django_command:
        command.append(item)
    django_command(command)
Esempio n. 3
0
def view_log(options):
    django_command([
        argv[0], 'runserver',
        ('0.0.0.0:' if options.external else '') + str(options.port)
    ])