-
Notifications
You must be signed in to change notification settings - Fork 0
/
fabfile.py
31 lines (24 loc) · 937 Bytes
/
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
from __future__ import with_statement
import os
from fabric.api import env, put, run, cd
from fabric.contrib.project import rsync_project, upload_project
env.user = 'user'
env.hosts = ['192.168.2.15']
TARGET_WORKSPACE = '/home/user/CodeVault/'
TARGET_PROJECT = os.path.join(TARGET_WORKSPACE, 'maebird')
TARGET_MAIN_FILE = 'main.py'
TARGET = os.path.join(TARGET_WORKSPACE, TARGET_PROJECT, TARGET_MAIN_FILE)
EXCLUDES = ['*.pyc', '*.pyo']
def deploy_n_run(remote='sync'):
if remote == 'sync':
sync()
elif remote == 'upload':
upload()
run_remote(TARGET_PROJECT, TARGET_MAIN_FILE)
def sync(remotedir=TARGET_WORKSPACE, localdir=None):
rsync_project(remotedir, localdir, exclude=EXCLUDES)
def run_remote(project, mainfile, cmd='python'):
with cd(project):
run('%s %s' % (cmd, mainfile))
def upload(localdir=None, remotedir=TARGET_WORKSPACE):
upload_project(localdir, remotedir)