Update local client resources after managedsoftwareupdate signals it has completed a run

This commit is contained in:
Greg Neagle
2014-05-13 15:11:08 -07:00
parent 50cf42f9ed
commit 6ad408b932
2 changed files with 30 additions and 14 deletions
@@ -250,6 +250,8 @@ class MSUMainWindowController(NSWindowController):
MunkiItems.reset()
# recache SelfService choices
self.cached_self_service = MunkiItems.SelfService()
# copy any new custom client resources
msulib.get_custom_resources()
# pending updates may have changed
self._alertedUserToOutstandingUpdates = False
# what page are we currently viewing?
@@ -54,6 +54,32 @@ def getInstallAllButtonTextForCount(count):
return NSLocalizedString(u"Update All", u"Update All button title")
def get_custom_resources():
'''copies custom resources into our html dir'''
if not _html_dir:
return
managed_install_dir = munki.pref('ManagedInstallDir')
source_path = os.path.join(managed_install_dir, 'client_resources/custom.zip')
if os.path.exists(source_path):
dest_path = os.path.join(_html_dir, 'custom')
if os.path.exists(dest_path):
try:
shutil.rmtree(dest_path)
except (OSError, IOError), err:
NSLog('Error clearing %s: %s' % (dest_path, err))
os.mkdir(dest_path)
archive = ZipFile(source_path)
archive_files = archive.namelist()
# sanity checking in case the archive is not built correctly
files_to_extract = [filename for filename in archive_files
if filename.startswith('resources/')
or filename.startswith('templates/')]
if not files_to_extract:
NSLog('Invalid client resources archive.')
for filename in files_to_extract:
archive.extract(filename, dest_path)
def html_dir():
'''sets up our local html cache directory'''
global _html_dir
@@ -88,18 +114,6 @@ def html_dir():
os.symlink(source_path, link_path)
# unzip any custom client resources
source_path = os.path.join(managed_install_dir, 'client_resources/custom.zip')
if os.path.exists(source_path):
dest_path = os.path.join(_html_dir, 'custom')
os.mkdir(dest_path)
archive = ZipFile(source_path)
archive_files = archive.namelist()
# sanity checking in case the archive is not built correctly
files_to_extract = [filename for filename in archive_files
if filename.startswith('resources/')
or filename.startswith('templates/')]
if not files_to_extract:
NSLog('Invalid client resources archive.')
for filename in files_to_extract:
archive.extract(filename, dest_path)
get_custom_resources()
return _html_dir