def deploy(): with nested(cd(env.sitedir), prefix(env.venv_activate)): run('git fetch') run('git reset --hard HEAD') run('git pull origin master') run('pip install --upgrade -r requirements.txt') restart_app()
def test_cd_should_not_apply_to_absolute_get(self): """ get() should not prepend env.cwd to absolute remote paths """ local = self.path('test.txt') with nested(cd('/tmp'), hide('everything')): get('/test.txt', local) assert os.path.exists(local)
def test_cd_should_not_apply_to_absolute_get(self): """ get() should not prepend env.cwd to absolute remote paths """ local = self.path("test.txt") with nested(cd("/tmp"), hide("everything")): get("/test.txt", local) assert os.path.exists(local)
def test_cd_should_apply_to_get(self): """ get() should honor env.cwd for relative remote paths """ local = self.path('test.txt') with nested(cd('/tmp'), hide('everything')): get('test.txt', local) assert os.path.exists(local)
def test_cd_should_apply_to_get(self): """ get() should honor env.cwd for relative remote paths """ local = self.path("test.txt") with nested(cd("/tmp"), hide("everything")): get("test.txt", local) assert os.path.exists(local)
def test_lcd_should_apply_to_get(self): """ lcd() should apply to get()'s local_path argument """ d = self.path('subdir') f = 'file.txt' with nested(lcd(d), hide('everything')): get(f, f) assert self.exists_locally(os.path.join(d, f))
def test_cd_should_not_apply_to_absolute_put(self): """ put() should not prepend env.cwd to absolute remote paths """ local = self.path("test.txt") with open(local, "w") as fd: fd.write("test") with nested(cd("/tmp"), hide("everything")): put(local, "/test.txt") assert not self.exists_remotely("/tmp/test.txt") assert self.exists_remotely("/test.txt")
def test_cd_should_not_apply_to_absolute_put(self): """ put() should not prepend env.cwd to absolute remote paths """ local = self.path('test.txt') with open(local, 'w') as fd: fd.write('test') with nested(cd('/tmp'), hide('everything')): put(local, '/test.txt') assert not self.exists_remotely('/tmp/test.txt') assert self.exists_remotely('/test.txt')
def test_cd_should_apply_to_put(self): """ put() should honor env.cwd for relative remote paths """ f = "test.txt" d = "/empty_folder" local = self.path(f) with open(local, "w") as fd: fd.write("test") with nested(cd(d), hide("everything")): put(local, f) assert self.exists_remotely("%s/%s" % (d, f))
def test_cd_should_apply_to_put(self): """ put() should honor env.cwd for relative remote paths """ f = 'test.txt' d = '/empty_folder' local = self.path(f) with open(local, 'w') as fd: fd.write('test') with nested(cd(d), hide('everything')): put(local, f) assert self.exists_remotely('%s/%s' % (d, f))
def test_lcd_should_apply_to_put(self): """ lcd() should apply to put()'s local_path argument """ f = 'lcd_put_test.txt' d = 'subdir' local = self.path(d, f) os.makedirs(os.path.dirname(local)) with open(local, 'w') as fd: fd.write("contents") with nested(lcd(self.path(d)), hide('everything')): put(f, '/') assert self.exists_remotely('/%s' % f)
def test_lcd_should_apply_to_put(self): """ lcd() should apply to put()'s local_path argument """ f = "lcd_put_test.txt" d = "subdir" local = self.path(d, f) os.makedirs(os.path.dirname(local)) with open(local, "w") as fd: fd.write("contents") with nested(lcd(self.path(d)), hide("everything")): put(f, "/") assert self.exists_remotely("/%s" % f)
def remote_tunnel(self): devnull = open(os.devnull, 'w') stack = self.ssh_tunnel and [ contextlib.closing(devnull), # forward sys.stdout to os.devnull to prevent # printing debug messages by fab.remote_tunnel utils.patch(sys, 'stdout', devnull), fab.remote_tunnel( remote_bind_address=self.ssh_tunnel.bind_address, remote_port=self.ssh_tunnel.port, local_host=self.ssh_tunnel.host, local_port=self.ssh_tunnel.host_port, ), ] or [] with nested(*stack): yield
def test_local_output_and_capture(): for capture in (True, False): for stdout in (True, False): for stderr in (True, False): hides, shows = ["running"], [] if stdout: hides.append("stdout") else: shows.append("stdout") if stderr: hides.append("stderr") else: shows.append("stderr") with nested(hide(*hides), show(*shows)): d = "local(): capture: %r, stdout: %r, stderr: %r" % (capture, stdout, stderr) local.description = d yield local, "echo 'foo' >/dev/null", capture del local.description
def test_local_output_and_capture(): for capture in (True, False): for stdout in (True, False): for stderr in (True, False): hides, shows = ['running'], [] if stdout: hides.append('stdout') else: shows.append('stdout') if stderr: hides.append('stderr') else: shows.append('stderr') with nested(hide(*hides), show(*shows)): d = "local(): capture: %r, stdout: %r, stderr: %r" % ( capture, stdout, stderr) local.description = d yield local, "echo 'foo' >/dev/null", capture del local.description
def remote_host(self): with nested(self.remote_tunnel(), shell_env(**self.env)): yield