MCPcopy
hub / github.com/microsoft/qlib / execute

Function execute

examples/run_all_model.py:79–96  ·  view source on GitHub ↗
(cmd, wait_when_err=False, raise_err=True)

Source from the content-addressed store, hash-verified

77
78# function to execute the cmd
79def execute(cmd, wait_when_err=False, raise_err=True):
80 print("Running CMD:", cmd)
81 with subprocess.Popen(cmd, stdout=subprocess.PIPE, bufsize=1, universal_newlines=True, shell=True) as p:
82 for line in p.stdout:
83 sys.stdout.write(line.split("\b")[0])
84 if "\b" in line:
85 sys.stdout.flush()
86 time.sleep(0.1)
87 sys.stdout.write("\b" * 10 + "\b".join(line.split("\b")[1:-1]))
88
89 if p.returncode != 0:
90 if wait_when_err:
91 input("Press Enter to Continue")
92 if raise_err:
93 raise RuntimeError(f"Error when executing command: {cmd}")
94 return p.stderr
95 else:
96 return None
97
98
99# function to get all the folders benchmark folder

Callers 2

create_envFunction · 0.85
runMethod · 0.85

Calls 2

sleepMethod · 0.80
writeMethod · 0.45

Tested by

no test coverage detected