Data: 18 febbraio 2008 23:50:02 GMT+01:00
Oggetto: [Pywikipedia-l] Logging Pywikipedia output
Hi
I am using standard python logging for my project. This project uses
Pywikipedia and runs as a cron job every night. It therefore needs to
log to a file and possibly any other configured log handler (mail,
syslog etc).
However, looking at wikipedia.py it seems Pywikipedia does not use any
kind of logging facility meaning that messages created by the tool are
lost if not piped to a output file.
Have the developers of this helpful tool considered or discussed using
standard Python logging for Pywikipedia instead print statements?
Maybe I am missing something? It would be helpful to be able to
configure a dedicated logger for the Pywikipedia output messages for
debugging a production environment.
Regards
Lee Francis
--
_____
In theory, there is no difference between theory and practice. But, in
practice, there is.
-- Jan L.A. van de Snepscheut
You should replace all the calls to the Python statement "print" to "wikipedia.output()". For example:
print "Foo"
becomes:
wikipedia.output("Foo")
Now you can use the "-log" option to log the output of your script to a file:
python my_bot_script.py -log:logs/my_bot_script.log
Of course you need to add "wikipedia.handleArgs()" at the beginning of your script so pywikipedia can handle the shell parameters (e.g. -log).
Data: 19 febbraio 2008 10:17:29 GMT+01:00
Oggetto: [Pywikipedia-l] Reducing sleep time
Hi
I am uploading a lot of documents to my local wiki. However,
Pywikipedia is sleeping for nearly 10 seconds between calls to
page.put(...). For large amounts of files this is quite noticeable.
"Sleeping for 9.3 seconds, 2008-02-19 10:06:45"
"Creating page [[en:<something>]]"
Can someone briefly explain why this sleep time is necessary and also
how to reduce it (eliminate it?) if possible. I am thinking there is a
story here... :-)
I think I saw a script somewhere tackling a similar problem, but I
can't seem to find it now.
Regards
Lee Francis
--
_____
In theory, there is no difference between theory and practice. But, in
practice, there is.
-- Jan L.A. van de Snepscheut
_______________________________________________
Pywikipedia-l mailing list
You can reduce this sleep time by setting the "put_throttle" variable in user-config.py.