| OLD | NEW |
| (Empty) | |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. |
| 4 |
| 5 import jinja2 |
| 6 import os |
| 7 |
| 8 from model import wf_analysis_status |
| 9 |
| 10 |
| 11 JINJA_ENVIRONMENT = jinja2.Environment( |
| 12 loader=jinja2.FileSystemLoader( |
| 13 os.path.join(os.path.dirname(__file__), 'templates')), |
| 14 extensions=['jinja2.ext.autoescape'], |
| 15 autoescape=True) |
| 16 |
| 17 # Additional status for swarming tasks and try jobs. |
| 18 NO_SWARMING_TASK_FOUND = 110 |
| 19 NON_SWARMING_NO_RERUN = 120 |
| 20 #Additional reasons for no try job information. |
| 21 SWARMING_TASK_PENDING = 130 |
| 22 SWARMING_TASK_RUNNING = 140 |
| 23 SWARMING_TASK_ERROR = 150 |
| 24 FLAKY = 200 |
| 25 |
| 26 NO_TRY_JOB_REASON_MAP = { |
| 27 NO_SWARMING_TASK_FOUND: NO_SWARMING_TASK_FOUND, |
| 28 NON_SWARMING_NO_RERUN: NON_SWARMING_NO_RERUN, |
| 29 wf_analysis_status.PENDING: SWARMING_TASK_PENDING, |
| 30 wf_analysis_status.ANALYZING: SWARMING_TASK_RUNNING, |
| 31 wf_analysis_status.ERROR: SWARMING_TASK_ERROR, |
| 32 } |
| 33 |
| 34 def ToStatusMessage(status_code): |
| 35 status_message_map = { |
| 36 wf_analysis_status.PENDING: 'try job is pending.', |
| 37 wf_analysis_status.ANALYZING: 'try job is running.', |
| 38 wf_analysis_status.ANALYZED: 'try job is completed.', |
| 39 wf_analysis_status.ERROR: 'try job failed.', |
| 40 NO_SWARMING_TASK_FOUND: 'No swarming task found, hence no try job.', |
| 41 NON_SWARMING_NO_RERUN: ('No swarming task nor try job will be triggered' |
| 42 ' for non-swarming steps.'), |
| 43 SWARMING_TASK_PENDING: 'Swarming task is pending, no try job yet.', |
| 44 SWARMING_TASK_RUNNING: 'Swarming task is running, no try job yet.', |
| 45 SWARMING_TASK_ERROR: ( |
| 46 'Swarming task failed, try job will not be triggered.'), |
| 47 FLAKY: 'Flaky tests.', |
| 48 } |
| 49 return status_message_map.get(status_code, '!!!MESSAGE BUG!!!') |
| 50 |
| 51 JINJA_ENVIRONMENT.filters['tostatusmessage'] = ToStatusMessage |
| OLD | NEW |