wikiteam icon indicating copy to clipboard operation
wikiteam copied to clipboard

[Newbie] TypeError: __init__() got an unexpected keyword argument 'scheme'

Open losershutin opened this issue 3 years ago • 7 comments

I'm completely new to using Python programs, so I might be doing something completely wrong. I have nothing else to add except my Command Prompt log. I'm using Windows, by the way.

Analysing https://trollpasta.miraheze.org/w/api.php Trying generating a new dump into a new directory... Loading page titles from namespaces = all Excluding titles from namespaces = None 28 namespaces found Retrieving titles in the namespace 0 Traceback (most recent call last): File "dumpgenerator.py", line 2569, in main() File "dumpgenerator.py", line 2561, in main createNewDump(config=config, other=other) File "dumpgenerator.py", line 2126, in createNewDump getPageTitles(config=config, session=other['session']) File "dumpgenerator.py", line 391, in getPageTitles for title in titles: File "dumpgenerator.py", line 261, in getPageTitlesAPI site = mwclient.Site(apiurl.netloc, apiurl.path.replace("api.php", ""), scheme=apiurl.scheme) TypeError: init() got an unexpected keyword argument 'scheme'

losershutin avatar Apr 09 '21 07:04 losershutin

Il 09/04/21 10:49, losershutin ha scritto:

I'm completely new to using Python programs, so I might be doing something completely wrong.

What version of mwclient have you installed?

nemobis avatar Apr 09 '21 11:04 nemobis

What version of mwclient have you installed?

I have mwclient 0.6.5 installed.

losershutin avatar Apr 09 '21 11:04 losershutin

Il 09/04/21 14:24, losershutin ha scritto:

I have mwclient 0.6.5 installed.

That's ancient, released in 2011. You could test with different versions and let us know what works, or send a patch to support such ancient versions of the library, or use an older version of dumpgenerator.

nemobis avatar Apr 11 '21 09:04 nemobis

I faced the same issue due to the deprecation of Python 2.7 in FreeBSD; the one I found was mwlib 0.9.3.

I got it working by modifying the end of the line starting def __init__ in /usr/local/lib/python2.7/site-packages/mwclient/client.py to end with scheme='https'): You may not have the same path to the file, but if you can find it, it might work for you.

If the scheme you have to use is actually http you may want to modify the line scheme = 'https' in def raw_call as well.

I also commented out from requests_oauthlib import OAuth1 because I couldn't be bothered to get all OAuth libraries and they did not seem to be required for a simple download.

Obviously, what nemobis suggests is better, but the above may be faster.

GreenReaper avatar May 09 '21 12:05 GreenReaper

I could also remove this scheme "guessing" from master, but at the time it was the only way I managed to archive a few hundreds wikis which were on record with the wrong scheme. It might be unnecessary if someone improved checkalive.py instead, to make a list of API URLs in the correct scheme.

nemobis avatar May 09 '21 12:05 nemobis

I've been trying to get this working with EditThis. mwclient only supports MediaWiki 1.16 and upwards in latest, while EditThis runs MediaWiki 1.15.

So, since the last mwclient that supports MediaWiki 1.15 was 0.6.5, released in 2011, I've been having trouble getting it to work with the latest dumpgenerator.

When was the scheme stuff implemented? @GreenReaper's solution does not work as 0.6.5 is much older than 0.9.3, so I'm curious what version of dumpgenerator I should be using with mwclient 0.6.5.

WAUthethird avatar Aug 03 '21 21:08 WAUthethird

mwclient only supports MediaWiki 1.16 and upwards in latest

That's a different matter. We probably need to pin a previous version or avoid using mwclient if we can't use it any more for older wikis...

nemobis avatar Nov 15 '21 21:11 nemobis