def execute(self, cmd): logger.info("Execute on %s: %s", self.host, cmd) with self.connect() as client: _, stdout, stderr = client.exec_command(cmd) output = stdout.read() errors = stderr.read() err_code = stdout.channel.recv_exit_status() return output, errors, err_code
def execute(self, cmd): logger.info("Execute on %s: %s", self.host, cmd) with self.connect() as client: _, stdout, stderr = client.exec_command(cmd) output = stdout.read() errors = stderr.read() err_code = stdout.channel.recv_exit_status() return output, errors, err_code
def exec_command(client, cmd: str) -> str: """Выполняет команду на ssh-сервере""" stdin, stdout, stderr = client.exec_command(cmd) data = stdout.read() + stderr.read() return data.decode('utf-8')