Revision: 4949
Author: wikipedian
Date: 2008-01-30 12:19:31 +0000 (Wed, 30 Jan 2008)
Log Message:
-----------
Each time a script is called, a line is now written to the file logs/commands.log. This
line contains a timestamp, the called module, and the parameters.
You can use this new logfile to track errors and to report bugs.
Modified Paths:
--------------
trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/wikipedia.py
===================================================================
--- trunk/pywikipedia/wikipedia.py 2008-01-30 10:17:03 UTC (rev 4948)
+++ trunk/pywikipedia/wikipedia.py 2008-01-30 12:19:31 UTC (rev 4949)
@@ -5182,6 +5182,17 @@
except ValueError:
return args[0]
+def decodeArg(arg):
+ if sys.platform=='win32' and config.console_encoding == 'cp850':
+ # Western Windows versions give parameters encoded as windows-1252
+ # even though the console encoding is cp850.
+ return unicode(arg, 'windows-1252')
+ else:
+ # Linux uses the same encoding for both.
+ # I don't know how non-Western Windows versions behave.
+ return unicode(arg, config.console_encoding)
+
+
def handleArgs():
"""Handle standard command line arguments, return the rest as a list.
@@ -5189,7 +5200,6 @@
global parameters such as -lang or -log. Returns a list of all arguments
that are not global. This makes sure that global arguments are applied
first, regardless of the order in which the arguments were given.
-
"""
global default_code, default_family, verbose
# get commandline arguments
@@ -5201,14 +5211,7 @@
moduleName = calledModuleName()
nonGlobalArgs = []
for arg in args[1:]:
- if sys.platform=='win32' and config.console_encoding == 'cp850':
- # Western Windows versions give parameters encoded as windows-1252
- # even though the console encoding is cp850.
- arg = unicode(arg, 'windows-1252')
- else:
- # Linux uses the same encoding for both.
- # I don't know how non-Western Windows versions behave.
- arg = unicode(arg, config.console_encoding)
+ arg = decodeArg(arg)
if arg == '-help':
showHelp(moduleName)
sys.exit(0)
@@ -5464,6 +5467,26 @@
result += diff[i]
output(result)
+def writeToCommandLogFile():
+ """
+ Save the name of the called module along with all parameters to
+ logs/commands.log so that the user can look it up later to track errors
+ or report bugs.
+ """
+ # put quotation marks around all parameters
+ args = [decodeArg(sys.argv[0])] + map(lambda s: decodeArg('"%s"' % s), sys.argv[1:])
+ commandLogFilename = config.datafilepath('logs', 'commands.log')
+ try:
+ commandLogFile = codecs.open(commandLogFilename, 'a', 'utf-8')
+ except IOError:
+ commandLogFile = codecs.open(commandLogFilename, 'w', 'utf-8')
+ # add a timestamp in ISO 8601 formulation
+ isoDate = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())
+ commandLogFile.write(isoDate + ' ')
+ s = u' '.join(args)
+ commandLogFile.write(s + '\n')
+ commandLogFile.close()
+
def setLogfileStatus(enabled, logname = None):
global logfile
if enabled:
@@ -5481,6 +5504,8 @@
if '*' in config.log or calledModuleName() in config.log:
setLogfileStatus(True)
+writeToCommandLogFile()
+
colorTagR = re.compile('\03{.*?}', re.UNICODE)
def log(text):
Bugs item #1881742, was opened at 2008-01-29 12:27
Message generated for change (Comment added) made by wikipedian
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=1881742&group_…
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: other
Group: None
>Status: Closed
>Resolution: Fixed
Priority: 5
Private: No
Submitted By: Dashiva (magnusrk)
Assigned to: Nobody/Anonymous (nobody)
Summary: Casing problem with mediawiki_message
Initial Comment:
mediawiki_message in wikipedia.py uses the PHP view of Special:Allmessages as fallback if the specific message page is missing (common in older MW versions).
However, this only registers messages with the first letter lowercase, while regular page access is first letter CI. There are six calls to mediawiki_message using uppercased first letters in wikipedia.py alone, probably many more elsewhere (based on current HEAD).
mediawiki_message should lowercase the first letter of the requested message name before doing the lookup.
----------------------------------------------------------------------
>Comment By: Daniel Herding (wikipedian)
Date: 2008-01-30 12:41
Message:
Logged In: YES
user_id=880694
Originator: NO
Fixed by russblau on 2008-01-29
----------------------------------------------------------------------
Comment By: Nobody/Anonymous (nobody)
Date: 2008-01-29 16:38
Message:
Logged In: NO
No, the bug was in the Site method mediawiki_message(), not the deprecated
module mediawiki_messages.py. Bug fixed in r4947.
----------------------------------------------------------------------
Comment By: AndreasJS (andreasjs)
Date: 2008-01-29 16:11
Message:
Logged In: YES
user_id=1738850
Originator: NO
Module is deprecated since Wed Jun 20 14:42:55 2007 UTC
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=1881742&group_…
Hallo Andreas,
you have submitted several useful patches for PyWikipediaBot. Would you like
to have developer access? Then you could directly commit your changes to the
SVN repository.
Daniel
Patches item #1880834, was opened at 2008-01-27 20:54
Message generated for change (Settings changed) made by wikipedian
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603140&aid=1880834&group_…
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
>Status: Closed
>Resolution: Accepted
Priority: 5
Private: No
Submitted By: AndreasJS (andreasjs)
Assigned to: Nobody/Anonymous (nobody)
Summary: add standard doc for genFactory.handleArg()
Initial Comment:
The documentation for the pagegenerator factory is contained in wikipedia.pagegenerators.parameterHelp and is imported as a macro into the pages using the factory, thus keeping it always up to date in all files. This is standard and is here extended to the files that did not use this feature.
add_text.py
blockpageschecker.py
inline_images.py
lonelypages.py
----------------------------------------------------------------------
Comment By: AndreasJS (andreasjs)
Date: 2008-01-27 20:58
Message:
Logged In: YES
user_id=1738850
Originator: YES
File Added: lonelypages.py
----------------------------------------------------------------------
Comment By: AndreasJS (andreasjs)
Date: 2008-01-27 20:57
Message:
Logged In: YES
user_id=1738850
Originator: YES
File Added: lonelypages.py
----------------------------------------------------------------------
Comment By: AndreasJS (andreasjs)
Date: 2008-01-27 20:57
Message:
Logged In: YES
user_id=1738850
Originator: YES
File Added: inline_images.diff
----------------------------------------------------------------------
Comment By: AndreasJS (andreasjs)
Date: 2008-01-27 20:56
Message:
Logged In: YES
user_id=1738850
Originator: YES
File Added: add_text.diff
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603140&aid=1880834&group_…
Revision: 4948
Author: wikipedian
Date: 2008-01-30 10:17:03 +0000 (Wed, 30 Jan 2008)
Log Message:
-----------
applied patch [ 1880834 ] add standard doc for genFactory.handleArg() by AndreasJS
Modified Paths:
--------------
trunk/pywikipedia/add_text.py
trunk/pywikipedia/blockpageschecker.py
trunk/pywikipedia/inline_images.py
trunk/pywikipedia/lonelypages.py
Modified: trunk/pywikipedia/add_text.py
===================================================================
--- trunk/pywikipedia/add_text.py 2008-01-29 15:37:34 UTC (rev 4947)
+++ trunk/pywikipedia/add_text.py 2008-01-30 10:17:03 UTC (rev 4948)
@@ -3,26 +3,12 @@
"""
This is a Bot written by Filnik to add a text in a given category.
---- GenFactory Generator is used ---
--start Define from which page should the Bot start
--ref Use the ref as generator
--cat Use a category as generator
--filelinks Use all the links to an image as generator
--unusedfiles
--unwatched
--withoutinterwiki
--interwiki
--file
--uncatfiles
--uncatcat
--uncat
--subcat
--transcludes Use all the page that transclude a certain page as generator
--weblink Use the pages with a certain web link as generator
--links Use the links from a certain page as generator
--regex Only work on pages whose titles match the given regex
+These command line parameters can be used to specify which pages to work on:
---- Other parameters ---
+¶ms;
+
+Furthermore, the following command line parameters are supported:
+
-page Use a page as generator
-text Define which text add
-summary Define the summary to use
@@ -60,6 +46,12 @@
import re, pagegenerators, urllib2, urllib
import wikipedia, catlib
+# This is required for the text that is shown when you run this script
+# with the parameter -help.
+docuReplacements = {
+ '¶ms;': pagegenerators.parameterHelp,
+}
+
msg = {
'en': u'Bot: Adding %s',
'he': u'בוט: מוסיף %s',
Modified: trunk/pywikipedia/blockpageschecker.py
===================================================================
--- trunk/pywikipedia/blockpageschecker.py 2008-01-29 15:37:34 UTC (rev 4947)
+++ trunk/pywikipedia/blockpageschecker.py 2008-01-30 10:17:03 UTC (rev 4948)
@@ -8,15 +8,29 @@
Parameters:
+These command line parameters can be used to specify which pages to work on:
+
+¶ms;
+
+-xml Retrieve information from a local XML dump (pages-articles
+ or pages-meta-current, see http://download.wikimedia.org).
+ Argument can also be given as "-xml:filename".
+
+-page Only edit a specific page.
+ Argument can also be given as "-page:pagetitle". You can
+ give this parameter multiple times to edit multiple pages.
+
+
+Furthermore, the following command line parameters are supported:
+
-always Doesn't ask every time if the bot should make the change or not, do it always.
+
-debug When the bot can't delete the template from the page (wrong regex or something like that)
it will ask you if it should open the page on your browser.
(attention: pages included may give false positives..)
--page Work only on one page
+
-move The bot will check if the page is blocked also for the move option, not only for edit
-Note: This script uses also genfactory, you can use those generator as default.
-
--- Warning! ---
You have to edit this script in order to add your preferences
otherwise the script won't work!
@@ -43,6 +57,12 @@
import re, webbrowser
import wikipedia, catlib, pagegenerators, config
+# This is required for the text that is shown when you run this script
+# with the parameter -help.
+docuReplacements = {
+ '¶ms;': pagegenerators.parameterHelp,
+}
+
#######################################################
#--------------------- PREFERENCES -------------------#
################### -- Edit below! -- #################
Modified: trunk/pywikipedia/inline_images.py
===================================================================
--- trunk/pywikipedia/inline_images.py 2008-01-29 15:37:34 UTC (rev 4947)
+++ trunk/pywikipedia/inline_images.py 2008-01-30 10:17:03 UTC (rev 4948)
@@ -10,28 +10,14 @@
It is especially useful when you intend to disable the inline linking
feature.
-This script understands various command-line arguments:
+These command line parameters can be used to specify which pages to work on:
- -start: used as -start:page_name, specifies that the robot should
- go alphabetically through all pages on the home wiki,
- starting at the named page.
+¶ms;
- -file: used as -file:file_name, read a list of pages to treat
- from the named textfile. Page titles should be enclosed
- in [[double-squared brackets]].
+-xml Retrieve information from a local XML dump (pages-articles
+ or pages-meta-current, see http://download.wikimedia.org).
+ Argument can also be given as "-xml:filename".
- -ref: used as -start:page_name, specifies that the robot should
- touch all pages referring to the named page.
-
- -links: used as -links:page_name, specifies that the robot should
- touch all pages referred to from the named page.
-
- -cat: used as -cat:category_name, specifies that the robot should
- touch all pages in the named category.
-
- -redir specifies that the robot should touch redirect pages;
- otherwise, they will be skipped.
-
All other parameters will be regarded as a page title; in this case, the bot
will only touch a single page.
"""
@@ -41,6 +27,12 @@
import wikipedia, pagegenerators, catlib, weblinkchecker, upload
import sys, re
+# This is required for the text that is shown when you run this script
+# with the parameter -help.
+docuReplacements = {
+ '¶ms;': pagegenerators.parameterHelp,
+}
+
msg = {
'en': u'This image was inline linked from %s. No information on author, copyright status, or license is available.',
'he': u'תמונה זו הייתה מקושרת מהדף %s. אין מידע זמין על המחבר, מצב זכויות היוצרים או הרישיון.',
Modified: trunk/pywikipedia/lonelypages.py
===================================================================
--- trunk/pywikipedia/lonelypages.py 2008-01-29 15:37:34 UTC (rev 4947)
+++ trunk/pywikipedia/lonelypages.py 2008-01-30 10:17:03 UTC (rev 4948)
@@ -4,15 +4,28 @@
This is a script written to add the template "orphan" to the pages that aren't linked by other pages.
It can give some strange Errors sometime, I hope that all of them are fixed in this version.
+These command line parameters can be used to specify which pages to work on:
+
+¶ms;
+
+-xml Retrieve information from a local XML dump (pages-articles
+ or pages-meta-current, see http://download.wikimedia.org).
+ Argument can also be given as "-xml:filename".
+
+-page Only edit a specific page.
+ Argument can also be given as "-page:pagetitle". You can
+ give this parameter multiple times to edit multiple pages.
+
+Furthermore, the following command line parameters are supported:
+
-enable: - Enable or disable the bot via a Wiki Page.
+
-disambig: - Set a page where the bot save the name of the disambig pages found (default: skip the pages)
+
-limit: - Set how many pages check.
--page: - Work only on the page given.
+
-always - Always say yes, won't ask
--newpages: - Check the newpages (default: the first 50 pages)
--standard arguments (like -start, -cat, -ref and so on)
-
--- FixMes ---
* Check that all the code hasn't bugs
@@ -36,6 +49,12 @@
import wikipedia, pagegenerators
import re
+# This is required for the text that is shown when you run this script
+# with the parameter -help.
+docuReplacements = {
+ '¶ms;': pagegenerators.parameterHelp,
+}
+
#####################################################
# Here you have to put the config for your Project. #
#####################################################
Patches item #1881758, was opened at 2008-01-29 12:59
Message generated for change (Settings changed) made by wikipedian
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603140&aid=1881758&group_…
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
>Status: Closed
>Resolution: Accepted
Priority: 5
Private: No
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
Summary: Swedish summaries for a few scripts
Initial Comment:
I've noticed that some of the scripts are missing Swedish summaries, so here are a few new ones:
==add_text.py==
'sv': u'Bot: Lägger till %s'
==archivebot.py==
'sv': {
'ArchiveFull': u'(ARKIV FULLT)',
'InitialArchiveHeader': u'{{arkiv}}',
'PageSummary': u'Arkiverar %(count)d trådar (%(why)s) till %(archives)s.',
'ArchiveSummary': u'Arkiverar %(count)d trådar från [[%(from)s]].',
'OlderThanSummary': u'äldre än',
}
==basic.py==
'sv': u'Bot: Ändrar ...'
==capitalize_redirects.py==
'sv': u'Bot: Omdirigerar till [[%s]]'
==catall.py==
'sv':u'Bot: Ändrar kategori'
==catlib.py==
'sv':u'Bot: Flyttad från %s. Författare: %s'
==cosmetic_changes.py==
msg_standalone: 'sv': u'Bot: Kosmetiska ändringar'
msg_append: 'sv': u'kosmetiska ändringar'
==delete.py==
msg_simple_delete: 'sv': u'Bot: Tar bort fillista.'
msg_delete_category: 'sv': u'Bot: Tar bort alla sidor i kategori %s'
msg_delete_links: 'sv': u'Bot: Tar bort alla sidor länkade från %s'
msg_delete_images: 'sv': u'Bot: Tar bort alla bilder på sida %s'
==editarticle.py==
'sv': u'Manuell redigering: %s'
==fixes.py==
'sv': u'Bot: Konverterar/korrigerar HTML'
==fixing_redirects.py==
msg: 'sv': u'Bot: Rättar omdirigeringar'
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603140&aid=1881758&group_…
Bugs item #1881742, was opened at 2008-01-29 03:27
Message generated for change (Comment added) made by nobody
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=1881742&group_…
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: other
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Dashiva (magnusrk)
Assigned to: Nobody/Anonymous (nobody)
Summary: Casing problem with mediawiki_message
Initial Comment:
mediawiki_message in wikipedia.py uses the PHP view of Special:Allmessages as fallback if the specific message page is missing (common in older MW versions).
However, this only registers messages with the first letter lowercase, while regular page access is first letter CI. There are six calls to mediawiki_message using uppercased first letters in wikipedia.py alone, probably many more elsewhere (based on current HEAD).
mediawiki_message should lowercase the first letter of the requested message name before doing the lookup.
----------------------------------------------------------------------
Comment By: Nobody/Anonymous (nobody)
Date: 2008-01-29 07:38
Message:
Logged In: NO
No, the bug was in the Site method mediawiki_message(), not the deprecated
module mediawiki_messages.py. Bug fixed in r4947.
----------------------------------------------------------------------
Comment By: AndreasJS (andreasjs)
Date: 2008-01-29 07:11
Message:
Logged In: YES
user_id=1738850
Originator: NO
Module is deprecated since Wed Jun 20 14:42:55 2007 UTC
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=1881742&group_…
Revision: 4947
Author: russblau
Date: 2008-01-29 15:37:34 +0000 (Tue, 29 Jan 2008)
Log Message:
-----------
fix bug #1881742
Modified Paths:
--------------
trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/wikipedia.py
===================================================================
--- trunk/pywikipedia/wikipedia.py 2008-01-29 14:58:25 UTC (rev 4946)
+++ trunk/pywikipedia/wikipedia.py 2008-01-29 15:37:34 UTC (rev 4947)
@@ -4074,7 +4074,7 @@
def mediawiki_message(self, key):
"""Return the MediaWiki message text for key "key" """
global mwpage, tree
- if key not in self._mediawiki_messages.keys() \
+ if key.lower() not in self._mediawiki_messages.keys() \
and not hasattr(self, "_phploaded"):
get_throttle()
mwpage = self.getUrl("%s?title=%s:%s&action=edit"
@@ -4090,9 +4090,9 @@
else:
value = None
if value:
- self._mediawiki_messages[key] = value
+ self._mediawiki_messages[key.lower()] = value
else:
- self._mediawiki_messages[key] = None
+ self._mediawiki_messages[key.lower()] = None
# Fallback in case MediaWiki: page method doesn't work
if verbose:
output(
@@ -4106,7 +4106,7 @@
count = 0
for (phpkey, phpval) in Rphpvals.findall(phppage):
count += 1
- self._mediawiki_messages[str(phpkey)] = phpval
+ self._mediawiki_messages[str(phpkey).lower()] = phpval
if count == 0:
# No messages could be added.
# We assume that the server is down.
@@ -4121,6 +4121,7 @@
break
self._phploaded = True
+ key = key.lower()
if self._mediawiki_messages[key] is None:
raise KeyError("MediaWiki key '%s' does not exist on %s"
% (key, self))
Bugs item #1881742, was opened at 2008-01-29 06:27
Message generated for change (Comment added) made by andreasjs
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=1881742&group_…
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: other
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Dashiva (magnusrk)
Assigned to: Nobody/Anonymous (nobody)
Summary: Casing problem with mediawiki_message
Initial Comment:
mediawiki_message in wikipedia.py uses the PHP view of Special:Allmessages as fallback if the specific message page is missing (common in older MW versions).
However, this only registers messages with the first letter lowercase, while regular page access is first letter CI. There are six calls to mediawiki_message using uppercased first letters in wikipedia.py alone, probably many more elsewhere (based on current HEAD).
mediawiki_message should lowercase the first letter of the requested message name before doing the lookup.
----------------------------------------------------------------------
>Comment By: AndreasJS (andreasjs)
Date: 2008-01-29 10:11
Message:
Logged In: YES
user_id=1738850
Originator: NO
Module is deprecated since Wed Jun 20 14:42:55 2007 UTC
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=1881742&group_…
Patches item #1808183, was opened at 2007-10-05 12:15
Message generated for change (Comment added) made by andreasjs
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603140&aid=1808183&group_…
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Leszek Krupiński (leszek_k)
Assigned to: Nobody/Anonymous (nobody)
Summary: Users generator
Initial Comment:
Attached patch will add "users" generator - can be used to perform certain actions on all users.
----------------------------------------------------------------------
>Comment By: AndreasJS (andreasjs)
Date: 2008-01-29 10:00
Message:
Logged In: YES
user_id=1738850
Originator: NO
Already exists: most scripts will retrieve all users by using the
parameter :
-prefixindex:User:
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603140&aid=1808183&group_…