Hashar has uploaded a new change for review. https://gerrit.wikimedia.org/r/53361
Change subject: pass pep8 linting checks ...................................................................... pass pep8 linting checks Change-Id: I22a0dba634f060e5335edd83e6d54e07542f249a --- M ircecho 1 file changed, 21 insertions(+), 14 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/operations/debs/ircecho refs/changes/61/53361/1 diff --git a/ircecho b/ircecho index f0317f0..2de32c0 100755 --- a/ircecho +++ b/ircecho @@ -2,11 +2,12 @@ # # stdin -> IRC echo bot, with optional file input support. # -# Written by Kate Turner <[email protected]>, source is in the public domain. -# Modified by Ryan Lane <[email protected]> for watching and taking input for files. -# Changes are also public domain. -# Modified by Ryan Anderson <[email protected]> to handle -# disconnections more gracefully. Changes in the public domain. +# Written by Kate Turner <[email protected]>, source is in the public +# domain. +# Modified by Ryan Lane <[email protected]> for watching and taking input +# for files. Changes are also public domain. +# Modified by Ryan Anderson <[email protected]> to handle disconnections more +# gracefully. Changes in the public domain. import sys import pyinotify @@ -14,9 +15,10 @@ import random import string import re -import irclib # for exceptions. +import irclib # for exceptions. from optparse import OptionParser from ircbot import SingleServerIRCBot + class EchoNotifier(threading.Thread): def __init__(self, notifier): @@ -25,6 +27,7 @@ def run(self): self.notifier.loop() + class EchoReader(threading.Thread): def __init__(self, infile='', associatedchannel=''): @@ -66,7 +69,7 @@ try: print "Opening: " + filename f = open(filename) - f.seek(0,2) + f.seek(0, 2) self.files[filename] = f except IOError: print "Failed to open file: " + filename @@ -92,9 +95,10 @@ self.bot.connection.privmsg(self.chans, s) except EOFError: # Once the input is finished, the bot should exit - break; + break except Exception: pass + def readfile(self, filename): if self.files[filename]: return self.files[filename].read() @@ -106,6 +110,7 @@ return self.associations[filename] else: return bot.chans + class EchoBot(SingleServerIRCBot): def __init__(self, chans, nickname, server): @@ -121,17 +126,18 @@ for chan in [self.chans]: c.join(chan) + class EventHandler(pyinotify.ProcessEvent): def process_IN_MODIFY(self, event): s = reader.readfile(event.pathname) s = s.rstrip('\n') if s: chans = reader.getchannels(event.pathname) - try: - bot.connection.privmsg(chans, s) - except irclib.ServerNotConnectedError, e: - print ("Error writing: %s\n" - "Dropping this message: '%s'") % (e, s) + try: + bot.connection.privmsg(chans, s) + except irclib.ServerNotConnectedError, e: + print ("Error writing: %s\n" + "Dropping this message: '%s'") % (e, s) def process_IN_CREATE(self, event): try: @@ -143,7 +149,8 @@ parser = OptionParser(conflict_handler="resolve") parser.set_usage("ircecho [--infile=<filename>] <channel> <nickname> <server>") -parser.add_option("--infile", dest="infile", help="Read input from the specific file instead of from stdin") +parser.add_option("--infile", dest="infile", + help="Read input from the specific file instead of from stdin") (options, args) = parser.parse_args() chans = args[0] nickname = args[1] -- To view, visit https://gerrit.wikimedia.org/r/53361 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I22a0dba634f060e5335edd83e6d54e07542f249a Gerrit-PatchSet: 1 Gerrit-Project: operations/debs/ircecho Gerrit-Branch: master Gerrit-Owner: Hashar <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
