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