Munki shouldn't crash when attempting to load a non-existent dist file while detecting blocking apps.

Fixes the following traceback:
    File '/usr/local/munki/munkilib/appleupdates.py', line 808, in GetSoftwareUpdateInfo
       blocking_apps = self.GetBlockingApps(update['productKey'])
          File '/usr/local/munki/munkilib/appleupdates.py', line 423, in GetBlockingApps
             dom = minidom.parse(distfile)
                File '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/dom/minidom.py', line 1914, in parse
                   File '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/dom/expatbuilder.py', line 922, in parse
                      IOError: [Errno 2] No such file or directory: u'/tmp/munki_swupd_cache/content/downloads/15/38/041-7414/ldfmzmn6psq7re395jmalnyba8ge3xa4cj/041-7414.English.dist'
This commit is contained in:
Justin McWilliams
2012-11-27 16:23:20 -05:00
parent 3903e89fc3
commit fe3c76dbdb

View File

@@ -120,7 +120,7 @@ class AppleUpdates(object):
def __init__(self):
self._managed_install_dir = munkicommon.pref('ManagedInstallDir')
real_cache_dir = os.path.join(self._managed_install_dir, 'swupd')
if os.path.exists(real_cache_dir):
if not os.path.isdir(real_cache_dir):
@@ -139,15 +139,15 @@ class AppleUpdates(object):
if os.path.exists(self.cache_dir):
# there should not be a file or directory at that path!
# move it
new_name = os.path.join('/tmp',
('munki_swupd_cache_moved_%s' %
new_name = os.path.join('/tmp',
('munki_swupd_cache_moved_%s' %
time.strftime('%Y.%m.%d.%H.%M.%S')))
os.rename(self.cache_dir, new_name)
os.symlink(real_cache_dir, self.cache_dir)
except (OSError, IOError), err:
# error in setting up the cache directories
raise Error('Could not configure cache directory: %s' % err)
self.temp_cache_dir = os.path.join(self.cache_dir, 'mirror')
self.local_catalog_dir = os.path.join(
self.cache_dir, LOCAL_CATALOG_DIR_REL_PATH)
@@ -391,7 +391,7 @@ class AppleUpdates(object):
return list_of_localizations[0]
def GetDistributionForProductKey(self, product_key):
'''Returns the path to a distibution file from the local cache for the
'''Returns the path to a distibution file from the local cache for the
given product_key.'''
try:
catalog = FoundationPlist.readPlist(self.local_catalog_path)
@@ -421,7 +421,7 @@ class AppleUpdates(object):
try:
dom = minidom.parse(distfile)
except expat.ExpatError:
except (expat.ExpatError, IOError):
return []
must_close_app_ids = []
@@ -1124,7 +1124,7 @@ class AppleUpdates(object):
last_result_code = self.GetSoftwareUpdatePref('LastResultCode') or 0
if last_result_code > 2:
retcode = last_result_code
if results['failures']:
return 1