| Index: PRESUBMIT.py | 
| diff --git a/PRESUBMIT.py b/PRESUBMIT.py | 
| index 751ae525751be38445e4bca2fd0a02c0ac7dd03e..5a13d2fac8151cd30a76b8144fce2d20e680cd5a 100644 | 
| --- a/PRESUBMIT.py | 
| +++ b/PRESUBMIT.py | 
| @@ -1784,29 +1784,28 @@ def CheckChangeOnCommit(input_api, output_api): | 
|  | 
|  | 
| def GetPreferredTryMasters(project, change): | 
| -  import re | 
| -  files = change.LocalPaths() | 
| - | 
| -  import os | 
| import json | 
| -  with open(os.path.join( | 
| -      change.RepositoryRoot(), 'testing', 'commit_queue', 'config.json')) as f: | 
| -    cq_config = json.load(f) | 
| -    cq_verifiers = cq_config.get('verifiers_no_patch', {}) | 
| -    cq_try_jobs = cq_verifiers.get('try_job_verifier', {}) | 
| -    builders = cq_try_jobs.get('launched', {}) | 
| - | 
| -    for master, master_config in cq_try_jobs.get('triggered', {}).iteritems(): | 
| -      for triggered_bot in master_config: | 
| -        builders.get(master, {}).pop(triggered_bot, None) | 
| - | 
| -    # Explicitly iterate over copies of dicts since we mutate them. | 
| -    for master in builders.keys(): | 
| -      for builder in builders[master].keys(): | 
| -        # Do not trigger presubmit builders, since they're likely to fail | 
| -        # (e.g. OWNERS checks before finished code review), and we're | 
| -        # running local presubmit anyway. | 
| -        if 'presubmit' in builder: | 
| -          builders[master].pop(builder) | 
| - | 
| -  return builders | 
| +  import os.path | 
| +  import subprocess | 
| + | 
| +  cq_config_path = os.path.join( | 
| +      change.RepositoryRoot(), 'infra', 'config', 'cq.cfg') | 
| +  # commit_queue.py below is a script in depot_tools directory, which has a | 
| +  # 'builders' command to retrieve a list of CQ builders from the CQ config. | 
| +  masters = json.loads(subprocess.check_output( | 
| +      ['commit_queue', 'builders', cq_config_path], shell=True)) | 
| + | 
| +  # Explicitly iterate over copies of keys since we mutate them. | 
| +  for master in masters.keys(): | 
| +    for builder in masters[master].keys(): | 
| +      # Do not trigger presubmit builders, since they're likely to fail | 
| +      # (e.g. OWNERS checks before finished code review), and we're | 
| +      # running local presubmit anyway. | 
| +      if 'presubmit' in builder: | 
| +        masters[master].pop(builder) | 
| +      else: | 
| +        # Convert testfilter format to the one expected by git-cl-try. | 
| +        testfilter = masters[master][builder].get('testfilter', 'defaulttests') | 
| +        masters[master][builder] = [testfilter] | 
| + | 
| +  return masters | 
|  |