jenkins-bot has submitted this change and it was merged.
Change subject: Don't crash when the bot hits an unknown globe ......................................................................
Don't crash when the bot hits an unknown globe
bug: 64495 Change-Id: Ie261991717bf5876054b30da6fcc6574b35ebe00 --- M pywikibot/__init__.py M pywikibot/exceptions.py M scripts/coordinate_import.py 3 files changed, 16 insertions(+), 5 deletions(-)
Approvals: Ladsgroup: Looks good to me, approved Merlijn van Deen: Looks good to me, but someone else must approve jenkins-bot: Verified
diff --git a/pywikibot/__init__.py b/pywikibot/__init__.py index ff2f61a..f12c128 100644 --- a/pywikibot/__init__.py +++ b/pywikibot/__init__.py @@ -156,7 +156,7 @@ FIXME Should this be in the DataSite object? """ if self.globe not in self.site.globes(): - raise NotImplementedError(u"%s is not supported in Wikibase yet." % self.globe) + raise CoordinateGlobeUnknownException(u"%s is not supported in Wikibase yet." % self.globe) return {'latitude': self.lat, 'longitude': self.lon, 'altitude': self.alt, diff --git a/pywikibot/exceptions.py b/pywikibot/exceptions.py index 7d4ba61..d9e869a 100644 --- a/pywikibot/exceptions.py +++ b/pywikibot/exceptions.py @@ -156,3 +156,11 @@
class UserActionRefuse(Error): pass + + +class WikiBaseError(Error): + pass + + +class CoordinateGlobeUnknownException(WikiBaseError, NotImplementedError): + """ This globe is not implemented yet in either WikiBase or pywikibot """ diff --git a/scripts/coordinate_import.py b/scripts/coordinate_import.py index d732c22..75343d5 100644 --- a/scripts/coordinate_import.py +++ b/scripts/coordinate_import.py @@ -62,11 +62,14 @@ newclaim = pywikibot.Claim(self.repo, u'P625') newclaim.setTarget(coordinate) pywikibot.output(u'Adding %s, %s to %s' % (coordinate.lat, coordinate.lon, item.title())) - item.addClaim(newclaim) + try: + item.addClaim(newclaim)
- source = self.getSource(page.site) - if source: - newclaim.addSource(source, bot=True) + source = self.getSource(page.site) + if source: + newclaim.addSource(source, bot=True) + except CoordinateGlobeUnknownException as e: + pywikibot.output(u'Skipping unsupported globe: %s' % e.args)
def main():
pywikibot-commits@lists.wikimedia.org