Alex Monk has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/286683

Change subject: Make udpmxircecho conform to pep8
......................................................................

Make udpmxircecho conform to pep8

Change-Id: I128c37db0a0b34e3d57fcfd2742f6bb6da95b3fc
---
M modules/mw_rc_irc/templates/udpmxircecho.py.erb
1 file changed, 45 insertions(+), 44 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/83/286683/1

diff --git a/modules/mw_rc_irc/templates/udpmxircecho.py.erb 
b/modules/mw_rc_irc/templates/udpmxircecho.py.erb
index df2ff38..79d63a9 100755
--- a/modules/mw_rc_irc/templates/udpmxircecho.py.erb
+++ b/modules/mw_rc_irc/templates/udpmxircecho.py.erb
@@ -1,70 +1,71 @@
 #! /usr/bin/env python
 #
 # usage: udpmxircecho.py nickname server
-import sys
-reload(sys)
-sys.setdefaultencoding('utf8')
-
 <% if scope.function_os_version(['debian >= jessie']) %>
 from irc.bot import SingleServerIRCBot
 <% else %>
 from ircbot import SingleServerIRCBot
 <% end %>
-
-import threading, socket
+import threading
+import socket
+import sys
+reload(sys)
+sys.setdefaultencoding('utf8')
 
 
 class EchoReader(threading.Thread):
-        def __init__(self, bot):
-                threading.Thread.__init__(self)
-                self.bot = bot
+    def __init__(self, bot):
+        threading.Thread.__init__(self)
+        self.bot = bot
 
-        def run(self):
-                udpsock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
+    def run(self):
+        udpsock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
 
-                udpsock.bind(('', 9390))
+        udpsock.bind(('', 9390))
 
-                while True:
-                        try:
-                                s = udpsock.recv(65535)
-                                sp = s.split("\t")
-                                if len(sp) == 2:
-                                        channel = sp[0]
-                                        text = sp[1]
-                                        text = 
text.lstrip().replace('\r','').replace('\n','')
+        while True:
+            try:
+                s = udpsock.recv(65535)
+                sp = s.split("\t")
+                if len(sp) == 2:
+                    channel = sp[0]
+                    text = sp[1].lstrip().replace('\r', '').replace('\n', '')
 
-                                        if channel not in self.bot.chans:
-                                                self.bot.chans.append(channel)
-                                                
self.bot.connection.join(channel)
-                                        # this throws an exception if not 
connected.
-                                        self.bot.connection.privmsg(channel, 
text)
+                    if channel not in self.bot.chans:
+                        self.bot.chans.append(channel)
+                        self.bot.connection.join(channel)
+                    # this throws an exception if not connected.
+                    self.bot.connection.privmsg(channel, text)
+            except EOFError:
+                # Once the input is finished, the bot should exit
+                sys.exit()
+            except Exception as e:
+                print e
 
-                        except EOFError:
-                                # Once the input is finished, the bot should 
exit
-                                sys.exit()
-                        except Exception as e:
-                                print e
 
 class EchoBot(SingleServerIRCBot):
-        def __init__(self, chans, nickname, server):
-                port = 6667
-                print "connecting to %s as %s on port %s" % (server, nickname, 
port)
-                SingleServerIRCBot.__init__(self, [(server, port)], nickname, 
"IRC echo bot")
-                self.chans = chans
+    def __init__(self, chans, nickname, server):
+        port = 6667
+        print "connecting to %s as %s on port %s" % (server, nickname, port)
+        server_list = [(server, port)]
+        realname = "IRC echo bot"
+        SingleServerIRCBot.__init__(self, server_list, nickname, realname)
+        self.chans = chans
 
-        def on_nicknameinuse(self, c, e):
-                print '%s nickname in use!' % (c.get_nickname(),)
-                c.nick(c.get_nickname() + "_")
+    def on_nicknameinuse(self, c, e):
+        print '%s nickname in use!' % (c.get_nickname(),)
+        c.nick(c.get_nickname() + "_")
 
-        def on_welcome(self, c, e):
-                print "got welcome"
-                c.oper("rc", "<%= @ircpassword %>")
+    def on_welcome(self, c, e):
+        print "got welcome"
+        c.oper("rc", "<%= @ircpassword %>")
 
-                for chan in self.chans:
-                        c.join(chan)
+        for chan in self.chans:
+            c.join(chan)
+
 
 def main():
-    bot = EchoBot([], sys.argv[1], sys.argv[2]);
+    bot = EchoBot([], sys.argv[1], sys.argv[2])
     sthr = EchoReader(bot)
     sthr.start()
     bot.start()

-- 
To view, visit https://gerrit.wikimedia.org/r/286683
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I128c37db0a0b34e3d57fcfd2742f6bb6da95b3fc
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Alex Monk <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to