Skip to content

Instantly share code, notes, and snippets.

@binarymatt
binarymatt / manage_fabric.py
Created October 31, 2011 03:03 — forked from bradmontgomery/manage_fabric.py
A stab at running remote Django management commands via fabric.
def manage(management_command, args=[]):
with cd(REMOTE_PROJECT_DIR):
with prefix('source /path/to/virtualenv/bin/activate'):
run('python manage.py %s %s' % (management_command, ' '.join(args))
from fabric.api import local,run, sudo, cd, prefix, env, put, settings, show
env.hosts = ['33.33.33.10']
env.user = 'vagrant'
def first():
run('ifconfig eth1')
def second():
with settings(
#!/usr/bin/env python
from __future__ import with_statement
import os
import re
import shutil
import subprocess
import sys
import tempfile
def sshagent_run(cmd):
"""
Helper function.
Runs a command with SSH agent forwarding enabled.
Note:: Fabric (and paramiko) can't forward your SSH agent.
This helper uses your system's ssh to do so.
"""
host = api.env.host_string
result = api.local('ssh -A %s "%s"' % (host, cmd))
print result
def test():
print 'this is a test'