mirror of
https://github.com/munki/munki.git
synced 2026-04-22 04:28:21 -05:00
Track issues that prevent installation and store them so MSC.app can display them and/or give better feedback. Also fixes issue 346.
This commit is contained in:
@@ -819,8 +819,6 @@ class OptionalItem(GenericItem):
|
||||
else:
|
||||
self['category_and_developer'] = self['category']
|
||||
self['dependent_items'] = dependentItems(self['name'])
|
||||
if not self.get('status'):
|
||||
self['status'] = self._get_status()
|
||||
if self.get('installer_item_size'):
|
||||
self['size'] = munki.humanReadable(self['installer_item_size'])
|
||||
elif self.get('installed_size'):
|
||||
@@ -829,7 +827,11 @@ class OptionalItem(GenericItem):
|
||||
self['size'] = u''
|
||||
self['detail_link'] = u'detail-%s.html' % quote(self['name'])
|
||||
self['hide_cancel_button'] = u''
|
||||
|
||||
if not self.get('note'):
|
||||
self['note'] = self._get_note_from_problem_items()
|
||||
if not self.get('status'):
|
||||
self['status'] = self._get_status()
|
||||
|
||||
def _get_status(self):
|
||||
'''Calculates initial status for an item and also sets a boolean
|
||||
if a updatecheck is needed'''
|
||||
@@ -875,6 +877,7 @@ class OptionalItem(GenericItem):
|
||||
# 'Download failed (%s)' % errmsg
|
||||
# 'Can\'t install %s because: %s', manifestitemname, errmsg
|
||||
# 'Insufficient disk space to download and install.'
|
||||
# and others in the future
|
||||
#
|
||||
# for now we prevent install this way
|
||||
status = u'unavailable'
|
||||
@@ -892,6 +895,15 @@ class OptionalItem(GenericItem):
|
||||
status = u'not-installed'
|
||||
return status
|
||||
|
||||
def _get_note_from_problem_items(self):
|
||||
'''Checks InstallInfo's problem_items for any notes for self that might
|
||||
give feedback why this item can't be downloaded or installed'''
|
||||
problem_items = getInstallInfo().get('problem_items', [])
|
||||
# check problem items for any whose name matches the name of the current item
|
||||
matches = [item for item in problem_items if item['name'] == self['name']]
|
||||
if len(matches):
|
||||
return matches[0].get('note', '')
|
||||
|
||||
def description(self):
|
||||
'''return a full description for the item, inserting dynamic data
|
||||
if needed'''
|
||||
@@ -910,6 +922,10 @@ class OptionalItem(GenericItem):
|
||||
"If this situation continues, contact your systems administrator.",
|
||||
u"Removal Error message")
|
||||
start_text += '<span class="warning">%s</span><br/><br/>' % filtered_html(warning_text)
|
||||
if self.get('note'):
|
||||
# some other note. Probably won't be localized.
|
||||
warning_text = NSLocalizedString(self['note'], None)
|
||||
start_text += '<span class="warning">%s</span><br/><br/>' % filtered_html(warning_text)
|
||||
if self.get('dependent_items'):
|
||||
start_text += self.dependency_description()
|
||||
|
||||
|
||||
@@ -1672,7 +1672,7 @@ def updateAvailableLicenseSeats(installinfo):
|
||||
|
||||
|
||||
def processInstall(manifestitem, cataloglist, installinfo):
|
||||
"""Processes a manifest item. Determines if it needs to be
|
||||
"""Processes a manifest item for install. Determines if it needs to be
|
||||
installed, and if so, if any items it is dependent on need to
|
||||
be installed first. Installation detail is added to
|
||||
installinfo['managed_installs']
|
||||
@@ -1763,17 +1763,23 @@ def processInstall(manifestitem, cataloglist, installinfo):
|
||||
if not success:
|
||||
dependenciesMet = False
|
||||
|
||||
if not dependenciesMet:
|
||||
munkicommon.display_warning('Didn\'t attempt to install %s '
|
||||
'because could not resolve all '
|
||||
'dependencies.', manifestitemname)
|
||||
return False
|
||||
|
||||
iteminfo = {}
|
||||
iteminfo['name'] = item_pl.get('name', '')
|
||||
iteminfo['display_name'] = item_pl.get('display_name', iteminfo['name'])
|
||||
iteminfo['description'] = item_pl.get('description', '')
|
||||
|
||||
if not dependenciesMet:
|
||||
munkicommon.display_warning('Didn\'t attempt to install %s '
|
||||
'because could not resolve all '
|
||||
'dependencies.', manifestitemname)
|
||||
# add information to managed_installs so we have some feedback
|
||||
# to display in MSC.app
|
||||
iteminfo['installed'] = False
|
||||
iteminfo['note'] = ('Can\'t install %s because could not resolve all '
|
||||
'dependencies.' % iteminfo['display_name'])
|
||||
installinfo['managed_installs'].append(iteminfo)
|
||||
return False
|
||||
|
||||
installed_state = installedState(item_pl)
|
||||
if installed_state == 0:
|
||||
munkicommon.display_detail('Need to install %s', manifestitemname)
|
||||
@@ -1821,8 +1827,7 @@ def processInstall(manifestitem, cataloglist, installinfo):
|
||||
# required keys
|
||||
iteminfo['installer_item'] = filename
|
||||
iteminfo['installed'] = False
|
||||
iteminfo['version_to_install'] = item_pl.get(
|
||||
'version','UNKNOWN')
|
||||
iteminfo['version_to_install'] = item_pl.get('version', 'UNKNOWN')
|
||||
|
||||
# we will ignore the unattended_install key if the item needs a
|
||||
# restart or logout...
|
||||
@@ -2995,7 +3000,6 @@ def check(client_id='', localmanifestpath=None):
|
||||
for item in installinfo['removals']
|
||||
if item.get('installed') == False]
|
||||
|
||||
|
||||
if os.path.exists(selfservemanifest):
|
||||
# for any item in the managed_uninstalls in the self-serve
|
||||
# manifest that is not installed, we should remove it from
|
||||
@@ -3035,6 +3039,9 @@ def check(client_id='', localmanifestpath=None):
|
||||
installinfo['removals'] = \
|
||||
[item for item in installinfo['removals']
|
||||
if item.get('installed')]
|
||||
|
||||
# also record problem items so MSC.app can provide feedback
|
||||
installinfo['problem_items'] = problem_items
|
||||
|
||||
# download display icons for optional installs
|
||||
# and active installs/removals
|
||||
|
||||
Reference in New Issue
Block a user