Add noirc option to bot
For local testing we want to run the bot without writing to the outside world. We already have a nocomment option, this adds a no irc option as well. Change-Id: I23cc2e3d05a85a414487b2cdac2f95b977f4e3eb
This commit is contained in:
parent
39f3997101
commit
e1f734b6e6
@ -112,8 +112,7 @@ class RecheckWatch(threading.Thread):
|
|||||||
msg = '%s change: %s failed tempest with an unrecognized error' % (
|
msg = '%s change: %s failed tempest with an unrecognized error' % (
|
||||||
data['change']['project'],
|
data['change']['project'],
|
||||||
data['change']['url'])
|
data['change']['url'])
|
||||||
LOG.info('Compiled Message %s: %s' % (channel, msg))
|
self.print_msg(channel, msg)
|
||||||
self.ircbot.send(channel, msg)
|
|
||||||
|
|
||||||
def error_found(self, channel, data):
|
def error_found(self, channel, data):
|
||||||
msg = ('%s change: %s failed tempest because of: ' % (
|
msg = ('%s change: %s failed tempest because of: ' % (
|
||||||
@ -122,11 +121,12 @@ class RecheckWatch(threading.Thread):
|
|||||||
bug_urls = ['https://bugs.launchpad.net/bugs/%s' % x for x
|
bug_urls = ['https://bugs.launchpad.net/bugs/%s' % x for x
|
||||||
in data['bug_numbers']]
|
in data['bug_numbers']]
|
||||||
msg += ' and '.join(bug_urls)
|
msg += ' and '.join(bug_urls)
|
||||||
LOG.info('Compiled Message %s: %s' % (channel, msg))
|
self.print_msg(channel, msg)
|
||||||
self.ircbot.send(channel, msg)
|
|
||||||
|
|
||||||
def print_msg(self, channel, msg):
|
def print_msg(self, channel, msg):
|
||||||
self.ircbot.send(channel, msg)
|
LOG.info('Compiled Message %s: %s' % (channel, msg))
|
||||||
|
if self.ircbot:
|
||||||
|
self.ircbot.send(channel, msg)
|
||||||
|
|
||||||
def _read(self, data={}, msg=""):
|
def _read(self, data={}, msg=""):
|
||||||
for channel in self.channel_config.channels:
|
for channel in self.channel_config.channels:
|
||||||
@ -195,6 +195,10 @@ def get_options():
|
|||||||
default=False,
|
default=False,
|
||||||
action='store_true',
|
action='store_true',
|
||||||
help="Don't comment in gerrit. Useful in testing.")
|
help="Don't comment in gerrit. Useful in testing.")
|
||||||
|
parser.add_argument('--noirc',
|
||||||
|
default=False,
|
||||||
|
action='store_true',
|
||||||
|
help="Don't comment in irc. Useful in testing.")
|
||||||
parser.add_argument('conffile', nargs=1, help="Configuration file")
|
parser.add_argument('conffile', nargs=1, help="Configuration file")
|
||||||
return parser.parse_args()
|
return parser.parse_args()
|
||||||
|
|
||||||
@ -212,13 +216,16 @@ def _main(args, config):
|
|||||||
|
|
||||||
channel_config = ChannelConfig(yaml.load(open(fp)))
|
channel_config = ChannelConfig(yaml.load(open(fp)))
|
||||||
|
|
||||||
bot = RecheckWatchBot(
|
if not args.noirc:
|
||||||
channel_config.channels,
|
bot = RecheckWatchBot(
|
||||||
config.get('ircbot', 'nick'),
|
channel_config.channels,
|
||||||
config.get('ircbot', 'pass'),
|
config.get('ircbot', 'nick'),
|
||||||
config.get('ircbot', 'server'),
|
config.get('ircbot', 'pass'),
|
||||||
config.getint('ircbot', 'port'),
|
config.get('ircbot', 'server'),
|
||||||
config.get('ircbot', 'server_password'))
|
config.getint('ircbot', 'port'),
|
||||||
|
config.get('ircbot', 'server_password'))
|
||||||
|
else:
|
||||||
|
bot = None
|
||||||
|
|
||||||
recheck = RecheckWatch(
|
recheck = RecheckWatch(
|
||||||
bot,
|
bot,
|
||||||
@ -231,7 +238,8 @@ def _main(args, config):
|
|||||||
)
|
)
|
||||||
|
|
||||||
recheck.start()
|
recheck.start()
|
||||||
bot.start()
|
if not args.noirc:
|
||||||
|
bot.start()
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
Loading…
Reference in New Issue
Block a user