Browse Source

Replag command; fix.

tags/v0.1^2
Ben Kurtovic 12 years ago
parent
commit
13476460c9
2 changed files with 31 additions and 0 deletions
  1. +29
    -0
      bot/commands/replag.py
  2. +2
    -0
      bot/tasks/afc_history.py

+ 29
- 0
bot/commands/replag.py View File

@@ -0,0 +1,29 @@
# -*- coding: utf-8 -*-

from os.path import expanduser

import oursql

from classes import BaseCommand

class Command(BaseCommand):
"""Return the replag for a specific database on the Toolserver."""
name = "replag"

def process(self, data):
args = {}
if not data.args:
args["db"] = "enwiki_p"
else:
args["db"] = data.args[0]
args["host"] = args["db"].replace("_", "-") + ".rrdb.toolserver.org"
args["read_default_file"] = expanduser("~/.my.cnf")

conn = oursql.connect(**args)
with conn.cursor() as cursor:
cursor.execute("SELECT NOW() - MAX(rev_timestamp) FROM revision")
replag = cursor.fetchall()[0][0]
conn.close()

msg = "Replag on \x0302{0}\x0301 is \x02{1}\x0F seconds."
self.connection.reply(data, msg.format(args["db"], replag))

+ 2
- 0
bot/tasks/afc_history.py View File

@@ -4,6 +4,8 @@ from datetime import datetime, timedelta
from os.path import expanduser from os.path import expanduser
from threading import Lock from threading import Lock


import oursql

from classes import BaseTask from classes import BaseTask
import config import config
import wiki import wiki


Loading…
Cancel
Save