MCPcopy Create free account
hub / github.com/PaddlePaddle/FastDeploy / run

Function run

fastdeploy/collect_env.py:114–137  ·  view source on GitHub ↗

Return (return-code, stdout, stderr).

(command)

Source from the content-addressed store, hash-verified

112
113
114def run(command):
115 """Return (return-code, stdout, stderr)."""
116 shell = True if type(command) is str else False
117 try:
118 p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=shell)
119 raw_output, raw_err = p.communicate()
120 rc = p.returncode
121 if get_platform() == "win32":
122 enc = "oem"
123 else:
124 enc = locale.getpreferredencoding()
125 output = raw_output.decode(enc)
126 if command == "nvidia-smi topo -m":
127 # don't remove the leading whitespace of `nvidia-smi topo -m`
128 # because they are meaningful
129 output = output.rstrip()
130 else:
131 output = output.strip()
132 err = raw_err.decode(enc)
133 return rc, output, err.strip()
134
135 except FileNotFoundError:
136 cmd_str = command if isinstance(command, str) else command[0]
137 return 127, "", f"Command not found: {cmd_str}"
138
139
140def run_and_read_all(run_lambda, command):

Callers

nothing calls this directly

Calls 2

get_platformFunction · 0.85
decodeMethod · 0.45

Tested by

no test coverage detected