1 # Copyright (c) 2009 Google Inc. All rights reserved.
3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are
7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following disclaimer
11 # in the documentation and/or other materials provided with the
13 # * Neither the name of Google Inc. nor the names of its
14 # contributors may be used to endorse or promote products derived from
15 # this software without specific prior written permission.
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 from webkitpy.tool.bot.sheriff import Sheriff
32 from webkitpy.tool.bot.irc_command import commands as irc_commands
33 from webkitpy.tool.bot.ircbot import IRCBot
34 from webkitpy.tool.commands.queues import AbstractQueue
35 from webkitpy.tool.commands.stepsequence import StepSequenceErrorHandler
37 _log = logging.getLogger(__name__)
40 class SheriffBot(AbstractQueue, StepSequenceErrorHandler):
42 watchers = AbstractQueue.watchers + [
47 # AbstractQueue methods
49 def begin_work_queue(self):
50 AbstractQueue.begin_work_queue(self)
51 self._sheriff = Sheriff(self._tool, self)
52 self._irc_bot = IRCBot(self.name, self._tool, self._sheriff, irc_commands)
53 self._tool.ensure_irc_connected(self._irc_bot.irc_delegate())
55 def work_item_log_path(self, failure_map):
58 def _is_old_failure(self, revision):
59 return self._tool.status_server.svn_revision(revision)
61 def next_work_item(self):
62 self._irc_bot.process_pending_messages()
65 def process_work_item(self, failure_map):
68 def handle_unexpected_error(self, failure_map, message):
71 # StepSequenceErrorHandler methods
74 def handle_script_error(cls, tool, state, script_error):
75 # Ideally we would post some information to IRC about what went wrong
76 # here, but we don't have the IRC password in the child process.