Manual talk:Pywikibot/2015
Add topicThis page used the Structured Discussions extension to give structured discussions. It has since been converted to wikitext, so the content and history here are only an approximation of what was actually displayed at the time these comments were made. |
![]() Archives
|
---|
mai language on pywikibot
[edit]Today, I tried pywikibot on mai.wikipedia.org but it didn't work. Can you please tell me where I have to define "mai" language in pywikibot? ☆★Sanjeev Kumar (talk) 20:52, 24 February 2015 (UTC)
- user-config.py, usually. Nemo 06:45, 25 February 2015 (UTC)
- I added it in user-config.py file as "usernames['wikipedia']['mai'] = u'sanjeev bot'"
- But it is not working and while running it says:
- and received the error (after entering my password and the new name I wanted for the file):
pywikibot.exceptions.NoSuchSite: Language mai does not exist in family wikipedia</pre> So, I don't understand where should I define it. <font color="green">☆★</font>[[User:संजीव कुमार|<u><font color="Magenta">Sanjeev Kumar</font></u>]] ([[User talk:संजीव कुमार|<font color="blue">talk</font>]]) 18:29, 26 February 2015 (UTC) :::Try updating the Wikipedia family file. [[User:KnightMiner|KnightMiner]] ([[User talk:KnightMiner|t]]/[[Special:Contribs/KnightMiner|c]]) 20:06, 26 February 2015 (UTC) ::::Can you please guide me to instructions page? <font color="green">☆★</font>[[User:संजीव कुमार|<u><font color="Magenta">Sanjeev Kumar</font></u>]] ([[User talk:संजीव कुमार|<font color="blue">talk</font>]]) 17:58, 27 February 2015 (UTC) :::::Well, you have a few choices here. :::::# Update to the latest version of pywikibot, which should contain the updated family file as it is wikimedia :::::# Run the script <code>generate_family_file.py</code>, using the path to the api (<code>https://mai.wikipedia.org/wiki</code> should do it), and the shortname of <code>wikipedia</code>. [[Manual:Pywikibot/Use on third-party wikis#Script to generate family file|This page best describes the process]] [[User:KnightMiner|KnightMiner]] ([[User talk:KnightMiner|t]]/[[Special:Contribs/KnightMiner|c]]) 04:33, 28 February 2015 (UTC) ::::::Thanks KnightMiner, it is resolved. Sorry for responding so late. <font color="green">☆★</font>[[User:संजीव कुमार|<u><font color="Magenta">Sanjeev Kumar</font></u>]] ([[User talk:संजीव कुमार|<font color="blue">talk</font>]]) 09:25, 16 May 2015 (UTC) == Remove dead internal links == Is there a functinality to remove links to non-existent images? Something similar to weblinkchecker.py probably, but for internal links? Thanks. [[User:Wesalius|Wesalius]] ([[User talk:Wesalius|talk]]) 08:39, 15 March 2015 (UTC) :Try the script "image.py". There is no documentation on it here, but within the script it states you simply need to run it with the file name as the first parameter, and it will delink images (or if you provide a second unnamed parameter, it will replace the first image with the second image). [[User:KnightMiner|KnightMiner]] ([[User talk:KnightMiner|t]]/[[Special:Contribs/KnightMiner|c]]) 17:44, 16 March 2015 (UTC) ::Thanks, I will try it out. [[User:Wesalius|Wesalius]] ([[User talk:Wesalius|talk]]) 09:47, 19 March 2015 (UTC) == How to search this manual except its language translations? == Say I wanna know about throttling. If I search [https://www.mediawiki.org/w/index.php?title=Special%3ASearch&profile=default&search=throttle+prefix%3AManual%3APywikibot&fulltext=Search throttle prefix:Manual:Pywikibot] I'll a get many redundant results that are just translations of the English version. (e.g. [[Manual:Pywikibot/Global Options/it]], [[Manual:Pywikibot/imagetransfer.py/ru]], [[Manual:Pywikibot/Global Options/ca]] etc.). Is there a simple way to avoid this? <span style="border-radius:3px;border:solid 2px DodgerBlue;">[[user:دالبا|Dalba]]</span> 6 Ordibehesht 1394/ 05:57, 26 April 2015 (UTC) :You could try and search for "/en" in title. :It's supposed to show your language first, though: [[phabricator:T68829]]. In general this is tracked at [[phabricator:T56832]]. [[User:Nemo_bis|Nemo]] 11:26, 27 April 2015 (UTC) ::Thanks. But it seems that some pages like [[Manual:Pywikibot/login.py]] don't have that "/en" suffix, so they won't appear in the results of [https://www.mediawiki.org/w/index.php?title=Special%3ASearch&profile=default&search=throttle+intitle%3A%2Fen+prefix%3AManual%3APywikibot&fulltext=Search this search]. <span style="border-radius:3px;border:solid 2px DodgerBlue;">[[user:دالبا|Dalba]]</span> 7 Ordibehesht 1394/ 12:33, 27 April 2015 (UTC) :::Indeed... not yet. They will as soon as they are migrated to the new translation system. Most pages on this wiki were migrated, but not 100 %. [[User:Nemo_bis|Nemo]] 20:46, 28 April 2015 (UTC) == [RESOLVED] Error to login == I installed Pywikipedia by these processes: <nowiki>1. svn checkout http://svn.wikimedia.org/svnroot/pywikipedia/trunk/pywikipedia/ pywikipedia</nowiki> <nowiki>2. cd pywikipedia</nowiki> <nowiki>echo "# -*- coding: utf-8 -*-" > user-config.py</nowiki> <nowiki>echo "mylang='xx'" >> user-config.py</nowiki> <nowiki>echo "family='xxxwiki'" >> user-config.py</nowiki> <nowiki>echo "usernames['xxxwiki']['xx']='xxxwiki_bot'" >> user-config.py</nowiki> <nowiki>3. cat > ./families/xxxwiki_family.py <<END_SCRIPT</nowiki> <nowiki># -*- coding: utf-8 -*-</nowiki> <nowiki>import config, family, urllib</nowiki> <nowiki>class Family(family.Family):</nowiki> <nowiki> def __init__(self):</nowiki> <nowiki> family.Family.__init__(self)</nowiki> <nowiki> self.name = 'xxxwiki'</nowiki> <nowiki> self.langs = {</nowiki> <nowiki> 'xx': 'xxxwiki.net',</nowiki> <nowiki> }</nowiki> <nowiki> self.namespaces[2]['xx'] = u'User'</nowiki> <nowiki> self.namespaces[3]['xx'] = u'User_talk'</nowiki> <nowiki> def version(self, code):</nowiki> <nowiki> return "1.24.2"</nowiki> <nowiki> def scriptpath(self, code):</nowiki> <nowiki> return '/w'</nowiki> <nowiki> def path(self, code):</nowiki> <nowiki> return '/w/index.php'</nowiki> <nowiki>END_SCRIPT</nowiki> When I commanded python login.py, However, The error occurs like this: <nowiki>Logging in to xxxwiki:ko as xxwiki_bot via API.</nowiki> <nowiki>Error downloading data: No JSON object could be decoded</nowiki> <nowiki>Request xx:/w/api.php?</nowiki> <nowiki>Retrying in 1 minutes...</nowiki> Version is like this: MediaWiki : 1.24.2 PHP : 5.4.39 (apache) MySQL : 5.0.45-log Python : 2.7.9rc1 [[User:Dlwnsgud0819|Dlwnsgud0819]] ([[User talk:Dlwnsgud0819|talk]]) 13:12, 29 April 2015 (UTC) :We don't use SVN anymore so you're using an old version of code, see [[Manual:Pywikibot/Installation]] for up to date instructions. [[User:Legoktm|Legoktm]] ([[User talk:Legoktm|talk]]) 22:52, 29 April 2015 (UTC) ::Thank you for your answer, but It's same to occur error "No JSON object could be decoded" ::When I use generate_family_file.py in core, the error displays like this: ::<nowiki>Generating family file from http://xxxwiki.net/w</nowiki> ::<nowiki>Traceback (most recent call last):</nowiki> ::<code> <nowiki>File "generate_family_file.py", line 320, in <module></nowiki></code> ::<code> <nowiki>FamilyFileGenerator(*sys.argv[1:]).run()</nowiki></code> ::<code> <nowiki>File "generate_family_file.py", line 93, in run</nowiki></code> ::<code> <nowiki>w = Wiki(self.base_url)</nowiki></code> ::<code> <nowiki>File "generate_family_file.py", line 261, in __init__</nowiki></code> ::<code> <nowiki>self._parse_post_117(wp, fromurl)</nowiki></code> ::<code> <nowiki>File "generate_family_file.py", line 292, in _parse_post_117</nowiki></code> ::<code> <nowiki>info = json.loads(data.read().decode(data.charset))['query']['general']</nowiki></code> ::<code> <nowiki>File "C:\Python27\lib\json\__init__.py", line 338, in loads</nowiki></code> ::<code> <nowiki>return _default_decoder.decode(s)</nowiki></code> ::<code> <nowiki>File "C:\Python27\lib\json\decoder.py", line 366, in decode</nowiki></code> ::<code> <nowiki>obj, end = self.raw_decode(s, idx=_w(s, 0).end())</nowiki></code> ::<code> <nowiki>File "C:\Python27\lib\json\decoder.py", line 384, in raw_decode</nowiki></code> ::<code> <nowiki>raise ValueError("No JSON object could be decoded")</nowiki></code> ::<nowiki>ValueError: No JSON object could be decoded</nowiki> [[User:Dlwnsgud0819|Dlwnsgud0819]] ([[User talk:Dlwnsgud0819|talk]]) 05:44, 30 April 2015 (UTC) :::I resolved the error. :::This error was caused by UTF-8 BOM of LocalSettings.php. [[User:Dlwnsgud0819|Dlwnsgud0819]] ([[User talk:Dlwnsgud0819|talk]]) 06:40, 30 April 2015 (UTC) == ERROR: "CRITICAL: Waiting for 1 network thread(s) to finish." == I changed wiki server and updated mediawiki 1.25.1 from 1.24.2 recently. But, when I use replace.py, It displays error that "CRITICAL: Waiting for 1 network thread(s) to finish". It is no error to login. <s>Could It caused by HHVM? I also replaced PHP 5.4 with HHVM 3.7.1 when I changed wiki server.</s> Well, maybe this is not cause. I tested copy of wiki only connected MariaDB in PHP 5.4 on another pysical server, But the error still displayed. [[User:Dlwnsgud0819|Dlwnsgud0819]] ([[User talk:Dlwnsgud0819|talk]]) 13:04, 2 June 2015 (UTC) :Looks like you have keyboardinterrupted the script, did you? In this case, the warning doesn't matter. <small>[[user talk:xqt|@]]</small>[[user:xqt|xqt]] 09:18, 4 June 2015 (UTC) ::Maybe not. Because I tried also running pywikibot with nohup. ::This is the Full log. ::<code> ::Traceback (most recent call last): ::<code> File "pwb.py", line 239, in <module></code> ::<code> if not main():</code> ::<code> File "pwb.py", line 233, in main</code> ::<code> run_python_file(filename, argv, argvu, file_package)</code> ::<code> File "pwb.py", line 88, in run_python_file</code> ::<code> main_mod.__dict__)</code> ::<code> File "./scripts/replace.py", line 969, in <module></code> ::<code> main()</code> ::<code> File "./scripts/replace.py", line 958, in main</code> ::<code> site)</code> ::<code> File "/root/core/pywikibot/tools/__init__.py", line 1102, in wrapper</code> ::<code> return obj(*__args, **__kw)</code> ::TypeError: __init__() takes at most 10 arguments (11 given) ::CRITICAL: Waiting for 1 network thread(s) to finish. Press ctrl-c to abort ::<type 'exceptions.TypeError'> ::</code> [[User:Dlwnsgud0819|Dlwnsgud0819]] ([[User talk:Dlwnsgud0819|talk]]) 13:50, 4 June 2015 (UTC) :::Are you using core 2.0 or the newest master branch or none of them? <small>[[user talk:xqt|@]]</small>[[user:xqt|xqt]] 13:00, 14 June 2015 (UTC) :::ok, this bug has been fixed in [[gerrit:218344]] for master branch and was backported to 2.0 branch of core. Please update your bot now. <small>[[user talk:xqt|@]]</small>[[user:xqt|xqt]] 13:44, 17 June 2015 (UTC) == Cannot delete broken redirects == I'm sure that the bot account has a permission of deleting pages. I try to use <code>redirect.py broken -always</code>, it output the names of the pages and do nothing. [[User:一個正常人|一個正常人]] ([[User talk:一個正常人|talk]]) 08:35, 22 June 2015 (UTC) :You need the parameter <code>-delete</code>. Otherwise it will only attempt to fix broken redirects (such as ones caused by a move without leaving a redirect). [[User:KnightMiner|KnightMiner]] ([[User talk:KnightMiner|t]]/[[Special:Contribs/KnightMiner|c]]) 21:13, 22 June 2015 (UTC) ::After adding this, it still doesn't work. [[User:一個正常人|一個正常人]] ([[User talk:一個正常人|talk]]) 10:00, 23 June 2015 (UTC) :::I am not sure what else might be the issue. Running the command <code>pwb.py redirect broken -delete -always</code> works for me when using core (though my bot marks pages for deletion rather than directly deleting them, due to lacking administrative rights...) [[User:KnightMiner|KnightMiner]] ([[User talk:KnightMiner|t]]/[[Special:Contribs/KnightMiner|c]]) 20:19, 24 June 2015 (UTC) :::Please run version.py and file the result here or create an new bug task at [[phab:]]. Also give the full command line starting the bot. <small>[[user talk:xqt|@]]</small>[[user:xqt|xqt]] 19:07, 4 July 2015 (UTC) == Timeout handling == I rather have some questions than a problem. * Does anyone know how the pywikibot would handle a timeout? * Has anybody ever experienced a timeout with the pywikibot? * What is the default ttl and the default reaction to a timeout? Thanks [[User:Miles Fides|Miles Fides]] ([[User talk:Miles Fides|talk]]) 12:45, 10 August 2015 (UTC) :I would be interested in the answer to these questions... [[User:Zbmath authorid|Zbmath authorid]] ([[User talk:Zbmath authorid|talk]]) 19:21, 1 November 2018 (UTC) :socket timeout values are 6.05 seconds for connection and 45 seconds for read timeout, see HTTP SETTINGS section in <code>config2.py</code>. If a <code>TimeoutError</code> occurs the scripts retries several times. All Settings can be found in SETTINGS TO AVOID SERVER OVERLOAD section <code>config2.py</code>. <small>[[user talk:xqt|@]]</small>[[user:xqt|xqt]] 14:48, 1 April 2021 (UTC) == Timeout errors == I just ran: <syntaxhighlight lang="bash">python scripts/imagetransfer.py File:Matplotlib_logo.svg -tofamily:lwiki -tolang:en -family:wikipedia -lang:en
ERROR: Traceback (most recent call last):
File "/usr/lib64/python2.7/site-packages/pywikibot-2.0rc1.post2-py2.7.egg/pywikibot/data/api.py", line 1927, in submit
body=body, headers=headers)
File "/usr/lib64/python2.7/site-packages/pywikibot-2.0rc1.post2-py2.7.egg/pywikibot/tools/__init__.py", line 1248, in wrapper
return obj(*__args, **__kw)
File "/usr/lib64/python2.7/site-packages/pywikibot-2.0rc1.post2-py2.7.egg/pywikibot/comms/http.py", line 244, in request
r = fetch(baseuri, method, body, headers, **kwargs)
File "/usr/lib64/python2.7/site-packages/pywikibot-2.0rc1.post2-py2.7.egg/pywikibot/comms/http.py", line 401, in fetch
error_handling_callback(request)
File "/usr/lib64/python2.7/site-packages/pywikibot-2.0rc1.post2-py2.7.egg/pywikibot/comms/http.py", line 318, in error_handling_callback
raise request.data
ReadTimeout: HTTPConnectionPool(host='localhost', port=80): Read timed out. (read timeout=30)
WARNING: Waiting 5 seconds before retrying.
this error message keeps being produced with the final line's time to retry doubling each time. Eventually I get the error message:
We got the following warning(s): exists: File Matplotlib_Logo.svg already exists.
How do I overcome this problem? Fuse809(talk, contribs, email) 00:18, 25 August 2015 (UTC)
Unable to login
[edit]Hi, I am attempting to upgrade to latest version of core on a PC. After downloading and unzipping I try to login using "pwb.py login" but this fails with
ImportError: no module named requests
Python module requests is required.
Try running 'pip install requests'
Attempting to do just that gives error
'pip' is not recognized as an internal or external command, operable program or batch file.
Anyone any ideas as to what the problem is? Keith D (talk) 00:00, 23 September 2015 (UTC)
- You should install the module from here : http://docs.python-requests.org/en/latest/user/install/ ~ Louperivois (talk) 20:59, 7 October 2015 (UTC)
- Hi,
- Ran
python get-pip.py
- which seemed to work OK, but still get
- 'pip' is not recognized as an internal or external command, operable program or batch file.
- when trying to run 'pip install requests'
- Regards
- Keith Keith D (talk) 16:47, 10 October 2015 (UTC)
- Tried running from the directory in which pip appears to be and this gives error.
- Fatal error in launcher: Unable to create process using '"'
- Regards
- Keith Keith D (talk) 17:44, 13 October 2015 (UTC)
- If i remember well, I just downloaded the code in a folder, i opened a terminal in it, and I ran "python setup.py install". Louperivois (talk) 22:46, 16 October 2015 (UTC)
transferbot.py
[edit]When trying to transfer Modules there is error:
{u'error': {u'info': u'The modification you tried to make was aborted by an extension hook', u'code': u'hookaborted', u'help': u'See http://site.org/api.php for API usage'<span></nowiki></span>}} <nowiki>Error saving page Module:Bananas (hookaborted: The modification you tried to make was aborted by an extension hook [help:See http://site.org/api.php for API usage])
Because of this:
text += ("<nowiki><noinclude>\n\n<small>This page was moved from %s. It's "</nowiki> "edit history can be viewed at %s</small></noinclude>" % (page.title(asLink=True, insite=targetpage.site), edithistpage.title(asLink=True, insite=targetpage.site)))</code><code></code><code></code><code></code><code> pywikibot.log("Getting edit history.") historytable = page.getVersionHistoryTable()
pywikibot.log("Putting edit history.") edithistpage.put(historytable, summary=summary)
Extension:Scribunto didn't allow standard wiki markup.
PS Good comment parser. 2nd 09:26, 24 September 2015 (UTC)