MCPcopy Create free account
hub / github.com/microsoft/debugpy / run_command

Function run_command

versioneer.py:383–423  ·  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

381
382
383def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False,
384 env=None):
385 """Call the given command(s)."""
386 assert isinstance(commands, list)
387 process = None
388
389 popen_kwargs = {}
390 if sys.platform == "win32":
391 # This hides the console window if pythonw.exe is used
392 startupinfo = subprocess.STARTUPINFO()
393 startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
394 popen_kwargs["startupinfo"] = startupinfo
395
396 for command in commands:
397 try:
398 dispcmd = str([command] + args)
399 # remember shell=False, so use git.cmd on windows, not just git
400 process = subprocess.Popen([command] + args, cwd=cwd, env=env,
401 stdout=subprocess.PIPE,
402 stderr=(subprocess.PIPE if hide_stderr
403 else None), **popen_kwargs)
404 break
405 except OSError:
406 e = sys.exc_info()[1]
407 if e.errno == errno.ENOENT:
408 continue
409 if verbose:
410 print("unable to run %s" % dispcmd)
411 print(e)
412 return None, None
413 else:
414 if verbose:
415 print("unable to find command, tried %s" % (commands,))
416 return None, None
417 stdout = process.communicate()[0].strip().decode()
418 if process.returncode != 0:
419 if verbose:
420 print("unable to run %s (error)" % dispcmd)
421 print("stdout was %s" % stdout)
422 return None, process.returncode
423 return stdout, process.returncode
424
425
426LONG_VERSION_PY['git'] = r'''

Callers 1

do_vcs_installFunction · 0.70

Calls 1

decodeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…