OLD | NEW |
1 # Copyright (c) 2013 Google Inc. All rights reserved. | 1 # Copyright (c) 2013 Google Inc. All rights reserved. |
2 # | 2 # |
3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
5 # met: | 5 # met: |
6 # | 6 # |
7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
(...skipping 20 matching lines...) Expand all Loading... |
31 from webkitpy.common.config.irc import update_wait_seconds | 31 from webkitpy.common.config.irc import update_wait_seconds |
32 from webkitpy.tool.bot.commitannouncer import CommitAnnouncer, CommitAnnouncerTh
read | 32 from webkitpy.tool.bot.commitannouncer import CommitAnnouncer, CommitAnnouncerTh
read |
33 from webkitpy.tool.multicommandtool import AbstractDeclarativeCommand | 33 from webkitpy.tool.multicommandtool import AbstractDeclarativeCommand |
34 | 34 |
35 _log = logging.getLogger(__name__) | 35 _log = logging.getLogger(__name__) |
36 | 36 |
37 | 37 |
38 class CommitAnnouncerCommand(AbstractDeclarativeCommand): | 38 class CommitAnnouncerCommand(AbstractDeclarativeCommand): |
39 name = "commit-announcer" | 39 name = "commit-announcer" |
40 help_text = "Start an IRC bot for announcing new git commits." | 40 help_text = "Start an IRC bot for announcing new git commits." |
| 41 show_in_main_help = True |
41 | 42 |
42 def __init__(self): | 43 def __init__(self): |
43 options = [ | 44 options = [ |
44 make_option("--irc-password", default=None, help="Specify IRC passwo
rd to use."), | 45 make_option("--irc-password", default=None, help="Specify IRC passwo
rd to use."), |
45 ] | 46 ] |
46 AbstractDeclarativeCommand.__init__(self, options) | 47 AbstractDeclarativeCommand.__init__(self, options) |
47 | 48 |
48 def execute(self, options, args, tool): | 49 def execute(self, options, args, tool): |
49 bot_thread = CommitAnnouncerThread(tool, options.irc_password) | 50 bot_thread = CommitAnnouncerThread(tool, options.irc_password) |
50 bot_thread.start() | 51 bot_thread.start() |
51 _log.info("Bot started") | 52 _log.info("Bot started") |
52 try: | 53 try: |
53 while bot_thread.is_alive(): | 54 while bot_thread.is_alive(): |
54 bot_thread.bot.post_new_commits() | 55 bot_thread.bot.post_new_commits() |
55 time.sleep(update_wait_seconds) | 56 time.sleep(update_wait_seconds) |
56 except KeyboardInterrupt: | 57 except KeyboardInterrupt: |
57 _log.error("Terminated by keyboard interrupt") | 58 _log.error("Terminated by keyboard interrupt") |
58 except Exception, e: | 59 except Exception, e: |
59 _log.error("Unexpected error:") | 60 _log.error("Unexpected error:") |
60 _log.error(traceback.format_exc()) | 61 _log.error(traceback.format_exc()) |
61 | 62 |
62 if bot_thread.is_alive(): | 63 if bot_thread.is_alive(): |
63 _log.info("Disconnecting bot") | 64 _log.info("Disconnecting bot") |
64 bot_thread.stop() | 65 bot_thread.stop() |
65 else: | 66 else: |
66 _log.info("Bot offline") | 67 _log.info("Bot offline") |
67 _log.info("Done") | 68 _log.info("Done") |
OLD | NEW |