WikiTeam / wikiteam

Tools for downloading and preserving wikis. We archive wikis, from Wikipedia to tiniest wikis. As of 2024, WikiTeam has preserved more than 600,000 wikis.
https://github.com/WikiTeam
GNU General Public License v3.0
729 stars 149 forks source link

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

Open losershutin opened 3 years ago

losershutin commented 3 years ago

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'

nemobis commented 3 years ago

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?

losershutin commented 3 years ago

What version of mwclient have you installed?

I have mwclient 0.6.5 installed.

nemobis commented 3 years ago

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.

GreenReaper commented 3 years ago

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.

nemobis commented 3 years ago

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.

WAUthethird commented 3 years ago

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.

nemobis commented 3 years ago

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...