Return standard output of executing cmd in a shell. Accepts the same arguments as os.system(). Parameters ---------- cmd : str or list A command to be executed in the system shell. Returns ------- stdout : str
(cmd: str)
| 140 | |
| 141 | |
| 142 | def getoutput(cmd: str) -> str: |
| 143 | """Return standard output of executing cmd in a shell. |
| 144 | |
| 145 | Accepts the same arguments as os.system(). |
| 146 | |
| 147 | Parameters |
| 148 | ---------- |
| 149 | cmd : str or list |
| 150 | A command to be executed in the system shell. |
| 151 | |
| 152 | Returns |
| 153 | ------- |
| 154 | stdout : str |
| 155 | """ |
| 156 | |
| 157 | with AvoidUNCPath() as path: |
| 158 | if path is not None: |
| 159 | cmd = '"pushd %s &&"%s' % (path, cmd) |
| 160 | out = process_handler(cmd, lambda p: p.communicate()[0], STDOUT) |
| 161 | |
| 162 | if out is None: |
| 163 | out = b"" |
| 164 | return py3compat.decode(out) |
| 165 | |
| 166 | |
| 167 | try: |
nothing calls this directly
no test coverage detected
searching dependent graphs…