Skip to content

Instantly share code, notes, and snippets.

@snahor
Created Sep 28, 2011
Embed
What would you like to do?
fabfile example
import os
from fabric.api import *
env.user = ''
env.hosts = ['']
env.password = ''
LOCAL_PATH = os.path.abspath('.')
SERVER_PATH = ''
def upload(prefix='', archive='src'):
archive = '%s.tar.bz2' % archive
server_base_path = SERVER_PATH
local(
'git archive --prefix=%(prefix)s/ HEAD | bzip2 > %(archive)s' % {
'prefix': prefix,
'archive': archive
}
)
put(archive, '%s/%s' % (server_base_path, 'src.tar.bz2'))
with cd(server_base_path):
run('tar xf %s' % archive)
run('rm -rf %s' % archive)
local('rm -rf %s' % archive)
def cp(name, dest=None):
if not dest:
dest = SERVER_PATH + "/%s" % name
put(LOCAL_PATH + "/%s" % name, dest)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment