Revision: 8003 Author: xqt Date: 2010-03-13 16:14:53 +0000 (Sat, 13 Mar 2010)
Log Message: ----------- bugfix for HTTPError 400 loading a lot of user pages at once
Modified Paths: -------------- trunk/pywikipedia/userlib.py trunk/pywikipedia/welcome.py
Modified: trunk/pywikipedia/userlib.py =================================================================== --- trunk/pywikipedia/userlib.py 2010-03-13 13:55:12 UTC (rev 8002) +++ trunk/pywikipedia/userlib.py 2010-03-13 16:14:53 UTC (rev 8003) @@ -553,16 +553,16 @@ users = list(users) # if pages is an iterator, we need to make it a list if len(users) > 1: wikipedia.output(u'Getting %d users data from %s...' % (len(users), site))
- if len(users) > 500: - for urg in range(0, len(users), 500): - if urg == range(0, len(users), 500)[-1]: #latest + if len(users) > 250: # max load prevents HTTPError 400 + for urg in range(0, len(users), 250): + if urg == range(0, len(users), 250)[-1]: #latest k = users[urg:] _GetAllUI(site, k, throttle, force).run() users[urg:] = k else: - k = users[urg:urg + 500] + k = users[urg:urg + 250] _GetAllUI(site, k, throttle, force).run() - users[urg:urg + 500] = k + users[urg:urg + 250] = k else: _GetAllUI(site, users, throttle, force).run()
Modified: trunk/pywikipedia/welcome.py =================================================================== --- trunk/pywikipedia/welcome.py 2010-03-13 13:55:12 UTC (rev 8002) +++ trunk/pywikipedia/welcome.py 2010-03-13 16:14:53 UTC (rev 8003) @@ -673,13 +673,8 @@ # if self._checkQueue: # for nm in self._checkQueue: # yield userlib.User(self.site, nm) - try: - if config.use_api and self.site.versionnumber() >= 13: - x = self.site.api_address() - del x - else: - raise NotImplementedError - except NotImplementedError: + + if not self.site.has_api() or self.site.versionnumber() < 13: for x in self._parseNewUserLogOld(): yield x return @@ -813,7 +808,7 @@ def run(self): while True: welcomed_count = 0 - if globalvar.quick and config.use_api: + if globalvar.quick and self.site.has_api(): us = [x for x in self.parseNewUserLog()] showStatus() try: