Sorry for starting a new thread, I just suscribed. I ran into the same problem today and I think I know how to fix it.
On userlib.py there are several checks before attempting to raise a block def block(self, expiry=None, reason=None, anon=True, noCreate=False, onAutoblock=False, banMail=False, watchUser=False, allowUsertalk=True, reBlock=False, hidename=False): if self._isAutoblock: #This user is probably being queried for purpose of lifting #an autoblock, so can't be blocked. raise AutoblockUser if self.isBlocked() and not reBlock: raise AlreadyBlocked() if not self.site().isAllowed('block', sysop=True): raise UserActionRefuse('You don\'t have permission to block') if not expiry: expiry = pywikibot.input(u'Please enter the expiry time for the block:') if not reason: reason = pywikibot.input(u'Please enter a reason for the block:') if (not self.site().has_api()) or self.site().versionnumber() < 12: return self._blockOld(expiry, reason, anon, noCreate, onAutoblock, banMail, watchUser, allowUsertalk, reBlock) params = { 'action': 'block', 'user': self.name(), 'token': self.site().getToken(self, sysop = True), 'reason': reason, } Notice last check: If the site doesn't have an API or version number is too old, then use a deprecated function to raise the block. We could add a check there as in if self.isAnonymous() or (not self.site().has_api()) or self.site().versionnumber() < 12: so if user is an IP, goes to the old method. However the error would persist. This because the checks above also need a user (user.isBlocked() fails for IP). quick hack would be moving this check at the top: def block(self, expiry=None, reason=None, anon=True, noCreate=False, onAutoblock=False, banMail=False, watchUser=False, allowUsertalk=True, reBlock=False, hidename=False): if self.isAnonymous() or (not self.site().has_api()) or self.site().versionnumber() < 12: return self._blockOld(expiry, reason, anon, noCreate, onAutoblock, banMail, watchUser, allowUsertalk, reBlock) if self._isAutoblock: #This user is probably being queried for purpose of lifting #an autoblock, so can't be blocked. raise AutoblockUser if self.isBlocked() and not reBlock: raise AlreadyBlocked() This way, if user = IP, goes directly into the depprecated ol method and doesn't execute the API-useronly functions. Now running gives :!python bloqueador.py Bloqueando 128.163.142.21 Traceback (most recent call last): File "bloqueador.py", line 86, in <module> main() File "bloqueador.py", line 79, in main bot.run() File "bloqueador.py", line 48, in run self.treat(user) File "bloqueador.py", line 62, in treat user.block(expiry="1 year", reason="Proxy", anon=True) File "/home/drini/pywiki/userlib.py", line 381, in block allowUsertalk, reBlock) TypeError: _blockOld() takes exactly 9 arguments (10 given) It seems code had another bug: _Blockold() doesn't accept a "reBlock" parameter: def _blockOld(self, expiry, reason, anonOnly, noSignup, enableAutoblock, emailBan, watchUser, allowUsertalk): So we fix again the call as if self.isAnonymous() or (not self.site().has_api()) or self.site().versionnumber() < 12: return self._blockOld(expiry, reason, anon, noCreate, onAutoblock, banMail, watchUser, allowUsertalk) It SHOULD work now... except I get a cryptic error: :!python bloqueador.py Bloqueando 128.163.142.21 Getting a token. Note: Your sysop account on wikipedia:es does not have a bot flag. Its edits will be visible in the recent changes. Blocking [[User:128.163.142.21]]... Traceback (most recent call last): File "bloqueador.py", line 86, in <module> main() File "bloqueador.py", line 79, in main bot.run() File "bloqueador.py", line 48, in run self.treat(user) File "bloqueador.py", line 62, in treat user.block(expiry="1 year", reason="Proxy", anon=True) File "/home/drini/pywiki/userlib.py", line 381, in block allowUsertalk) File "/home/drini/pywiki/userlib.py", line 471, in _blockOld raise BlockError userlib.BlockError shell returned 1 Hope it helps Amir, and if you find a solution, please tell since I'm stuck with the same problem Pedro Sánchez http://drini.mx @combinatorica _______________________________________________ Pywikipedia-l mailing list Pywikipedia-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/pywikipedia-l