OLD | NEW |
1 #!/usr/bin/python2.7 | 1 #!/usr/bin/env python |
2 | 2 |
| 3 |
| 4 # Copyright (c) 2014 The Chromium Authors. All rights reserved. |
| 5 # Use of this source code is governed by a BSD-style license that can be |
| 6 # found in the LICENSE file. |
| 7 |
| 8 |
3 """greenify.py: standalone script to correct flaky bench expectations. | 9 """greenify.py: standalone script to correct flaky bench expectations. |
4 Usage: | 10 |
5 Copy script to a separate dir outside Skia repo. The script will create a | 11 Requires Rietveld credentials on the running machine. |
6 skia dir on the first run to host the repo, and will create/delete temp | 12 |
7 dirs as needed. | 13 Usage: |
8 ./greenify.py --url <the stdio url from failed CheckForRegressions step> | 14 Copy script to a separate dir outside Skia repo. The script will create a |
| 15 skia dir on the first run to host the repo, and will create/delete |
| 16 temp dirs as needed. |
| 17 ./greenify.py --url <the stdio url from failed CheckForRegressions step> |
9 """ | 18 """ |
10 | 19 |
11 import argparse | 20 import argparse |
12 import filecmp | 21 import filecmp |
13 import os | 22 import os |
14 import re | 23 import re |
15 import shutil | 24 import shutil |
16 import subprocess | 25 import subprocess |
17 import time | 26 import time |
18 import urllib2 | 27 import urllib2 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 return True | 149 return True |
141 | 150 |
142 | 151 |
143 def main(): | 152 def main(): |
144 d = os.path.dirname(os.path.abspath(__file__)) | 153 d = os.path.dirname(os.path.abspath(__file__)) |
145 os.chdir(d) | 154 os.chdir(d) |
146 if not subprocess.call(['git', 'rev-parse'], stderr=subprocess.PIPE): | 155 if not subprocess.call(['git', 'rev-parse'], stderr=subprocess.PIPE): |
147 print 'Please copy script to a separate dir outside git repos to use.' | 156 print 'Please copy script to a separate dir outside git repos to use.' |
148 return | 157 return |
149 ts_str = '%s' % time.time() | 158 ts_str = '%s' % time.time() |
150 exp_dir = os.path.join(d, 'exp' + ts_str) | |
151 clean_dir(exp_dir) | |
152 | 159 |
153 parser = argparse.ArgumentParser() | 160 parser = argparse.ArgumentParser() |
154 parser.add_argument('--url', | 161 parser.add_argument('--url', |
155 help='Broken bench build CheckForRegressions page url.') | 162 help='Broken bench build CheckForRegressions page url.') |
156 parser.add_argument('--commit', action='store_true', | 163 parser.add_argument('--commit', action='store_true', |
157 help='Whether to commit changes automatically.') | 164 help='Whether to commit changes automatically.') |
158 args = parser.parse_args() | 165 args = parser.parse_args() |
159 repo_dir = os.path.join(d, 'skia') | 166 repo_dir = os.path.join(d, 'skia') |
160 if not os.path.exists(repo_dir): | 167 if not os.path.exists(repo_dir): |
161 os.makedirs(repo_dir) | 168 os.makedirs(repo_dir) |
(...skipping 11 matching lines...) Expand all Loading... |
173 raise Exception('Please provide a url with broken CheckForRegressions.') | 180 raise Exception('Please provide a url with broken CheckForRegressions.') |
174 path = args.url.split('/') | 181 path = args.url.split('/') |
175 if len(path) != 11 or not path[6].isdigit(): | 182 if len(path) != 11 or not path[6].isdigit(): |
176 raise Exception('Unexpected url format: %s' % args.url) | 183 raise Exception('Unexpected url format: %s' % args.url) |
177 bot = path[4] | 184 bot = path[4] |
178 build = path[6] | 185 build = path[6] |
179 commit = False | 186 commit = False |
180 if args.commit: | 187 if args.commit: |
181 commit = True | 188 commit = True |
182 | 189 |
| 190 exp_dir = os.path.join(d, 'exp' + ts_str) |
| 191 clean_dir(exp_dir) |
183 if not widen_bench_ranges(args.url, bot, repo_dir, exp_dir): | 192 if not widen_bench_ranges(args.url, bot, repo_dir, exp_dir): |
184 print 'NO bench exceptions found! %s' % args.url | 193 print 'NO bench exceptions found! %s' % args.url |
185 elif not git_commit_expectations( | 194 elif not git_commit_expectations( |
186 repo_dir, exp_dir, bot, build, commit): | 195 repo_dir, exp_dir, bot, build, commit): |
187 print 'ERROR uploading expectations using git.' | 196 print 'ERROR uploading expectations using git.' |
188 elif not commit: | 197 elif not commit: |
189 print 'CL created. Please take a look at the link above.' | 198 print 'CL created. Please take a look at the link above.' |
190 else: | 199 else: |
191 print 'New bench baselines should be in CQ now.' | 200 print 'New bench baselines should be in CQ now.' |
192 delete_dirs([exp_dir]) | 201 delete_dirs([exp_dir]) |
193 | 202 |
194 | 203 |
195 if __name__ == "__main__": | 204 if __name__ == "__main__": |
196 main() | 205 main() |
OLD | NEW |