Skip to content

Instantly share code, notes, and snippets.

@snahor
Created September 28, 2011 22:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save snahor/1249404 to your computer and use it in GitHub Desktop.
Save snahor/1249404 to your computer and use it in GitHub Desktop.
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