MCPcopy Create free account
hub / github.com/ccxt/ccxt / run_command

Function run_command

python/ccxt/static_dependencies/ecdsa/_version.py:70–104  ·  view source on GitHub ↗

Call the given command(s).

(commands, args, cwd=None, verbose=False, hide_stderr=False,
                env=None)

Source from the content-addressed store, hash-verified

68
69
70def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False,
71 env=None):
72 """Call the given command(s)."""
73 assert isinstance(commands, list)
74 p = None
75 for c in commands:
76 try:
77 dispcmd = str([c] + args)
78 # remember shell=False, so use git.cmd on windows, not just git
79 p = subprocess.Popen([c] + args, cwd=cwd, env=env,
80 stdout=subprocess.PIPE,
81 stderr=(subprocess.PIPE if hide_stderr
82 else None))
83 break
84 except EnvironmentError:
85 e = sys.exc_info()[1]
86 if e.errno == errno.ENOENT:
87 continue
88 if verbose:
89 print("unable to run %s" % dispcmd)
90 print(e)
91 return None, None
92 else:
93 if verbose:
94 print("unable to find command, tried %s" % (commands,))
95 return None, None
96 stdout = p.communicate()[0].strip()
97 if sys.version_info[0] >= 3:
98 stdout = stdout.decode()
99 if p.returncode != 0:
100 if verbose:
101 print("unable to run %s (error)" % dispcmd)
102 print("stdout was %s" % stdout)
103 return None, p.returncode
104 return stdout, p.returncode
105
106
107def versions_from_parentdir(parentdir_prefix, root, verbose):

Callers 1

git_pieces_from_vcsFunction · 0.70

Calls 2

stripMethod · 0.45
decodeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…