/
fabfile.py
63 lines (46 loc) · 1.64 KB
/
fabfile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
from fabric.api import cd, sudo, put, env, hosts
from fabric.context_managers import prefix, shell_env
from contextlib import contextmanager
import os
env.pythonpath = '/Users/joseph/.virtualenvs/alfred/lib/python2.7/site-packages/'
env.hosts = ['hal', 'pi@raspbmc']
@contextmanager
def source_venv():
with prefix('source ' + '/Users/joseph/.virtualenvs/alfred/bin/activate'):
yield
def clean():
local('find . -name "*.pyc" -delete')
local('rm -rf alfred.log dist build *.egg-info')
# TODO: change to package
def install():
run('test -e alfred || git clone https://github.com/eagleamon/alfred.git')
with(cd('alfred')):
sudo('python setup.py develop')
sudo('pip install -r requirements.txt')
def build():
clean()
local('python setup.py sdist')
def deps():
print "Todo"
#@hosts('hal', 'pi@raspbmc')
def publish():
f = os.listdir('dist')[-1]
put('dist/%s' % f, '/tmp/%s' % f)
sudo('pip install --no-deps -U /tmp/%s' % f)
sudo('touch /var/log/alfred.log')
sudo('restart alfred')
sudo('uname -a')
# @hosts('localhost')
# def run(env='dev'):
# if env == 'dev':
# client = "--client-path ./client/app"
# cmd = 'python -m alfred -d --db-host hal %s'
# # local(cmd % client)
# os.system(cmd % client) # Otherwise when quitting, background process may stay alive
@hosts('localhost')
def dev():
os.system('nodemon -e ".py" -x "python3 -m alfred -d --config-file config.json"')
def test(toTest=''):
" Chose tests like -> fab test:tests/items.py "
with source_venv(), shell_env(PYTHONPATH=env.pythonpath):
local('nosetests %s --with-watch -v' % toTest)