blob: 7521df6e7636b05698ec5ac94b9740f1431956f7 [file] [log] [blame]
Xixuan Wu197b0652017-08-28 15:46:25 -07001# 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 Wu64361fe2017-08-28 19:15:17 -07005"""Module of BuildEvent, triggered by new builds."""
Xixuan Wu197b0652017-08-28 15:46:25 -07006
7import datetime
8
9import base_event
10import constants
11import time_converter
12
13
14class NewBuild(base_event.BaseEvent):
Xixuan Wu64361fe2017-08-28 19:15:17 -070015 """The class for BuildEvent triggered by new builds."""
Xixuan Wu197b0652017-08-28 15:46:25 -070016
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