def deploy(): """Deploy the project: fab [environment] deploy""" push() with cd(env.path): run('git pull {push_remote} {push_branch}'.format(**env)) with _venv(env.virtualenv_path): run('pip install -Ur {requirements}'.format(**env)) migrate() with _venv(env.virtualenv_path): run('./manage.py collectstatic --noinput {settings}'.format(**env)) # run('./manage.py compilemessages %(settings)s'.format(**env)) restart()
def run_command(command): """ Run a management command: fab [environment] run_command my_command Example: fab production run_command:'./manage.py check' """ with cd(env.path): with _venv(env.virtualenv_path): run('{command} {settings}'.format(command=command, settings=env.settings))
def show_crontab(): """Show the current crontab entries: fab [environment] show_crontab""" with _venv(env.virtualenv_path): run('{path}/manage.py crontab show {settings}'.format(**env))
def create_superuser(): """Create a django superuser: fab [environment] create_superuser""" with _venv(env.virtualenv_path): run('{path}/manage.py createsuperuser {settings}'.format(**env))
def shell(): """Open a shell: fab [environment] shell""" with _venv(env.virtualenv_path): run('{path}/manage.py shell_plus {settings}'.format(**env))
def disable_debug(): """Disable django debug mode: fab [environment] disable_debug""" with _venv(env.virtualenv_path): run("sed -i -e 's/DJANGO_DEBUG=True/DJANGO_DEBUG=False/' {path}/.env". format(**env)) restart()
def migrate(): """Migrate the database: fab [environment] migrate""" with _venv(env.virtualenv_path): run("{path}/manage.py migrate {settings}".format(**env))
def remove_crontab(): """Remove the crontab entries: fab [environment] remove_crontab""" with _venv(env.virtualenv_path): run('{path}/manage.py crontab remove {settings}'.format(**env))
def add_crontab(): """Update the crontab entries: fab [environment] add_crontab""" with _venv(env.virtualenv_path): run('{path}/manage.py crontab add {settings}'.format(**env))
def disable_debug(): """Disable django debug mode: fab [environment] disable_debug""" with _venv(env.virtualenv_path): run("sed -i -e 's/DJANGO_DEBUG=True/DJANGO_DEBUG=False/' {path}/.env".format(**env)) restart()