netneurotools.utils.run
- netneurotools.utils.run(cmd, env=None, return_proc=False, quiet=False)[source]
Run cmd via shell subprocess with provided environment env.
- Parameters:
cmd (str) – Command to be run as single string
env (dict, optional) – If provided, dictionary of key-value pairs to be added to base environment when running cmd. Default: None
return_proc (bool, optional) – Whether to return CompletedProcess object. Default: false
quiet (bool, optional) – Whether to suppress stdout/stderr from subprocess. Default: False
- Returns:
proc – Process output
- Return type:
- Raises:
subprocess.CalledProcessError – If subprocess does not exit cleanly
Examples
>>> from netneurotools import utils >>> p = utils.run('echo "hello world"', return_proc=True, quiet=True) >>> p.returncode 0 >>> p.stdout 'hello world\n'