瀏覽代碼

Replag command; fix.

tags/v0.1^2
Ben Kurtovic 13 年之前
父節點
當前提交
13476460c9
共有 2 個檔案被更改,包括 31 行新增0 行删除
  1. +29
    -0
      bot/commands/replag.py
  2. +2
    -0
      bot/tasks/afc_history.py

+ 29
- 0
bot/commands/replag.py 查看文件

@@ -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 查看文件

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

import oursql

from classes import BaseTask
import config
import wiki


Loading…
取消
儲存