jenkins-bot submitted this change.
[IMPR] add Server414Error in reflink.py and close file
Changes:
- catch also Server414Error so that the bot does not crash.
- close listof404pages file after reading.
Bug: T266000
Change-Id: I6e7361ac8716954967bf959221b2dd922751ce1f
---
M scripts/reflinks.py
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/scripts/reflinks.py b/scripts/reflinks.py
index c0aa235..e974a39 100755
--- a/scripts/reflinks.py
+++ b/scripts/reflinks.py
@@ -495,8 +495,8 @@
def setup(self):
"""Read dead links from file."""
try:
- self.dead_links = codecs.open(
- listof404pages, 'r', 'latin_1').read()
+ with codecs.open(listof404pages, 'r', 'latin_1') as f:
+ self.dead_links = f.read()
except IOError:
raise NotImplementedError(
'404-links.txt is required for reflinks.py\n'
@@ -614,6 +614,7 @@
IOError,
httplib.error,
pywikibot.FatalServerError,
+ pywikibot.Server414Error,
pywikibot.Server504Error) as e:
pywikibot.output("Can't retrieve page {} : {}"
.format(ref.url, e))
To view, visit change 635303. To unsubscribe, or for help writing mail filters, visit settings.