Exemplo n.º 1
0
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()
Exemplo n.º 2
0
 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)
Exemplo n.º 3
0
 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)
Exemplo n.º 4
0
 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)
Exemplo n.º 5
0
 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)
Exemplo n.º 6
0
 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)
Exemplo n.º 7
0
 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)
Exemplo n.º 8
0
 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))
Exemplo n.º 9
0
 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))
Exemplo n.º 10
0
 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")
Exemplo n.º 11
0
 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')
Exemplo n.º 12
0
 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')
Exemplo n.º 13
0
 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))
Exemplo n.º 14
0
 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))
Exemplo n.º 15
0
 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))
Exemplo n.º 16
0
 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)
Exemplo n.º 17
0
 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)
Exemplo n.º 18
0
 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)
Exemplo n.º 19
0
 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
Exemplo n.º 20
0
 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
Exemplo n.º 21
0
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
Exemplo n.º 22
0
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
Exemplo n.º 23
0
 def remote_host(self):
     with nested(self.remote_tunnel(), shell_env(**self.env)):
         yield
Exemplo n.º 24
0
 def remote_host(self):
     with nested(self.remote_tunnel(), shell_env(**self.env)):
         yield