Skip to content

Instantly share code, notes, and snippets.

@tsuyukimakoto
Created September 18, 2013 15:51
Show Gist options
  • Save tsuyukimakoto/6611232 to your computer and use it in GitHub Desktop.
Save tsuyukimakoto/6611232 to your computer and use it in GitHub Desktop.
I don't believe public recipe. Therefor, this is good enough.
from fabric.api import sudo, run, prefix
def _install_apt_if_not_installed(pkg_name):
if not pkg_name in run('''dpkg -l | grep '{0}' | cat '''.format(pkg_name)):
sudo('apt-get install -y {0}'.format(pkg_name))
def _install_pip_if_not_installed(venv_dir):
def _func(libname):
with prefix('source {0}/bin/activate'.format(venv_dir)):
if not libname.lower() in run('''pip freeze | grep -i '{0}' | cat '''.format(libname)).lower():
run('pip install {0}'.format(libname))
return _func
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment