Dzahn has submitted this change and it was merged.

Change subject: added year into logging, made pep8 and pyflakes happy
......................................................................


added year into logging, made pep8 and pyflakes happy

Bug: T85803
Change-Id: Ia1a8bddfa60fc50d95cfbc2227ca395b8b68f7c4
---
M adminlog.py
M adminlogbot.py
M statusnet.py
3 files changed, 18 insertions(+), 18 deletions(-)

Approvals:
  Negative24: Looks good to me, but someone else must approve
  JanZerebecki: Looks good to me, but someone else must approve
  Dzahn: Looks good to me, approved



diff --git a/adminlog.py b/adminlog.py
index 240c778..d20cc42 100644
--- a/adminlog.py
+++ b/adminlog.py
@@ -23,7 +23,7 @@
 
        page = site.Pages[pagename]
        if page.redirect:
-               page = next(p.links())
+               page = next(page.links())
 
        text = page.edit()
        lines = text.split('\n')
@@ -31,6 +31,7 @@
        # Um, check the date
        now = datetime.datetime.utcnow()
        logline = "* %02d:%02d %s: %s" % (now.hour, now.minute, author, message)
+       year = str(now.year)
        month = str(now.month)
        day = str(now.day)
        # Try extracting latest date header
@@ -38,12 +39,13 @@
        for line in lines:
                position += 1
                if line.startswith(header):
-                       undef, month, day, undef = line.split(" ", 3)
+                       undef, year, month, day, undef = line.split(" ", 4)
                        break
-       if months[now.month - 1] != month or now.day != int(day):
+       if now.year != int(year) or months[
+               now.month - 1] != month or now.day != int(day):
                lines.insert(0, "")
                lines.insert(0, logline)
-               lines.insert(0, "%s %s %d %s" % (header, months[now.month - 1],
+               lines.insert(0, "%s %d %s %d %s" % (header, now.year, 
months[now.month - 1],
                        now.day, header))
        else:
                lines.insert(position, logline)
diff --git a/adminlogbot.py b/adminlogbot.py
index 1b96b3f..2776729 100755
--- a/adminlogbot.py
+++ b/adminlogbot.py
@@ -13,8 +13,6 @@
 import time
 import urllib
 
-import traceback
-
 
 LOG_FORMAT = "%(asctime)-15s %(levelname)s: %(message)s"
 
@@ -33,7 +31,8 @@
         ircbot.SingleServerIRCBot.connect(self, *args, **kwargs)
 
     def get_version(self):
-        return 'Wikimedia Server Admin Log bot -- 
https://wikitech.wikimedia.org/wiki/Morebots'
+        return ('Wikimedia Server Admin Log bot -- '
+            'https://wikitech.wikimedia.org/wiki/Morebots')
 
     def get_cloak(self, source):
         if re.search("/", source) and re.search("@", source):
@@ -118,12 +117,10 @@
                 for obj in projectdata:
                     projects.append(obj[1]["cn"][0])
 
-
                 if self.config.service_group_rdn:
                     sgdata = ds.search_s(self.config.service_group_rdn +
-                                              "," + base,
-                                              ldap.SCOPE_SUBTREE,
-                                              "(objectclass=groupofnames)")
+                        "," + base, ldap.SCOPE_SUBTREE,
+                        "(objectclass=groupofnames)")
                     if not sgdata:
                         self.connection.privmsg(event.target(),
                                             "Can't contact LDAP"
@@ -137,7 +134,7 @@
                     self.connection.privmsg(event.target(),
                                         "Error reading project"
                                         " list from LDAP.")
-                except irclib.ServerNotConnectedError, e:
+                except irclib.ServerNotConnectedError:
                     logging.debug("Server connection error"
                                   " when sending message")
         return projects
@@ -169,7 +166,7 @@
                 try:
                     self.connection.privmsg(event.target(),
                                         "To log a message, type !log <msg>.")
-                except irclib.ServerNotConnectedError, e:
+                except irclib.ServerNotConnectedError:
                     logging.debug("Server connection error "
                                   "when sending message")
         elif line.lower().startswith("!log "):
@@ -222,7 +219,7 @@
                                                 " to the trust list"
                                                 " or your user page.")
                             return
-                    except irclib.ServerNotConnectedError, e:
+                    except irclib.ServerNotConnectedError:
                         logging.debug("Server connection error"
                                       " when sending message")
             if self.config.enable_projects:
@@ -237,7 +234,7 @@
                         self.connection.privmsg(event.target(),
                                             "Message missing. Nothing logged.")
                         return
-                except irclib.ServerNotConnectedError, e:
+                except irclib.ServerNotConnectedError:
                     logging.debug("Server connection error"
                                   " when sending message")
                 project = arr[1]
@@ -248,7 +245,7 @@
                         self.connection.privmsg(event.target(),
                                             project +
                                             " is not a valid project.")
-                    except irclib.ServerNotConnectedError, e:
+                    except irclib.ServerNotConnectedError:
                         logging.debug("Server connection error"
                                       " when sending message")
                     return
@@ -259,7 +256,7 @@
                     try:
                         self.connection.privmsg(event.target(),
                                             "Message missing. Nothing logged.")
-                    except irclib.ServerNotConnectedError, e:
+                    except irclib.ServerNotConnectedError:
                         logging.debug("Server connection error"
                                       " when sending message")
                     return
@@ -274,7 +271,7 @@
                 try:
                     self.connection.privmsg(event.target(),
                                         "Logged the message, %s" % title)
-                except irclib.ServerNotConnectedError, e:
+                except irclib.ServerNotConnectedError:
                     logging.debug("Server connection error"
                                   " when sending message")
             except Exception:
diff --git a/statusnet.py b/statusnet.py
index 34628c6..d4f47af 100644
--- a/statusnet.py
+++ b/statusnet.py
@@ -7,6 +7,7 @@
 
 if version_info[0] < 3:
     from urllib import urlencode
+    assert urlencode
 else:
     from urllib.parse import urlencode
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ia1a8bddfa60fc50d95cfbc2227ca395b8b68f7c4
Gerrit-PatchSet: 12
Gerrit-Project: operations/debs/adminbot
Gerrit-Branch: master
Gerrit-Owner: Elee <e...@mit.edu>
Gerrit-Reviewer: Dzahn <dz...@wikimedia.org>
Gerrit-Reviewer: Elee <e...@mit.edu>
Gerrit-Reviewer: JanZerebecki <jan.wikime...@zerebecki.de>
Gerrit-Reviewer: Negative24 <jamison.loftho...@gmail.com>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to