Mozilla.com

  1. User:Taken
  2. How to use PyWikipedia on MDC

Content merged from en

How to use PyWikipedia on MDC

This describes how to use PyWikipedia on MDC roughly.

Create account

Create account usually and request that Sysop user sets the bot flag to that bot each languages. now uses "Takenbot"

Download PyWikipedia

To download PyWikipedia via cvs, do something like this.

$ cvs -d :pserver:anonymous@cvs.sf.net:/cvsroot/pywikipediabot login
$ cvs -d :pserver:anonymous@cvs.sf.net:/cvsroot/pywikipediabot co pywikipedia

Prepare config files

download (to be exact copy and paste) mdc_family.py. and put it (pywikipedia)/families.

create (pywikipedia)/user-config.py and write with something like this

family='mdc'
mylang='ja' # or other langs
usernames['mdc']['ja'] = 'Takenbot'
usernames['mdc']['en'] = 'Takenbot'
# (write other languages which needed here)
console_encoding = 'utf-8'

Logging in

you will need login to MDC on first time.

python (pywikipedia)/login.py

but IMHO you should login on each lang

$ python (pywikipedia)/login.py -lang:ja
$ python (pywikipedia)/login.py -lang:en
(execute for other languages which needed here)


Running

to run inter-langs bot do something like this

$ python ./interwiki.py -start:! -log
-start:!
to check all MDC articles.
-log
to create log file. it stores on (pywikipedia)/logs. default file name is interwiki.log. To set file name you can set -log:filename
Running automatically

I use script like below.

#!/bin/sh
cd (pywikipedia)/
rundate=`date +"%FT%T%z"`
python ./interwiki.py -start:! -autonomous -log:`echo $rundate`.log

See also

Content merged from ja

MDC で PyWikipedia を使う

以下では MDC で PyWikipedia の言語間リンクを修正するボットの走らせ方を述べます。

未完成。将来英語化されるかも

アカウントを作成する

通常のようにブラウザでアカウントを作成します。 MDC のユーザアカウントは全ての言語で共通なので、1つの言語で1つのユーザアカウントを取れば十分です。今回は Takenbot にします。

次に各言語毎の sysop 権限を持っているユーザにそのユーザにボットフラグを立てて貰うように申請しましょう。 sysop をもっているユーザは Special:Listusers の「グループ」で「sysop」を選択すると表示されます。

PyWikipedia をダウンロードする

設定ファイルを準備する

PyWikipedia を MDC で動かすための mdc_family.py をコピーアンドペーストして (pywikipedia)/families におきます。 (pywikipedia)/user-config.py に以下のような内容を書きます

family='mdc'
mylang='ja'
usernames['mdc']['ja'] = 'Takenbot'
usernames['mdc']['en'] = 'Takenbot'
console_encoding = 'utf-8'

ログイン

ログインは基本的に

python (pywikipedia)/login.py

ですが、その場合デフォルト言語でのみログインするので、以下のように各言語毎にログインしておく方が良いのではないかと思います。

python (pywikipedia)/login.py -lang:ja
python (pywikipedia)/login.py -lang:en

実際に動かす

python ./interwiki.py -lang:en -start:!

ログを取る

python ./interwiki.py -lang:en -start:! -log

自動化

mdc_bot.sh

#!/bin/sh
cd (pywikipedia)/
rundate=`date +"%FT%T%z"`
python ./interwiki.py -lang:en -start:! -autonomous -log:`echo $rundate`.en.log
python ./interwiki.py -lang:ja -start:! -autonomous -log:`echo $rundate`.ja.log
rm -rf (pywikipedia)/logs/interwiki.log
ln -sf (pywikipedia)/logs/`echo $rundate`.en.log (pywikipedia)/logs/interwiki.log
python ./splitwarning.py
cd logs/
mdc_warnfile.sh > index.html

mdc_warnfile.sh

#!/bin/sh
cat << EOS
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" dir="ltr">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>MDC Warning Files</title>
    <script type="text/javascript" src="mdc_warnfile.js"></script>
    <link type="text/css" rel="stylesheet" href="mdc_warnfile.css" />
  </head>
  <body>
    <h1>MDC Warning Files</h1>
    <p>This page lists the warning files genereated by <a href="http://developer.mozilla.org/en/docs/User:Takenbot">Takenbot</a>, a inter-langs bot on <a href="http://developer.mozilla.org/">MDC</a>.</p>
    <ul>
EOS
for file in warning-mdc-*.log
do
  echo "<li class=\"close\">"
  echo \<p\>\<a href=\"$file\"\ onclick=\"showWarnFile\(this\)\;r\eturn false\"\>$file\</a\>
  echo "("`wc -l < $file`" warnings.)</p>"
  echo "</li>"
done
cat << EOS
    </ul>
    <address>
EOS
echo "<br/>Last updated : " `date +"%FT%T%z"` ".<br/>"
cat << EOS
Genereated by <a href="http://developer.mozilla.org/en/docs/User:Takenbot">Takenbot</a> operated by <a href="http://developer.mozilla.org/en/docs/User:Taken">Taken</a>.
    </address>
  </body>
</html>
EOS

Page last modified 10:12, 1 May 2006 by Victory?

Tags:

Files (0)