diff options
author | Leo Neat <leosneat@gmail.com> | 2020-01-31 10:19:12 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-31 10:19:12 -0800 |
commit | f2588ea5a8687dffe6f86eba837d7348876d5aaf (patch) | |
tree | 851d87e30eac934984d7bf741776b2c568d521f4 /infra/build_specified_commit.py | |
parent | 7751ab5a87907ec971beace9d4d139aaab6287cf (diff) | |
download | oss-fuzz-f2588ea5a8687dffe6f86eba837d7348876d5aaf.tar.gz |
Moving execute to utils.py (#3313)
Diffstat (limited to 'infra/build_specified_commit.py')
-rw-r--r-- | infra/build_specified_commit.py | 30 |
1 files changed, 1 insertions, 29 deletions
diff --git a/infra/build_specified_commit.py b/infra/build_specified_commit.py index 85f844ad2..823fd488d 100644 --- a/infra/build_specified_commit.py +++ b/infra/build_specified_commit.py @@ -21,7 +21,6 @@ import os import collections import logging import re -import subprocess import helper import utils @@ -89,35 +88,8 @@ def detect_main_repo(project_name, repo_name=None, commit=None): command_to_run.extend(['--repo_name', repo_name]) else: command_to_run.extend(['--example_commit', commit]) - out, _ = execute(command_to_run) + out, _ = utils.execute(command_to_run) match = re.search(r'\bDetected repo: ([^ ]+) ([^ ]+)', out.rstrip()) if match and match.group(1) and match.group(2): return match.group(1), match.group(2) return None, None - - -def execute(command, location=None, check_result=False): - """ Runs a shell command in the specified directory location. - - Args: - command: The command as a list to be run. - location: The directory the command is run in. - check_result: Should an exception be thrown on failed command. - - Returns: - The stdout of the command, the error code. - - Raises: - RuntimeError: running a command resulted in an error. - """ - - if not location: - location = os.getcwd() - process = subprocess.Popen(command, stdout=subprocess.PIPE, cwd=location) - out, err = process.communicate() - if check_result and (process.returncode or err): - raise RuntimeError('Error: %s\n Command: %s\n Return code: %s\n Out: %s' % - (err, command, process.returncode, out)) - if out is not None: - out = out.decode('ascii').rstrip() - return out, process.returncode |