Last modified: 2014-11-16 01:44:05 UTC
When calling any script with the -help argument to see the parameters it can handle, the bot makes a call to the api of the default configured wiki. I noticed it because my default configured wiki is a test wiki hosted locally, and I have the webserver stopped when I don't need it running. When I need to run the bot, I manually specify -family:WHATEVER Under that circumstances, every attempt to run -help on any script causes an error because the default configured wiki-family is not accessible: $ python pwb.py replace.py -help > ERROR: Traceback (most recent call last): > File "/path/pywikibot/data/api.py", line 341, in submit > body=paramstring) > File "/path/pywikibot/comms/http.py", line 184, in request > raise request.data > error: [Errno 111] Connection refused > > WARNING: Waiting 5 seconds before retrying. > ^CTraceback (most recent call last): > File "pwb.py", line 171, in <module> > run_python_file(fn, argv, argvu) > File "pwb.py", line 69, in run_python_file > exec(compile(source, filename, "exec"), main_mod.__dict__) > File "scripts/replace.py", line 685, in <module> > main() > File "scripts/replace.py", line 483, in main > local_args = pywikibot.handleArgs(*args) > File "/path/pywikibot/bot.py", line 666, in handleArgs > init_handlers() > File "/path/pywikibot/bot.py", line 248, in init_handlers > writelogheader() > File "/path/pywikibot/bot.py", line 318, in writelogheader > log(u'SITE VERSION: %s' % unicode(site.live_version())) > File "/path/pywikibot/site.py", line 1877, in live_version > expiry=0 if force else 1) > File "/path/pywikibot/site.py", line 1097, in get > preloaded = self._get_general(key, expiry) > File "/path/pywikibot/site.py", line 1043, in _get_general > default_info = self._get_siteinfo(props, expiry) > File "/path/pywikibot/site.py", line 967, in _get_siteinfo > siprop='|'.join(props)).submit() > File "/path/pywikibot/data/api.py", line 580, in submit > self._data = super(CachedRequest, self).submit() > File "/path/pywikibot/data/api.py", line 358, in submit > self.wait() > File "/path/pywikibot/data/api.py", line 469, in wait > time.sleep(self.retry_wait) > KeyboardInterrupt > <type 'exceptions.KeyboardInterrupt'> Of course, it works when I have apache running, but such connections seem unnecessary when the bot doesn't have to run anything.
Indeed. I was going to raise this bug myself, as it is preventing automated testing of the scripts before code review (as the WMF test boxes are not supposed to make network connections). https://gerrit.wikimedia.org/r/#/c/154242/8..9/tests/script_tests.py,unified In addition to disabling connecting to the wiki for '-help', we should offer to disable that call to site.live_version() in the startup sequence for _all_ commands. I did a partial solution in https://gerrit.wikimedia.org/r/137009 , but there is still more unnecessary network activity during startup.
Change 157799 had a related patch set uploaded by John Vandenberg: Remove user messages check during startup https://gerrit.wikimedia.org/r/157799
Change 166583 had a related patch set uploaded by John Vandenberg: Dont load site at startup to log site version https://gerrit.wikimedia.org/r/166583
Change 157799 merged by jenkins-bot: Remove user messages check during startup https://gerrit.wikimedia.org/r/157799
One merged; one more to go.
Change 166583 merged by jenkins-bot: Dont load site at startup to log site version https://gerrit.wikimedia.org/r/166583