| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 | 6 |
| 7 import math | 7 import math |
| 8 import optparse | 8 import optparse |
| 9 import re | 9 import re |
| 10 import simplejson | 10 import simplejson |
| 11 import subprocess | 11 import subprocess |
| 12 import sys | 12 import sys |
| 13 import time | 13 import time |
| 14 import urllib2 | 14 import urllib2 |
| 15 | 15 |
| 16 | 16 |
| 17 __version__ = '1.0' | 17 __version__ = '1.0' |
| 18 DEFAULT_EXPECTATIONS_FILE = 'perf_expectations.json' | 18 DEFAULT_EXPECTATIONS_FILE = 'perf_expectations.json' |
| 19 DEFAULT_VARIANCE = 0.05 | 19 DEFAULT_VARIANCE = 0.05 |
| 20 USAGE = '' | 20 USAGE = '' |
| 21 | 21 |
| 22 | 22 |
| 23 def ReadFile(filename): | 23 def ReadFile(filename): |
| 24 try: | 24 try: |
| 25 file = open(filename, 'r') | 25 file = open(filename, 'r') |
| 26 except IOError, e: | 26 except IOError, e: |
| 27 print >> sys.stderr, ('I/O Error reading file %s(%s): %s' % | 27 print >> sys.stderr, ('I/O Error reading file %s(%s): %s' % |
| 28 (filename, e.errno, e.strerror)) | 28 (filename, e.errno, e.strerror)) |
| 29 raise e | 29 raise e |
| 30 if not file: | |
| 31 return None | |
| 32 contents = file.read() | 30 contents = file.read() |
| 33 file.close() | 31 file.close() |
| 34 return contents | 32 return contents |
| 35 | 33 |
| 36 | 34 |
| 37 def ConvertJsonIntoDict(string): | 35 def ConvertJsonIntoDict(string): |
| 38 """Read a JSON string and convert its contents into a Python datatype.""" | 36 """Read a JSON string and convert its contents into a Python datatype.""" |
| 39 if len(string) == 0: | 37 if len(string) == 0: |
| 40 print >> sys.stderr, ('Error could not parse empty string') | 38 print >> sys.stderr, ('Error could not parse empty string') |
| 41 raise Exception('JSON data missing') | 39 raise Exception('JSON data missing') |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 if write_new_expectations: | 228 if write_new_expectations: |
| 231 print 'writing expectations... ', | 229 print 'writing expectations... ', |
| 232 WriteJson(DEFAULT_EXPECTATIONS_FILE, perf, perfkeys) | 230 WriteJson(DEFAULT_EXPECTATIONS_FILE, perf, perfkeys) |
| 233 print 'done' | 231 print 'done' |
| 234 else: | 232 else: |
| 235 print 'no updates made' | 233 print 'no updates made' |
| 236 | 234 |
| 237 | 235 |
| 238 if __name__ == '__main__': | 236 if __name__ == '__main__': |
| 239 sys.exit(Main(sys.argv)) | 237 sys.exit(Main(sys.argv)) |
| OLD | NEW |