Executes a command for the local bash shell and return stdout as a string. Raise CalledProcessError in case of non-zero return code. Args: cmd: command as a string Return: STDOUT
(cmd)
| 25 | |
| 26 | |
| 27 | def exec_local_command(cmd): |
| 28 | """ |
| 29 | Executes a command for the local bash shell and return stdout as a string. |
| 30 | |
| 31 | Raise CalledProcessError in case of non-zero return code. |
| 32 | |
| 33 | Args: |
| 34 | cmd: command as a string |
| 35 | |
| 36 | Return: |
| 37 | STDOUT |
| 38 | """ |
| 39 | proc = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE, |
| 40 | universal_newlines=True) |
| 41 | output, error = proc.communicate() |
| 42 | retcode = proc.poll() |
| 43 | if retcode: |
| 44 | LOG.error("{0} returned status {1}: {2}".format(cmd, retcode, error)) |
| 45 | raise subprocess.CalledProcessError() |
| 46 | else: |
| 47 | return output |
| 48 | |
| 49 | |
| 50 | def find_all_files(fname_pattern, base_dir=os.getenv('IMPALA_HOME', '.')): |
no test coverage detected