Permalink
Browse files

Wrap parsing of dist file in a try/except block so we don't get an un…

…handled exception if the XML is invalid because of a partial or corrupt download (or Apple error).
  • Loading branch information...
1 parent 4b73a40 commit c26918cd37b8b67d98ca84c14da14abde15b8288 @gregneagle gregneagle committed Jul 17, 2012
Showing with 8 additions and 1 deletion.
  1. +8 −1 code/repo_sync
View
9 code/repo_sync
@@ -103,7 +103,12 @@ def parseSUdist(filename):
su_name = ""
title = ""
- dom = minidom.parse(filename)
+ try:
+ dom = minidom.parse(filename)
+ except ExpatError:
+ reposadocommon.print_stderr(
+ 'Invalid XML in %s', filename)
+ return None
choice_elements = dom.getElementsByTagName("choice")
if choice_elements:
@@ -631,6 +636,8 @@ def sync(fast_scan=False, download_packages=True):
if preferred_dist:
dist = parseSUdist(preferred_dist)
+ if not dist:
+ continue
products[product_key]['title'] = dist['title']
products[product_key]['version'] = dist['version']
products[product_key]['size'] = str(size)

0 comments on commit c26918c

Please sign in to comment.