Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: sitescripts/extensions/utils.py

Issue 29370859: Issue 4767 - Improve error reporting in update_update_manifests (Closed)
Patch Set: For comments 9 and 10 Created Jan. 11, 2017, 11:31 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sitescripts/extensions/utils.py
===================================================================
--- a/sitescripts/extensions/utils.py
+++ b/sitescripts/extensions/utils.py
@@ -23,9 +23,11 @@
import urlparse
import urllib
import xml.dom.minidom as dom
+import sys
from ConfigParser import SafeConfigParser, NoOptionError
from StringIO import StringIO
from sitescripts.utils import get_config
+from xml.parsers.expat import ExpatError
PACKAGE_SUFFIXES = {
'gecko': '.xpi',
@@ -259,16 +261,24 @@
"""
gets download link for a Gecko add-on from the Mozilla Addons site
"""
- url = 'https://services.addons.mozilla.org/en-US/firefox/api/1/addon/%s' % _urlencode(galleryID)
- document = dom.parse(_urlopen(url))
- linkTags = document.getElementsByTagName('install')
- linkTag = linkTags[0] if len(linkTags) > 0 else None
- versionTags = document.getElementsByTagName('version')
- versionTag = versionTags[0] if len(versionTags) > 0 else None
- if linkTag and versionTag and linkTag.firstChild and versionTag.firstChild:
- return (linkTag.firstChild.data, versionTag.firstChild.data)
- else:
- return (None, None)
+ try:
+ url = 'https://services.addons.mozilla.org/en-US/firefox/api/1/addon/%s' % _urlencode(galleryID)
+ document = dom.parse(_urlopen(url))
Vasily Kuznetsov 2017/01/12 11:12:32 Actually we don't need to put the whole block into
+ linkTags = document.getElementsByTagName('install')
+ linkTag = linkTags[0] if len(linkTags) > 0 else None
+ versionTags = document.getElementsByTagName('version')
+ versionTag = versionTags[0] if len(versionTags) > 0 else None
+ if linkTag and versionTag and linkTag.firstChild and versionTag.firstChild:
+ return (linkTag.firstChild.data, versionTag.firstChild.data)
+ else:
+ return (None, None)
+ except ExpatError:
+ page = _urlopen(url)
Vasily Kuznetsov 2017/01/12 11:12:32 This is not a good idea. You're downloading the pa
+ content = document.open()
+ page.close()
+ raise Exception('Error found while parsing xml:\n{0}\nfrom {1} link'
+ .format(content, galleryID))
+
def _getLocalLink(repo):
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld