I posted this yesterday about 15 hours ago and don't see it yet, so I'm reposting:
I'm new to anything Python related. I downloaded pywikimedia yesterday and am trying to get this to work.
This is my dump from api.php?action=query&meta=siteinfo&siprop=general|namespaces|namespacealiases|statistics
[QUOTE]
<?xml version="1.0"?> <api> <query> <general mainpage="Main Page" base= "http://www.locksmithwiki.com/lockwiki/index.php/Main_Page"http://www.locksmithwiki.com/lockwiki/index.php/Main_Pagesitename="Locksmith Wiki Knowledge Base" generator="MediaWiki 1.15.1" case="first-letter" rights="" lang="en" fallback8bitEncoding="windows-1252" writeapi="" timezone="UTC" timeoffset="0" /> <namespaces> <ns id="-2" canonical="Media" xml:space="preserve">Media</ns> <ns id="-1" canonical="Special" xml:space="preserve">Special</ns> <ns id="0" xml:space="preserve" /> <ns id="1" subpages="" canonical="Talk" xml:space="preserve">Talk</ns> <ns id="2" subpages="" canonical="User" xml:space="preserve">User</ns> <ns id="3" subpages="" canonical="User talk" xml:space="preserve">User talk</ns> <ns id="4" canonical="Project" xml:space="preserve">Locksmith Wiki Knowledge Base</ns> <ns id="5" subpages="" canonical="Project talk" xml:space="preserve">Locksmith Wiki Knowledge Base talk</ns> <ns id="6" canonical="File" xml:space="preserve">File</ns> <ns id="7" subpages="" canonical="File talk" xml:space="preserve">File talk</ns> <ns id="8" canonical="MediaWiki" xml:space="preserve">MediaWiki</ns> <ns id="9" subpages="" canonical="MediaWiki talk" xml:space="preserve">MediaWiki talk</ns> <ns id="10" canonical="Template" xml:space="preserve">Template</ns> <ns id="11" subpages="" canonical="Template talk" xml:space="preserve">Template talk</ns> <ns id="12" canonical="Help" xml:space="preserve">Help</ns> <ns id="13" subpages="" canonical="Help talk" xml:space="preserve">Help talk</ns> <ns id="14" canonical="Category" xml:space="preserve">Category</ns> <ns id="15" subpages="" canonical="Category talk" xml:space="preserve">Category talk</ns> </namespaces> <namespacealiases> <ns id="6" xml:space="preserve">Image</ns> <ns id="7" xml:space="preserve">Image talk</ns> </namespacealiases> <statistics pages="8930" articles="3406" views="87415" edits="15885" images="760" users="264" activeusers="1" admins="2" jobs="0" /> </query> </api>
[/QUOTE]
This is my current "lockwiki_family.py" file (I removed the commented out lines):
[QUOTE]
# -*- coding: utf-8 -*- # REQUIRED import config, family, urllib # REQUIRED
class Family(family.Family): # REQUIRED def __init__(self): # REQUIRED family.Family.__init__(self) # REQUIRED self.name = 'Locksmith Wiki Knowledge Base' # REQUIRED; replace with actual name
self.langs = { # REQUIRED 'en': 'www.locksmithwiki.com', # Include one line for each wiki in family }
self.namespaces[4] = { '_default': [u'Locksmith Wiki Knowledge Base', self.namespaces[4]['_default']], # REQUIRED }
self.namespaces[-2] = { 'en': 'Media' } self.namespaces[-1] = { 'en': 'Special' } self.namespaces[1] = { 'en': 'Talk' } self.namespaces[2] = { 'en': 'User' } self.namespaces[3] = { 'en': 'User talk' } self.namespaces[4] = { 'en': 'Locksmith Wiki Knowledge Base' } self.namespaces[5] = { 'en': 'Locksmith Wiki Knowledge Base talk' } self.namespaces[6] = { 'en': 'File' } self.namespaces[7] = { 'en': 'File talk' } self.namespaces[8] = { 'en': 'MediaWiki' } self.namespaces[9] = { 'en': 'MediaWiki talk' } self.namespaces[10] = { 'en': 'Template' } self.namespaces[11] = { 'en': 'Template talk' } self.namespaces[12] = { 'en': 'Help' } self.namespaces[13] = { 'en': 'Help talk' } self.namespaces[14] = { 'en': 'Category' } self.namespaces[15] = { 'en': 'Category talk' }
self.content_id = "bodyContent"
self.interwiki_text_separator = '\r\n\r\n'
self.interwiki_putfirst = {}
self.interwiki_putfirst_doubled = {}
self.interwiki_forward = None
self.obsolete = {}
self.category_attop = []
self.category_on_one_line = []
self.category_text_separator = '\r\n\r\n'
self.categories_last = []
def protocol(self, code): """ Can be overridden to return 'https'. Other protocols are not supported. """ return 'http'
def scriptpath(self, code): """The prefix used to locate scripts on this wiki.
This is the value displayed when you enter {{SCRIPTPATH}} on a wiki page (often displayed at [[Help:Variables]] if the wiki has copied the master help page correctly).
The default value is the one used on Wikimedia Foundation wikis, but needs to be overridden in the family file for any wiki that uses a different value.
""" return '/lockwiki'
def apipath(self, code): return '%s/api.php' % self.scriptpath(code)
def version(self, code): # Replace with the actual version being run on your wiki return '1.15.1'
def code2encoding(self, code): """Return the encoding for a specific language wiki""" return 'utf-8'
[/QUOTE]
When I go to login.py the screen flashes and closes within a second.
I did have
self.name = 'Locksmith Wiki Knowledge Base' # REQUIRED; replace with actual name and self.namespaces[4] = { '_default': [u'Locksmith Wiki Knowledge Base', self.namespaces[4]['_default']], # REQUIRED }
set as
self.name = 'lockwiki' # REQUIRED; replace with actual name and self.namespaces[4] = { '_default': [u'lockwiki', self.namespaces[4]['_default']], # REQUIRED }
and that let me at least enter my password, but the screen closed so quickly I couldn't read the several lines of type that flashed up shortly afterwards.
What am I doing wrong here?
Dnia 10.11.2009 Gilles Deacur tronno22556@gmail.com napisał/a:
I posted this yesterday about 15 hours ago and don't see it yet, so I'm
Here is the file that almost works for me:
---->8------ CUT HERE ----- # -*- coding: utf-8 -*-
__version__ = '$Id$'
import family
# The locksmithwiki family
class Family(family.Family): def __init__(self): family.Family.__init__(self) self.name = 'lockwiki' self.langs = { 'en': 'www.locksmithwiki.com', } self.namespaces[4] = { '_default': [u'Locksmith Wiki Knowledge Base', self.namespaces[4]['_default']], # REQUIRED } self.namespaces[4] = { '_default': [u'Locksmith Wiki Knowledge Base talk', self.namespaces[5]['_default']], # REQUIRED }
def scriptpath(self, code): return '/lockwiki'
def version(self, code): return '1.15.1'
def nicepath(self, code): return "%s/" % self.path(self, code)
---->8------ CUT HERE -----
While pasting above file please be extremely careful about spaces.
However, your API does no seem to work because every response includes a Byte Order Mark. Please see:
http://www.mediawiki.org/wiki/Manual:Errors_and_Symptoms#Warning:_Cannot_mod...
You need to probably unpack your mediawiki files using some sane tool.
--Marcin
Thank you for the code.
I'm not sure exactly what response you got, but this is what login.py is shooting back at me:
[QUOTE] Logging in to lockwiki:en as XXXXXX Error downloading data: no JSON object could be decoded Request en:/lockwiki/api.php?action=query&format=json&meta=userinfo&uiprop=block info Retrying [/QUOTE]
I'm very unfamiliar with Byte Order Mark. Is this actually the problem based on the screen output here?
On Wed, Nov 11, 2009 at 11:04 PM, Marcin Cieslak saper@saper.info wrote:
Dnia 10.11.2009 Gilles Deacur tronno22556@gmail.com napisał/a:
I posted this yesterday about 15 hours ago and don't see it yet, so I'm
Here is the file that almost works for me:
---->8------ CUT HERE ----- # -*- coding: utf-8 -*-
__version__ = '$Id$'
import family
# The locksmithwiki family
class Family(family.Family): def __init__(self): family.Family.__init__(self) self.name = 'lockwiki' self.langs = { 'en': 'www.locksmithwiki.com', } self.namespaces[4] = { '_default': [u'Locksmith Wiki Knowledge Base', self.namespaces[4]['_default']], # REQUIRED } self.namespaces[4] = { '_default': [u'Locksmith Wiki Knowledge Base talk', self.namespaces[5]['_default']], # REQUIRED }
def scriptpath(self, code): return '/lockwiki'
def version(self, code): return '1.15.1'
def nicepath(self, code): return "%s/" % self.path(self, code)
---->8------ CUT HERE -----
While pasting above file please be extremely careful about spaces.
However, your API does no seem to work because every response includes a Byte Order Mark. Please see:
http://www.mediawiki.org/wiki/Manual:Errors_and_Symptoms#Warning:_Cannot_mod...
You need to probably unpack your mediawiki files using some sane tool.
--Marcin
Pywikipedia-l mailing list Pywikipedia-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/pywikipedia-l
Dnia 12.11.2009 Gilles Deacur tronno22556@gmail.com napisał/a:
I'm very unfamiliar with Byte Order Mark. Is this actually the problem based on the screen output here?
Your api.php script returns strange output with the Byte Order Mark. Please read further on Wikipedia or somewhere about what it is and why it is wrong to use that.
I don't think that your Mediawiki installation will work as expected.
You need to unpack MediaWiki files and not touch them with Windows text editing tools like notepad or similar.
This is not a problem of your bot, it's the problem of your wiki.
Once this is fixed we can have a look further.
--Marcin