(input_api,
output_api,
script_path,
script_arguments=None,
message=None)
| 47 | |
| 48 | |
| 49 | def _ExecuteSubProcess(input_api, |
| 50 | output_api, |
| 51 | script_path, |
| 52 | script_arguments=None, |
| 53 | message=None): |
| 54 | if isinstance(script_path, six.string_types): |
| 55 | script_path = [input_api.python3_executable, script_path] |
| 56 | |
| 57 | start_time = time.time() |
| 58 | process = input_api.subprocess.Popen(script_path + |
| 59 | (script_arguments or []), |
| 60 | stdout=input_api.subprocess.PIPE, |
| 61 | stderr=input_api.subprocess.STDOUT) |
| 62 | out, _ = process.communicate() |
| 63 | end_time = time.time() |
| 64 | time_difference = end_time - start_time |
| 65 | return [ |
| 66 | output_api.PresubmitError( |
| 67 | "%s (%.1fs): %s" % |
| 68 | (message if message is not None else script_path, time_difference, |
| 69 | out.decode('utf-8').strip())) |
| 70 | ] if process.returncode != 0 else [] |
| 71 | |
| 72 | |
| 73 | def _IsEnvCog(input_api): |
no test coverage detected