Executes a command and waits for it to finish, raises an exception if the return status is not zero. The command output is returned. 'args' and 'kwargs' use the same format as subprocess.Popen().
(args, **kwargs)
| 110 | |
| 111 | |
| 112 | def exec_cmd(args, **kwargs): |
| 113 | '''Executes a command and waits for it to finish, raises an exception if the return |
| 114 | status is not zero. The command output is returned. |
| 115 | |
| 116 | 'args' and 'kwargs' use the same format as subprocess.Popen(). |
| 117 | ''' |
| 118 | process = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, |
| 119 | universal_newlines=True, **kwargs) |
| 120 | output = process.communicate()[0] |
| 121 | if process.returncode != 0: |
| 122 | raise Exception("Command returned non-zero status\nCommand: %s\nOutput: %s" |
| 123 | % (args, output)) |
| 124 | return output |
| 125 | |
| 126 | |
| 127 | def select_cc(): |
no test coverage detected