OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/python |
| 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. |
| 5 |
| 6 """A Module for LayoutTestAnalyzer main functions.""" |
| 7 |
| 8 import csv |
| 9 from datetime import datetime |
| 10 import optparse |
| 11 import os |
| 12 import time |
| 13 import pickle |
| 14 |
| 15 from layouttests import LayoutTests |
| 16 from test_expectations import TestExpectations |
| 17 import layouttest_analyzer_helpers |
| 18 from layouttest_analyzer_helpers import AnalyzerResultMap |
| 19 |
| 20 # DEBUG mode is used when you want to debug the analyzer by using local file |
| 21 # rather than getting data from SVN. This shortens the debugging time. |
| 22 DEBUG = False |
| 23 |
| 24 # Pre-defined default dirs. |
| 25 RESULT_DIR = 'result' |
| 26 ANNOTATION_DIR = 'anno' |
| 27 |
| 28 |
| 29 def parse_option(): |
| 30 """Parse command line options using OptionParser. |
| 31 |
| 32 Returns: |
| 33 (options, args) tuple which contains options |
| 34 """ |
| 35 option_parser = optparse.OptionParser() |
| 36 |
| 37 option_parser.add_option("-r", |
| 38 "--receiver-email-address", |
| 39 dest="receiver_email_address", |
| 40 help="reciever's email adddress", |
| 41 default='imasaki@chromium.org') |
| 42 (options, _) = option_parser.parse_args() |
| 43 return options |
| 44 |
| 45 |
| 46 def main(): |
| 47 """A main function for the analyzer.""" |
| 48 options = parse_option() |
| 49 |
| 50 if not DEBUG: |
| 51 layouttests = LayoutTests(csv_file_path=os.path.join('testname', |
| 52 'media.csv')) |
| 53 test_expectations = TestExpectations() |
| 54 test_info_map = layouttests.JoinWithTestExpectation(test_expectations) |
| 55 analyzer_result_map = AnalyzerResultMap(test_info_map) |
| 56 (prev_time, prev_analyzer_result_map) = ( |
| 57 layouttest_analyzer_helpers.FindLatestResult('result')) |
| 58 else: |
| 59 analyzer_result_map = AnalyzerResultMap.Load(os.path.join(RESULT_DIR, |
| 60 '2011-08-19-21')) |
| 61 prev_time = '2011-08-19-11' |
| 62 prev_analyzer_result_map = AnalyzerResultMap.Load(os.path.join(RESULT_DIR, |
| 63 '2011-08-19-11')) |
| 64 |
| 65 # Read annotations. |
| 66 anno_map = {} |
| 67 file_path = os.path.join(ANNOTATION_DIR, 'anno.csv') |
| 68 file_object = open(file_path) |
| 69 data = csv.reader(file_object) |
| 70 for row in data: |
| 71 anno_map[row[0]] = row[1] |
| 72 file_object.close() |
| 73 |
| 74 layouttest_analyzer_helpers.SendStatusEmail(prev_time, analyzer_result_map, |
| 75 prev_analyzer_result_map, |
| 76 anno_map, |
| 77 options.receiver_email_address) |
| 78 if not DEBUG: |
| 79 # Save the current result. |
| 80 t = datetime.now() |
| 81 date = t.strftime("%Y-%m-%d-%H") |
| 82 file_path = os.path.join(RESULT_DIR, date) |
| 83 file_object = open(file_path, "wb") |
| 84 pickle.dump(analyzer_result_map, file_object) |
| 85 file_object.close() |
| 86 |
| 87 |
| 88 if '__main__' == __name__: |
| 89 main() |
OLD | NEW |