MCPcopy Create free account
hub / github.com/ProjectMitosisOS/mitosis-core / execute

Method execute

exp_scripts/bootstrap.py:335–359  ·  view source on GitHub ↗
(self, cmd, host, pty=True, dir="", timeout=None, output=True, background=False)

Source from the content-addressed store, hash-verified

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)

Callers

nothing calls this directly

Calls 2

pre_executeMethod · 0.95
closeMethod · 0.45

Tested by

no test coverage detected