From fd5852a6d0729f72e42899d195799934ceba30c2 Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Sun, 25 Aug 2013 05:10:10 -0400 Subject: [PATCH] RIP Toolserver. (Some fixes for Labs compatibilty.) --- earwigbot/commands/lag.py | 4 ++-- earwigbot/config/script.py | 17 +++++++++++++---- earwigbot/wiki/site.py | 2 +- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/earwigbot/commands/lag.py b/earwigbot/commands/lag.py index c2e8330..cefafcc 100644 --- a/earwigbot/commands/lag.py +++ b/earwigbot/commands/lag.py @@ -24,7 +24,7 @@ from earwigbot import exceptions from earwigbot.commands import Command class Lag(Command): - """Return the replag for a specific database on the Toolserver.""" + """Return replag or maxlag information on specific databases.""" name = "lag" commands = ["lag", "replag", "maxlag"] @@ -45,7 +45,7 @@ class Lag(Command): self.reply(data, msg) def get_replag(self, site): - return "Toolserver replag is {0}".format(self.time(site.get_replag())) + return "replag is {0}".format(self.time(site.get_replag())) def get_maxlag(self, site): return "database maxlag is {0}".format(self.time(site.get_maxlag())) diff --git a/earwigbot/config/script.py b/earwigbot/config/script.py index 35dfc38..7bc54c5 100644 --- a/earwigbot/config/script.py +++ b/earwigbot/config/script.py @@ -279,11 +279,20 @@ class ConfigScript(object): self.data["wiki"]["sql"] = {} if self._wmf: - msg = "Will this bot run from the Wikimedia Toolserver?" - toolserver = self._ask_bool(msg, default=False) - if toolserver: - args = [("host", "$1-p.rrdb.toolserver.org"), ("db", "$1_p")] + msg = "Will this bot run from the Wikimedia Tool Labs?" + labs = self._ask_bool(msg, default=False) + if labs: + args = [("host", "$1.labsdb"), ("db", "$1_p"), + ("read_default_file", + "/data/project/earwigbot/replica.my.cnf")] self.data["wiki"]["sql"] = OrderedDict(args) + else: + msg = "Will this bot run from the Wikimedia Toolserver?" + toolserver = self._ask_bool(msg, default=False) + if toolserver: + args = [("host", "$1-p.rrdb.toolserver.org"), + ("db", "$1_p")] + self.data["wiki"]["sql"] = OrderedDict(args) self.data["wiki"]["shutoff"] = {} msg = "Would you like to enable an automatic shutoff page for the bot?" diff --git a/earwigbot/wiki/site.py b/earwigbot/wiki/site.py index ec6002b..772dfe7 100644 --- a/earwigbot/wiki/site.py +++ b/earwigbot/wiki/site.py @@ -729,7 +729,7 @@ class Site(object): query = """SELECT UNIX_TIMESTAMP() - UNIX_TIMESTAMP(rc_timestamp) FROM recentchanges ORDER BY rc_timestamp DESC LIMIT 1""" result = list(self.sql_query(query)) - return result[0][0] + return int(result[0][0]) def namespace_id_to_name(self, ns_id, all=False): """Given a namespace ID, returns associated namespace names.