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