rattail-demo/fabfile.py
2018-02-26 15:14:44 -06:00

62 lines
1.6 KiB
Python

# -*- coding: utf-8 -*-
"""
Fabric script for Rattail Demo
"""
from __future__ import unicode_literals, absolute_import
import shutil
from fabric.api import *
from rattail_fabric import cdvirtualenv, workon, python
env.roledefs = {
'production': ['lance@rattailproject.org'],
}
@task
def release():
"""
Release a new version of rattail-demo
"""
shutil.rmtree('rattail_demo.egg-info')
local('python setup.py sdist --formats=gztar upload')
@task
@roles('production')
def update_production(all='false'):
"""
Update production Rattail Demo server
"""
all = all.lower() == 'true'
if all:
with workon('demo'):
python.pip('pip', 'setuptools', 'wheel', 'ndg-httpsclient')
with cdvirtualenv('demo', 'src/rattail'):
sudo('git pull')
sudo('pip install --editable .')
with cdvirtualenv('demo', 'src/rattail-tempmon'):
sudo('git pull')
sudo('pip install --editable .')
with cdvirtualenv('demo', 'src/tailbone'):
sudo('git pull')
sudo('pip install --editable .')
with cdvirtualenv('demo', 'src/rattail-demo'):
sudo('git pull')
if all:
sudo('pip install --upgrade --editable .')
else:
sudo('pip install --editable .')
with cd('/srv/envs/demo'):
sudo('bin/alembic --config=app/rattail.conf upgrade heads', user='rattail')
with cd('/srv/envs/demo'):
sudo('bin/alembic --config=app/tempmon.conf upgrade heads', user='rattail')
sudo('service apache2 restart')
run('curl --output demo.html https://rattailproject.org/demo/')
run('rm demo.html')