MCPcopy
hub / github.com/aws/aws-cli / run

Function run

scripts/utils.py:17–38  ·  view source on GitHub ↗
(cmd, cwd=None, env=None, echo=True)

Source from the content-addressed store, hash-verified

15
16
17def run(cmd, cwd=None, env=None, echo=True):
18 if echo:
19 sys.stdout.write("Running cmd: %s\n" % cmd)
20 kwargs = {
21 'shell': True,
22 'stdout': subprocess.PIPE,
23 'stderr': subprocess.PIPE,
24 }
25 if isinstance(cmd, list):
26 kwargs['shell'] = False
27 if cwd is not None:
28 kwargs['cwd'] = cwd
29 if env is not None:
30 kwargs['env'] = env
31 p = subprocess.Popen(cmd, **kwargs)
32 stdout, stderr = p.communicate()
33 output = stdout.decode('utf-8') + stderr.decode('utf-8')
34 if p.returncode != 0:
35 raise BadRCError(
36 "Bad rc (%s) for cmd '%s': %s" % (p.returncode, cmd, output)
37 )
38 return output
39
40
41def extract_zip(zipfile_name, target_dir):

Callers 3

install_local_packageFunction · 0.90
pip_install_packagesFunction · 0.90

Calls 4

BadRCErrorClass · 0.85
decodeMethod · 0.80
writeMethod · 0.45
communicateMethod · 0.45

Tested by 1