Ejemplo n.º 1
0
def django_syncdb():
    """ 
    Synchronize/create database on remote host 
    """
    _setup_env()
    sys.path.append(env.base_path)
    django.settings_module('%(project_name)s.settings_%(role)s' % env)
    settings = __import__('%(project_name)s.settings_%(role)s' % env)

    # Not sure what's going on here .. but it fixes a problem..
    if getattr(settings, 'settings_%(role)s' % env, False):
        settings = getattr(settings, 'settings_%(role)s' % env, False)

    dbconf = settings.DATABASES['default']

    #if dbconf['ENGINE'].endswith('mysql'):
    #    _create_mysqldb(dbconf)
    # Give apache write permission to the project directory
    if dbconf['ENGINE'].endswith('sqlite3') and env.role != 'dev':
        user = '******' in env.stage and env.stage['user'] or 'www-data'
        sudo('chown -R %s %s' % (user, os.path.dirname(dbconf['NAME'])))
        sudo('chmod 777 %s' % dbconf['NAME'])

    if env.role in ['prod', 'demo']:
        path = env.stage['path']
        do = run
    else:
        path = env.base_path
        do = local

    if (yes_no_prompt("Do you want to syncdb ?")):
        with (cd(os.path.join(path, env.project_name))):
            do(env.venv_activate +
               ' && %s manage.py syncdb --noinput --settings=settings_%s' %
               (env.venv_python, env.role))
Ejemplo n.º 2
0
def django_syncdb():
    """ 
    Synchronize/create database on remote host 
    """
    _setup_env()
    sys.path.append(env.base_path)
    django.settings_module('%(project_name)s.settings_%(role)s' % env)
    settings = __import__('%(project_name)s.settings_%(role)s' % env)
    
    # Not sure what's going on here .. but it fixes a problem..
    if getattr(settings, 'settings_%(role)s' % env, False):
        settings = getattr(settings, 'settings_%(role)s' % env, False)

    dbconf = settings.DATABASES['default']

    if dbconf['ENGINE'].endswith('mysql'):
        _create_mysqldb(dbconf)
    # Give apache write permission to the project directory
    elif dbconf['ENGINE'].endswith('sqlite3') and env.role != 'dev':
        user = '******' in env.stage and env.stage['user'] or 'www-data'
        sudo('chown -R %s %s' % (user, os.path.dirname(dbconf['NAME'])))
        sudo('chmod 777 %s' % dbconf['NAME'])
        

    if env.role in ['prod', 'demo']:
        path = env.stage['path']
        do = run
    else:
        path = env.base_path
        do = local

    if (yes_no_prompt("Do you want to syncdb ?")):
        with(cd(os.path.join(path, env.project_name))):
            do(env.venv_activate +' && %s manage.py syncdb --noinput --settings=settings_%s' % (env.venv_python, env.role))
Ejemplo n.º 3
0
def setup_dev():
    """
    Activates the development environment. These actions are performed:

     * Create a virtualenv if it doesn't already exists
     * Create bootstrap script if it doesn't already exists

    """
    _setup_env()
    print "Starting dev environment for %s" % env.project_name
    bootstrap_path = os.path.join(env.dadconf_path, 'dev.sh')
    if not os.path.exists(env.venv_path):
        setup_virtualenv()
    else:
        if not os.path.exists(bootstrap_path):
            if yes_no_prompt("A virtualenv with the same name has been found, \
would you like to use this one ? Otherwise it will be deleted and recreated.", True):
                _create_dev_bootstrap(env.venv_path, env.venv_name)
            else:
                local("rm -rf %s" % os.path.join(env.venv_path, env.venv_name))
                setup_virtualenv()
Ejemplo n.º 4
0
def setup_dev():
    """
    Activates the development environment. These actions are performed:

     * Create a virtualenv if it doesn't already exists
     * Create bootstrap script if it doesn't already exists

    """
    _setup_env()
    print "Starting dev environment for %s" % env.project_name
    bootstrap_path = os.path.join(env.dadconf_path, 'dev.sh')
    if not os.path.exists(env.venv_path):
        setup_virtualenv()
    else:
        if not os.path.exists(bootstrap_path):
            if yes_no_prompt(
                    "A virtualenv with the same name has been found, \
would you like to use this one ? Otherwise it will be deleted and recreated.",
                    True):
                _create_dev_bootstrap(env.venv_path, env.venv_name)
            else:
                local("rm -rf %s" % os.path.join(env.venv_path, env.venv_name))
                setup_virtualenv()