def test_command_with_ssh_config(self): command = backend.build_command(self.project, self.deployment, {}) fabfile_path, active_loc = backend.get_fabfile_path(self.deployment.stage.project) self.assertEqual( command, 'fab update_sandbox_site --set "KEY=VALUE" ' '--abort-on-prompts -i {} '.format(self.ssh_config.private_key_file._get_path()) + '-u {} --fabfile={}'.format(self.ssh_config.remote_user, fabfile_path) )
def test_command_with_ssh_config(self): command = backend.build_command(self.project, self.deployment, {}) fabfile_path, active_loc = backend.get_fabfile_path( self.deployment.stage.project) self.assertEqual( command, 'fab update_sandbox_site --set "KEY=VALUE" ' '--abort-on-prompts -i {} '.format( self.ssh_config.private_key_file._get_path()) + '-u {} --fabfile={}'.format(self.ssh_config.remote_user, fabfile_path))
def output_stream_generator(self, *args, **kwargs): from fabric_bolt.task_runners import backend self.process = subprocess.Popen( backend.build_command(self.deployment.stage.project, self.deployment, self.request.session, False), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, stdin=subprocess.PIPE, shell=True, executable=getattr(settings, 'SHELL', '/bin/sh'), close_fds=True, ) fd = self.process.stdout.fileno() fl = fcntl.fcntl(fd, fcntl.F_GETFL) fcntl.fcntl(fd, fcntl.F_SETFL, fl | os.O_NONBLOCK) all_output = '' while True: try: nextline = self.process.stdout.read() except IOError as e: print e nextline = '' if nextline == '' and self.process.poll() != None: break all_output += nextline if nextline: self.broadcast_event('output', { 'status': 'pending', 'lines': str(nextline) }) time.sleep(0.00001) sys.stdout.flush() self.deployment.status = self.deployment.SUCCESS if self.process.returncode == 0 else self.deployment.FAILED self.deployment.output = all_output self.deployment.save() self.broadcast_event('output', {'status': self.deployment.status}) self.disconnect()
def output_stream_generator(self, *args, **kwargs): from fabric_bolt.task_runners import backend self.process = subprocess.Popen( backend.build_command(self.deployment.stage.project, self.deployment, self.request.session, False), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, stdin=subprocess.PIPE, shell=True, executable=getattr(settings, 'SHELL', '/bin/sh'), close_fds=True, ) fd = self.process.stdout.fileno() fl = fcntl.fcntl(fd, fcntl.F_GETFL) fcntl.fcntl(fd, fcntl.F_SETFL, fl | os.O_NONBLOCK) all_output = '' while True: try: nextline = self.process.stdout.read() except IOError as e: print e nextline = '' if nextline == '' and self.process.poll() != None: break all_output += nextline if nextline: self.broadcast_event('output', {'status': 'pending', 'lines': str(nextline)}) time.sleep(0.00001) sys.stdout.flush() self.deployment.status = self.deployment.SUCCESS if self.process.returncode == 0 else self.deployment.FAILED self.deployment.output = all_output self.deployment.save() self.broadcast_event('output', {'status': self.deployment.status}) self.disconnect()