Skip to content

Commit

Permalink
Catch APIError exceptions in importblocks.py
Browse files Browse the repository at this point in the history
They occur when the IP is a range is already blocked
  • Loading branch information
Huji authored Jan 7, 2024
1 parent 05a28c7 commit 7f73d6e
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions HujiBot/importblocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,17 @@ def main(self):
blocked = 2
else:
pywikibot.output("Blocking %s" % ip)
self.site.blockuser(
target,
"1 year",
self.blocksummary,
anononly=False,
allowusertalk=True,
)
blocked = 1
try:
self.site.blockuser(
target,
"1 year",
self.blocksummary,
anononly=False,
allowusertalk=True,
)
blocked = 1
except pywikibot.exceptions.APIError:
blocked = 2
row = rowtemplate % (
ip,
ipinfo["cidr"],
Expand Down

0 comments on commit 7f73d6e

Please sign in to comment.