(self, cmd, host, pty=True, dir="", timeout=None, output=True, background=False)
| 333 | return self.pre_execute(cmd, host, pty, dir, timeout, retry_count - 1) |
| 334 | |
| 335 | def execute(self, cmd, host, pty=True, dir="", timeout=None, output=True, background=False): |
| 336 | ret = [True, ""] |
| 337 | p, stdout = self.pre_execute(cmd, host, pty, dir, timeout, background=background) |
| 338 | if p and (stdout and output) and (not background): |
| 339 | try: |
| 340 | while not stdout.channel.closed: |
| 341 | try: |
| 342 | for line in iter(lambda: stdout.readline(2048), ""): |
| 343 | if pty and (len(line) > 0): ## ignore null lines |
| 344 | print((("[%s]: " % host) + line)) |
| 345 | else: |
| 346 | ret[1] += (line + "\n") |
| 347 | except UnicodeDecodeError as e: |
| 348 | continue |
| 349 | except Exception as e: |
| 350 | break |
| 351 | except Exception as e: |
| 352 | print("[%s] execute with execption: %s" % (host, e)) |
| 353 | if p and (not background): |
| 354 | p.close() |
| 355 | # ret[1] = stdout |
| 356 | else: |
| 357 | ret[0] = False |
| 358 | ret[1] = stdout |
| 359 | return ret[0], ret[1] |
| 360 | |
| 361 | |
| 362 | # cr.envs.set(base_env) |
nothing calls this directly
no test coverage detected