def run_command(command): if command.startswith("dokku") and not command.startswith("dokkutils"): command = command.replace("dokku", '', 1) command = "%s %s" % (_env.dokku_command, command) res = _local(command) else: _local(command)
def host_print(msg, remote=True, leading_chars='\n'): ''' Print a raw message on the host. ''' cmd = 'echo "{0}{1}"'.format(leading_chars, msg) with hide('running'): if remote: _run(cmd) else: _local(cmd)
def update_envs(args=""): """ Setup all evironmnt varables example of usage: * fab staging update_envs_dokku """ envs_map = environment_keys(_env.environment_variables)[1] if envs_map: _local(_env.dokku_command + " config:set %s %s %s " % (_env.app_name_dokku, envs_map, args))
def local(*args, **kwargs): '''Override Fabric's local() to facilitate output logging.''' capture = kwargs.get('capture') kwargs['capture'] = True out = _local(*args, **kwargs) if capture: return out else: print out
def schema(initial=False): """Create a schema migration for any changes.""" if south: if initial: _local('django-admin.py schemamigration {} --initial'.format(APP_NAME)) else: _local('django-admin.py schemamigration {} --auto'.format(APP_NAME)) else: _local('django-admin.py makemigrations')
def schema(initial=False): """Create a schema migration for any changes.""" if south: if initial: _local('django-admin.py schemamigration {} --initial'.format( APP_NAME)) else: _local( 'django-admin.py schemamigration {} --auto'.format(APP_NAME)) else: _local('django-admin.py makemigrations')
def schema(): """Create a schema migration for any changes.""" _local('django-admin.py schemamigration currencies --auto')
def restart(): if _is_local(env.host): _local("sudo apachectl graceful") else: _sudo("apache2ctl graceful")
def ipdb_test(): """ Run the test suite with ipdbplugin enabled for errors and failures, stopping after first error or failure. """ _local('django-admin.py test --ipdb --ipdb-failures -sx')
def migrate(migration=''): """Update a testing database with south.""" _local('django-admin.py migrate %s %s' % (APP_NAME, migration))
def test_ipdb(test_case=''): """Run the test suite using ipdb to debug errors and failures.""" _local('django-admin.py test %s --ipdb --ipdb-failures' % test_case)
def syncdb(): """Create a database for testing in the shell or server.""" _local('django-admin.py syncdb')
def local(cmd): if hasattr(env,'capture_default'): _local(cmd, env.capture_default) else: _local(cmd)
def run(command, remote=True): ''' Run a command using fabric. ''' if remote: return _run(command) else: return _local(command)
def schema(initial=False): """Create a schema migration for any changes.""" if initial: _local('django-admin.py schemamigration %s --initial' % APP_NAME) else: _local('django-admin.py schemamigration %s --auto' % APP_NAME)
def pypi_upload(): """build and upload to PyPi""" _local('python setup.py sdist bdist_egg upload')
def test(test_case=""): """Run the test suite.""" _local("django-admin.py test %s" % test_case)
def test(): """Run the ratelimit test suite.""" _local('django-admin.py test')
def schema(): """Create a schema migration for any changes.""" _local('django-admin.py schemamigration waffle --auto')
def install_requirements(): """Installs the python requirements from lib.""" # Remove any existing versions. _local('rm -rf flask jinja2 werkzeug simplejson') # Extract the tar files. _local('tar xzf lib/Flask-0.8.tar.gz') _local('tar xf lib/Jinja2-2.6.tar') _local('tar xf lib/Werkzeug-0.8.1.tar') _local('tar xzf lib/simplejson-2.3.0.tar.gz') # Move the relevant files to the directory root. _local('mv Flask-0.8/flask .') _local('mv Jinja2-2.6/jinja2 .') _local('mv Werkzeug-0.8.1/werkzeug .') _local('mv simplejson-2.3.0/simplejson .') # Clean up after ourselves! _local('rm -rf Flask-0.8') _local('rm -rf Jinja2-2.6') _local('rm -rf Werkzeug-0.8.1') _local('rm -rf simplejson-2.3.0')
def test(test_case=''): """Run the test suite.""" _local('django-admin.py test {}'.format(test_case))
def test(): """Run the tests.""" _local('nosetests -s')
def makemigrations(): """Create a schema migration for any changes.""" _local('django-admin.py makemigrations {}'.format(APP_NAME))
def initialmigrate(migration=''): """Initial migrations""" _local('django-admin.py migrate'.format(APP_NAME, migration))
def test_coverage(): _local('coverage run --source=%s --omit=*/migrations/*.py ' '$(which django-admin.py) test' % APP_NAME)
def schema(): """Create a schema migration for any changes.""" _local('django-admin.py schemamigration djenie_siterelease --auto')
def migrate(): """Update a testing database with south.""" _local('django-admin.py migrate')
def jenkins_test(): """Run the test suite with Django Jenkins, cover, pep8 and pyflakes.""" _local('django-admin.py jenkins')
def schema(initial=False): """Create a schema migration for any changes.""" _local('django-admin.py makemigrations %s' % APP_NAME)
def manage(cmd): """Update a testing database""" _local('django-admin.py {}'.format(cmd))
def makemigrations(): """Django version > 1.6 - Create a schema migration for any changes.""" _local('django-admin.py makemigrations waffle')
def run(command, capture=False, shell=True, pty=True): if _is_local(env.host): return _local(command % (env), capture=capture) else: return _run(command % (env), shell=shell, pty=pty)
def syncdb(): """Create a database for testing in the shell or server.""" if south: _local('django-admin.py syncdb') else: _local('django-admin.py migrate')
def test(args=''): """Run the test suite.""" _local('django-admin.py test %s' % args)
def shell(): """Start a Django shell with the test settings.""" _local('django-admin.py shell')
def shell(): """Open a Django shell.""" _local('django-admin.py shell')
def serve(): """Start the Django dev server.""" _local('django-admin.py runserver')
def coverage(): """Run the tests with a coverage report.""" _local('nosetests -s --with-coverage --cover-package=commonware')
def test(test_case=''): """Run the test suite.""" _local('django-admin.py test %s' % test_case)
def cover(): """Run the test suite with coverage.""" _local('django-admin.py test --with-coverage --cover-package=' + APP_NAME)
def test(): """Run the Waffle test suite.""" _local('django-admin.py test')
def migrate(app_name='', migration=''): """Update a testing database""" _local('django-admin.py migrate {} {}'.format(APP_NAME, migration))
def test(): """Run the test suite.""" _local('django-admin.py test')
def makemigrations(): """Create a database for testing in the shell or server.""" _local('django-admin.py makemigrations urlographer')
def schema(): """Create a schema migration for any changes.""" _local('django-admin.py schemamigration %s --auto' % APP_NAME)
def podcast(cmd): _local('django-admin.py podcast %s' % cmd)
def test_coverage(): _local('coverage run --source=%s --omit=*/migrations/*.py $(which django-admin.py) test' % APP_NAME)