Exemple #1
0
def pull():
    """
    Pulls latest changes from Git
    """
    require("root", provided_by=("An environment task"))
    with cd(env.root):
        execute("git pull")
Exemple #2
0
def fetch(tags=False):
    """
    Fetches from Git
    """
    require("root", provided_by=("An environment task"))
    with cd(env.root):
        execute("git fetch %s" % ("--tags" if tags else ""))
Exemple #3
0
def checkout(name):
    """
    Checkouts the given tag or branch
    """
    require("root", provided_by=("An environment task"))
    with cd(env.root):
        execute("git checkout %s" % name)
Exemple #4
0
def integration_tests():
    """
    Run integration tests.
    """
    from django.conf import settings
    for app in settings.APP_MODULES:
        execute('nosetests -w %s/tests/integration' % app)
Exemple #5
0
def acceptance_tests():
    """
    Run acceptance tests.
    """
    from django.conf import settings
    for app in settings.APP_MODULES:
        execute('nosetests -w %s/tests/acceptance' % app)
Exemple #6
0
def up():
    """
    Updates to the latest changes from SVN
    """
    require('root', provided_by=('An environment task'))
    with cd(env.root):
        execute('svn up')
Exemple #7
0
def unit_tests():
    """
    Run unit tests.
    """
    from django.conf import settings
    for app in settings.APP_MODULES:
        execute('nosetests -w %s/tests/unit' % app)
def dropdb():
    # Invert apps to avoid dependency problems.
    from django.conf import settings
    apps = list(settings.INSTALLED_APPS)
    apps.reverse()

    failed_apps = []

    for app in apps:
        app = app.split('.')[-1]
        with cd(env.root):
            with virtualenv():
                try:
                    # We need to split DROP TABLEs from DROP FK because MySQL aborts if the FK doesn't exists
                    try:
                        execute('python manage.py sqlclear %(app)s --settings=%(settings)s | grep "DROP FOREIGN KEY" | ./manage.py dbshell --settings=%(settings)s' % {'app': app, 'settings': env.settings})
                    except:
                        # Ignore errors while dropping FK.
                        pass
                    execute('python manage.py sqlclear %(app)s --settings=%(settings)s | grep "DROP TABLE" | ./manage.py dbshell --settings=%(settings)s' % {'app': app, 'settings': env.settings})
                except:
                    failed_apps.insert(0, app)

    if failed_apps:
        dropdb(failed_apps)
Exemple #9
0
def install_dependencies(path='requirements.txt'):
    """
    Install dependencies defined in requirements.txt
    """
    require('root', provided_by=('An environment task'))
    with cd(env.root):
        with virtualenv():
            execute('pip install -r %s' % path)
def migrate(initial_data=False):
    require('root', provided_by=('An environment task'))
    with cd(env.root):
        with virtualenv():
            if initial_data:
                execute('python manage.py migrate --settings=%(settings)s' % env)
            else:
                execute('python manage.py migrate --no-initial-data --settings=%(settings)s' % env)
def syncdb(initial_data=False):
    from django.conf import settings
    require('root', provided_by=('An environment task'))
    with cd(env.root):
        with virtualenv():
            execute('python manage.py syncdb --noinput --settings=%(settings)s' % env)
    if 'south' in settings.INSTALLED_APPS:
        migrate(initial_data)
Exemple #12
0
def clear():
    """
    Recreate de db schema.
    """
    from django.conf import settings
    file_name = settings.DATABASES['default']['NAME']

    if os.path.exists(file_name):
        execute('rm %s' % file_name)
def collect_static():
    from django.conf import settings

    require('root', provided_by=('An environment task'))
    with cd(env.root):
        with virtualenv():
            execute('python manage.py collectstatic --noinput --settings=%(settings)s' % env)
            if 'compressor' in settings.INSTALLED_APPS and getattr(settings, 'COMPRESS_ENABLED', False) and getattr(settings, 'COMPRESS_OFFLINE', False):
                execute('python manage.py compress --force --settings=%(settings)s' % env)
Exemple #14
0
def install(package=None, version_str=" "):
    """
    Install a pip package.
    """
    if not package:
        abort('Provide a package name and optionally a version. Example: fab %(command)s:package=django,version===1.2' % env)

    with virtualenv():
        execute('pip install %s%s' % (package, version_str))
        execute('pip freeze > requirements.txt')
Exemple #15
0
def uninstall(package=None):
    """
    Uninstall a pip package.
    """
    if not package:
        abort('Provide a package name. Example: fab %(command)s:package=django' % env)

    with virtualenv():
        execute('pip uninstall %s' % package)
        execute('pip freeze > requirements.txt')
def rebuild_index():
    require('root', provided_by=('An environment task'))
    with cd(env.root):
        with virtualenv():
            execute('python manage.py rebuild_index --noinput --settings=%(settings)s' % env)