Xixuan Wu | 197b065 | 2017-08-28 15:46:25 -0700 | [diff] [blame] | 1 | # Copyright 2017 The Chromium OS 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 | |
Xixuan Wu | 64361fe | 2017-08-28 19:15:17 -0700 | [diff] [blame] | 5 | """Module of BuildEvent, triggered by new builds.""" |
Xixuan Wu | 197b065 | 2017-08-28 15:46:25 -0700 | [diff] [blame] | 6 | |
| 7 | import datetime |
| 8 | |
| 9 | import base_event |
| 10 | import constants |
| 11 | import time_converter |
| 12 | |
| 13 | |
| 14 | class NewBuild(base_event.BaseEvent): |
Xixuan Wu | 64361fe | 2017-08-28 19:15:17 -0700 | [diff] [blame] | 15 | """The class for BuildEvent triggered by new builds.""" |
Xixuan Wu | 197b065 | 2017-08-28 15:46:25 -0700 | [diff] [blame] | 16 | |
| 17 | KEYWORD = 'new_build' |
| 18 | PRIORITY = constants.Priorities.POSTBUILD |
| 19 | |
| 20 | # Every several hours a batch of tasks in task_list of NewBuild event |
| 21 | # is scheduled. Here we set the LAST_EXEC_INTERVAL=6. |
| 22 | LAST_EXEC_INTERVAL = 6 |
| 23 | |
| 24 | # NewBuild event's tasks get 12 hours to run, as builds come out |
| 25 | # every 6 hours. |
| 26 | TIMEOUT = 12 |
| 27 | |
| 28 | def __init__(self, event_settings, last_exec_utc): |
| 29 | """Initialize a BuildEvent. |
| 30 | |
| 31 | Args: |
| 32 | event_settings: a config_reader.EventSettings object. |
| 33 | last_exec_utc: The utc datetime.datetime timestamp of last |
| 34 | execution. |
| 35 | """ |
| 36 | now = time_converter.utc_now() |
| 37 | target_exec_utc = datetime.datetime( |
| 38 | now.year, now.month, now.day, now.hour, now.minute, |
| 39 | tzinfo=time_converter.UTC_TZ) |
| 40 | |
| 41 | super(NewBuild, self).__init__( |
| 42 | event_settings, last_exec_utc, target_exec_utc) |
| 43 | |
| 44 | self.since_date = self.last_exec_utc |