from fabric.decorators import task

from refabric.api import run, info
from refabric.context_managers import sudo

from . import debian

__all__ = ['setup']


@task
def setup():
    """
    Install python develop tools
    """
    install()


def install():
    with sudo():
        info('Install python dependencies')
        debian.apt_get('install', 'python-dev', 'python-setuptools')
        run('easy_install -0 pip')


def pip(command, *options):
    info('Running pip {}', command)
    run('pip {} {} -v --log=/tmp/pip.log --log-file=/tmp/pip.log'.format(command, ' '.join(options)))

from fabric.decorators import task

from refabric.api import run, info
from refabric.context_managers import sudo

from . import debian

__all__ = ['setup']


pip_log_file = '/tmp/pip.log'


@task
def setup():
    """
    Install python develop tools
    """
    install()


def install():
    with sudo():
        info('Install python dependencies')
        debian.apt_get('install', 'python-dev', 'python-setuptools')
        run('easy_install -0 pip')
        run('touch {}'.format(pip_log_file))
        debian.chmod(pip_log_file, mode=777)


def pip(command, *options):
    info('Running pip {}', command)
    run('pip {0} {1} -v --log={2} --log-file={2}'.format(command, ' '.join(options), pip_log_file))

Make pip log world writable
Make pip log world writable
  from fabric.decorators import task
  
  from refabric.api import run, info
  from refabric.context_managers import sudo
  
  from . import debian
  
  __all__ = ['setup']
+ 
+ 
+ pip_log_file = '/tmp/pip.log'
  
  
  @task
  def setup():
      """
      Install python develop tools
      """
      install()
  
  
  def install():
      with sudo():
          info('Install python dependencies')
          debian.apt_get('install', 'python-dev', 'python-setuptools')
          run('easy_install -0 pip')
+         run('touch {}'.format(pip_log_file))
+         debian.chmod(pip_log_file, mode=777)
  
  
  def pip(command, *options):
      info('Running pip {}', command)
-     run('pip {} {} -v --log=/tmp/pip.log --log-file=/tmp/pip.log'.format(command, ' '.join(options)))
+     run('pip {0} {1} -v --log={2} --log-file={2}'.format(command, ' '.join(options), pip_log_file))
  
Make pip log world writable
## Code Before:
from fabric.decorators import task

from refabric.api import run, info
from refabric.context_managers import sudo

from . import debian

__all__ = ['setup']


@task
def setup():
    """
    Install python develop tools
    """
    install()


def install():
    with sudo():
        info('Install python dependencies')
        debian.apt_get('install', 'python-dev', 'python-setuptools')
        run('easy_install -0 pip')


def pip(command, *options):
    info('Running pip {}', command)
    run('pip {} {} -v --log=/tmp/pip.log --log-file=/tmp/pip.log'.format(command, ' '.join(options)))

## Instruction:
Make pip log world writable
## Code After:
from fabric.decorators import task

from refabric.api import run, info
from refabric.context_managers import sudo

from . import debian

__all__ = ['setup']


pip_log_file = '/tmp/pip.log'


@task
def setup():
    """
    Install python develop tools
    """
    install()


def install():
    with sudo():
        info('Install python dependencies')
        debian.apt_get('install', 'python-dev', 'python-setuptools')
        run('easy_install -0 pip')
        run('touch {}'.format(pip_log_file))
        debian.chmod(pip_log_file, mode=777)


def pip(command, *options):
    info('Running pip {}', command)
    run('pip {0} {1} -v --log={2} --log-file={2}'.format(command, ' '.join(options), pip_log_file))
