Exemple #1
0
def update_requirements(require='dev3rdparty'):
    """Runs pip install -r requirements on the right file
    """
    _default('local')
    _ve_local("pip install -r requirements/compiled.pip")
    _ve_local("pip install -r requirements/%s.pip" % require)
    test()
Exemple #2
0
def install_dev():
    """Install dev environment and dependencies

    Installs pip, virtualenv and virtualenvwrapper
    Creates workon directory
    Updates all (eventual) submodules
    Installs simplejson, mysql-python and edge dependencies
    If PROJECT_DEV dev_from_edge is called

    Example: fab install_dev
    """
    _default('local')
    local('sudo easy_install pip')
    local('sudo pip install virtualenvwrapper')
    local('sudo pip install virtualenv')
    if not os.path.exists(env.workondir):
        local("mkdir %s" % env.workondir)
    if not os.path.exists(os.path.join(env.workondir, env.virtualenv)):
        # Create virtual environment
        local("""
            export WORKON_HOME=%s &&
            source %s &&
            mkvirtualenv --no-site-packages %s
            """ % (env.workondir, env.ve_wrapper, env.virtualenv))
    local("git submodule update --init --recursive")
    _ve_local("""
             pip install simplejson &&
             pip install mysql-python &&
             pip install -r requirements/edge.pip""")
    if sett.PROJECT_TYPE == sett.PROJECT_DEV:
        if not dev_from_edge():
            return
    test()
Exemple #3
0
def createsuperuser():
    """Creates django project admin

    Example: fab createsuperuser
    """
    _default('local')
    _ve_local('./manage.py createsuperuser')
Exemple #4
0
def update_dev(repository='upstream'):
    """Update development packages

    Depending on PROJECT_TYPE it runs pip updates dev3rdparty or edge
    If PROJECT_DeV it also git checkes master and pulls master from upstream

    Example: fab update_dev
    """
    _default('local')
    if not os.path.exists(env.workondir):
        if not confirm("No virtualenv provided. Should I install?"):
            return
        install_dev()
        return
    local("git status")
    if confirm("Should I checkout to and pull from master?"):
        local("git checkout master && git pull %s master" % repository)

    if sett.PROJECT_TYPE == sett.PROJECT_DEV:
        # update APPS
        _ve_local("pip install -r requirements/dev3rdparty.pip")
        for app in sett.APPS:
            with lcd(os.path.join(env.workondir, env.virtualenv, 'src', app)):
                print _cyan('Updating %s' % app)
                local("git status")
                if confirm("Should I checkout to and pull from master"):
                    local("git status")
                    local("git checkout master && git pull %s master" % repository)
    if sett.PROJECT_TYPE == sett.PROJECT_EDGE:
        # update APPS from master branch
        _ve_local("pip install -r requirements/edge.pip --upgrade")
Exemple #5
0
def test(apps=ALLAPS_PLUS, params=None):
    """Run unittests

    :param: apps (string) optional - apps which needs to be tested
            (separated by +), default ALLAPS_PLUS
    :param: params (string) optional - parameters of the ``./manage.py test``
            (separated by +), default coverage settings
    """
    _default('local')
    apps = apps.replace('+', ' ')
    # use all for apps to allow additional settings
    if apps == 'all':
        apps = sett.ALLAPS
    temp_cover_packages = apps.split(' ')
    cover_packages = []
    for cp in temp_cover_packages:
        cover_packages.append(cp.split('.')[0])
    cover_packages = ','.join(cover_packages)
    params = params.split('+') if params else []
    params.extend(['nocapture', 'nologcapture',
        #'with-fixture-bundling',
        'with-progressive',
        'with-coverage', 'cover-inclusive', 'cover-erase', 'cover-tests',
        'cover-exclude-module=base64,migrations,settings$',
        'cover-package=%s' % cover_packages])
    command = './manage.py test %s --%s' % (
            apps,
            ' --'.join(params))
    _ve_local(command)
Exemple #6
0
def test(apps=ALLAPS_PLUS, params=None):
    """Run unittests

    :param: apps (string) optional - apps which needs to be tested
            (separated by +), default ALLAPS_PLUS
    :param: params (string) optional - parameters of the ``./manage.py test``
            (separated by +), default coverage settings
    """
    _default('local')
    apps = apps.replace('+', ' ')
    # use all for apps to allow additional settings
    if apps == 'all':
        apps = sett.ALLAPS
    temp_cover_packages = apps.split(' ')
    cover_packages = []
    for cp in temp_cover_packages:
        cover_packages.append(cp.split('.')[0])
    cover_packages = ','.join(cover_packages)
    params = params.split('+') if params else []
    params.extend(['nocapture', 'nologcapture',
        #'with-fixture-bundling',
        'with-progressive',
        'with-coverage', 'cover-inclusive', 'cover-erase', 'cover-tests',
        'cover-exclude-module=base64,migrations,settings$',
        'cover-package=%s' % cover_packages])
    command = './manage.py test %s --%s' % (
            apps,
            ' --'.join(params))
    _ve_local(command)
Exemple #7
0
def createsuperuser():
    """Creates django project admin

    Example: fab createsuperuser
    """
    _default('local')
    _ve_local('./manage.py createsuperuser')
Exemple #8
0
def manage(*args):
    """Run ./manage.py commands

    Example: fab manage:south
    """
    _default('local')
    _ve_local('./manage.py %s' % ' '.join(args))
Exemple #9
0
def manage(*args):
    """Run ./manage.py commands

    Example: fab manage:south
    """
    _default('local')
    _ve_local('./manage.py %s' % ' '.join(args))
Exemple #10
0
def install_dev():
    """Install dev environment and dependencies

    Installs pip, virtualenv and virtualenvwrapper
    Creates workon directory
    Updates all (eventual) submodules
    Installs simplejson, mysql-python and edge dependencies
    If PROJECT_DEV dev_from_edge is called

    Example: fab install_dev
    """
    _default('local')
    local('sudo easy_install pip')
    local('sudo pip install virtualenvwrapper')
    local('sudo pip install virtualenv')
    if not os.path.exists(env.workondir):
        local("mkdir %s" % env.workondir)
    if not os.path.exists(os.path.join(env.workondir, env.virtualenv)):
        # Create virtual environment
        local("""
            export WORKON_HOME=%s &&
            source %s &&
            mkvirtualenv --no-site-packages %s
            """ % (env.workondir, env.ve_wrapper, env.virtualenv))
    local("git submodule update --init --recursive")
    _ve_local("""
             pip install simplejson &&
             pip install mysql-python &&
             pip install -r requirements/edge.pip""")
    if sett.PROJECT_TYPE == sett.PROJECT_DEV:
        if not dev_from_edge():
            return
    test()
Exemple #11
0
def update_dev(repository='upstream'):
    """Update development packages

    Depending on PROJECT_TYPE it runs pip updates dev3rdparty or edge
    If PROJECT_DeV it also git checkes master and pulls master from upstream

    Example: fab update_dev
    """
    _default('local')
    if not os.path.exists(env.workondir):
        if not confirm("No virtualenv provided. Should I install?"):
            return
        install_dev()
        return
    local("git status")
    if confirm("Should I checkout to and pull from master?"):
        local("git checkout master && git pull %s master" % repository)

    if sett.PROJECT_TYPE == sett.PROJECT_DEV:
        # update APPS
        _ve_local("pip install -r requirements/dev3rdparty.pip")
        for app in sett.APPS:
            with lcd(os.path.join(env.workondir, env.virtualenv, 'src', app)):
                print _cyan('Updating %s' % app)
                local("git status")
                if confirm("Should I checkout to and pull from master"):
                    local("git status")
                    local("git checkout master && git pull %s master" % repository)
    if sett.PROJECT_TYPE == sett.PROJECT_EDGE:
        # update APPS from master branch
        _ve_local("pip install -r requirements/edge.pip --upgrade")
Exemple #12
0
def makedocs(target='html'):
    """Compile development docs

    Example: fab makedocs:pdf
    """
    _default('local')
    with lcd(os.path.join(env.directory, 'docs')):
        _ve_local('make %s' % target)
Exemple #13
0
def syncdb():
    """Synchronise db and runs migrate

    Example: fab syncdb
    """
    _default('local')
    _ve_local("./manage.py syncdb")
    _ve_local("./manage.py migrate")
Exemple #14
0
def syncdb():
    """Synchronise db and runs migrate

    Example: fab syncdb
    """
    _default('local')
    _ve_local("./manage.py syncdb")
    _ve_local("./manage.py migrate")
Exemple #15
0
def makedocs(target='html'):
    """Compile development docs

    Example: fab makedocs:pdf
    """
    _default('local')
    with lcd(os.path.join(env.directory, 'docs')):
        _ve_local('make %s' % target)
Exemple #16
0
def runserver(port=8000):
    """Runs the development server

    :param: port (int) on which port should the runserver be run

    Example: fab runserver
             fab runserver:8091
    """
    _default('local')
    _ve_local('./manage.py runserver %d' % int(port))
Exemple #17
0
def runserver(port=8000):
    """Runs the development server

    :param: port (int) on which port should the runserver be run

    Example: fab runserver
             fab runserver:8091
    """
    _default('local')
    _ve_local('./manage.py runserver %d' % int(port))
Exemple #18
0
def migrate(app=None, attr=None):
    """Migrate database

    :param: app (string) limit migration to this app only
    """
    _default('local')
    app = app or ''
    command = './manage.py migrate %s' % app
    if attr:
        command += ' --%s' % attr
    _ve_local(command)
Exemple #19
0
def migrate(app=None, attr=None):
    """Migrate database

    :param: app (string) limit migration to this app only
    """
    _default('local')
    app = app or ''
    command = './manage.py migrate %s' % app
    if attr:
        attr = ' '.join(attr.split('+'))
        command += ' %s' % attr
    _ve_local(command)
Exemple #20
0
def harvest(apps=None):
    """Harvest thelettuce behaviour tests

    :param: apps (plus separated string) apps which should be harvested

    Example: fab harvest
             fab harvest:fiddle
    """
    _default('local')
    command = "./manage.py harvest"
    if apps:
        apps = apps.replace('+', ',')
        command += " --apps=%s" % apps
    _ve_local(command)
Exemple #21
0
def harvest(apps=None):
    """Harvest thelettuce behaviour tests

    :param: apps (plus separated string) apps which should be harvested

    Example: fab harvest
             fab harvest:fiddle
    """
    _default('local')
    command = "./manage.py harvest"
    if apps:
        apps = apps.replace('+', ',')
        command += " --apps=%s" % apps
    _ve_local(command)
Exemple #22
0
def schema(app, sattr='auto', mattr=None):
    """Change the database for the given app

    :param: app (string) which app was changed
    :param: attr (string) additional attributes, defaults to "auto". Other
            useful setting is ``initial``

    Example: fab schema:fiddle
    """
    _default('local')
    _ve_local('./manage.py schemamigration %s --%s' % (app, sattr))
    mcommand = './manage.py migrate %s' % app
    if mattr:
        mcommand += ' --%s' % mattr
    _ve_local(mcommand)
Exemple #23
0
def reset_migrations():
    """Remove migrations in all apps and create new ones
    """
    if sett.PROJECT_TYPE == sett.PROJECT_DEV:
        _default('local')
        local('rm -rf apps/*/migrations')
        for app in sett.APPS:
            with lcd(os.path.join(
                    env.workondir, env.virtualenv, 'src', app, app)):
                local('rm -rf migrations')
        _ve_local('./manage.py reset south')
        for app in sett.ALLAPPS:
            print _green('converting %s to south' % app)
            _ve_local('./manage.py convert_to_south %s' % app)
        migrate()
Exemple #24
0
def reset_migrations():
    """Remove migrations in all apps and create new ones
    """
    if sett.PROJECT_TYPE == sett.PROJECT_DEV:
        _default('local')
        local('rm -rf apps/*/migrations')
        for app in sett.APPS:
            with lcd(os.path.join(
                    env.workondir, env.virtualenv, 'src', app, app)):
                local('rm -rf migrations')
        _ve_local('./manage.py reset south')
        for app in sett.ALLAPPS:
            print _green('converting %s to south' % app)
            _ve_local('./manage.py convert_to_south %s' % app)
        migrate()
Exemple #25
0
def check(command=None, *args):
    """Run check.py on all Python files in all dev apps
    """
    _default('local')
    apps = args or sett.APPS
    if command:
        return _ve_local("check.py %s" % command)
    command = ["check.py *py apps/*py utils/*py apps/*/*py apps/*/tests/*py"]
    if sett.PROJECT_TYPE == sett.PROJECT_DEV:
        for app in apps:
            directory = os.path.join(
                    env.workondir, env.virtualenv, 'src', app, app)
            command.append("%s/*py" % directory)
            if os.path.isdir("%s/tests" % directory):
                command.append("%s/tests/*py" % directory)
    _ve_local(' '.join(command))
Exemple #26
0
def check(command=None, *args):
    """Run check.py on all Python files in all dev apps
    """
    _default('local')
    apps = args or sett.APPS
    if command:
        return _ve_local("check.py %s" % command)
    command = ["check.py *py apps/*py utils/*py apps/*/*py apps/*/tests/*py"]
    if sett.PROJECT_TYPE == sett.PROJECT_DEV:
        for app in apps:
            directory = os.path.join(
                    env.workondir, env.virtualenv, 'src', app, app)
            command.append("%s/*py" % directory)
            if os.path.isdir("%s/tests" % directory):
                command.append("%s/tests/*py" % directory)
    _ve_local(' '.join(command))
Exemple #27
0
def schemamigration(app, sattr='--auto', mattr=None):
    """Change the database for the given app

    :param: app (string) which app was changed
    :param: sattr (string) schemamigration additional attributes,
            defaults to "auto". other useful setting is ``--initial``
    :param: mattr (string) migrate additional attributes, defaults to None.

    Example: fab schema:appname
    Example: fab schema:appname,--initial
    Example: fab schema:appname,001+--fake
    """
    _default('local')
    sattr = ' '.join(sattr.split('+'))
    _ve_local('./manage.py schemamigration %s %s' % (app, sattr))
    mcommand = './manage.py migrate %s' % app
    if mattr:
        mattr = ' '.join(mattr.split('+'))
        mcommand += ' %s' % mattr
    _ve_local(mcommand)