def _build_update_list(): update_items = [] if not munki.munkiUpdatesContainAppleItems(): apple_updates = getAppleUpdates() apple_update_items = apple_updates.get('AppleUpdates', []) for item in apple_update_items: item['developer'] = u'Apple' item['status'] = u'will-be-installed' update_items.extend(apple_update_items) install_info = getInstallInfo() managed_installs = install_info.get('managed_installs', []) for item in managed_installs: item['status'] = u'will-be-installed' update_items.extend(managed_installs) removal_items = install_info.get('removals', []) for item in removal_items: item['status'] = u'will-be-removed' # TO-DO: handle the case where removal detail is suppressed update_items.extend(removal_items) # use our list to make UpdateItems update_list = [UpdateItem(item) for item in update_items] # sort it and return it return sorted(update_list, key=itemgetter('due_date_sort', 'restart_sort', 'developer_sort', 'size_sort'))
def _build_update_list(): update_items = [] if not munki.munkiUpdatesContainAppleItems(): apple_updates = getAppleUpdates() apple_update_items = apple_updates.get('AppleUpdates', []) for item in apple_update_items: item['developer'] = u'Apple' item['status'] = u'will-be-installed' update_items.extend(apple_update_items) install_info = getInstallInfo() managed_installs = install_info.get('managed_installs', []) for item in managed_installs: item['status'] = u'will-be-installed' update_items.extend(managed_installs) removal_items = install_info.get('removals', []) for item in removal_items: item['status'] = u'will-be-removed' # TO-DO: handle the case where removal detail is suppressed update_items.extend(removal_items) # use our list to make UpdateItems update_list = [UpdateItem(item) for item in update_items] # sort it and return it return sorted(update_list, key=itemgetter( 'due_date_sort', 'restart_sort', 'developer_sort', 'size_sort'))
def updatesContainNonUserSelectedItems(): '''Does the list of updates contain items not selected by the user?''' if not munki.munkiUpdatesContainAppleItems() and getAppleUpdates(): # available Apple updates are not user selected return True install_info = getInstallInfo() install_items = install_info.get('managed_installs', []) removal_items = install_info.get('removals', []) filtered_installs = [item for item in install_items if item['name'] not in user_install_selections] if filtered_installs: return True filtered_uninstalls = [item for item in removal_items if item['name'] not in user_removal_selections] if filtered_uninstalls: return True return False
def getAvailableUpdates(self): updatelist = [] installinfo = munki.getInstallInfo() munki_updates_contain_apple_items = \ munki.munkiUpdatesContainAppleItems() if installinfo: updatelist.extend(installinfo.get('managed_installs', [])) if not munki_updates_contain_apple_items: appleupdates = munki.getAppleUpdates() updatelist.extend(appleupdates.get("AppleUpdates", [])) for update in updatelist: force_install_after_date = update.get( 'force_install_after_date') if force_install_after_date: # insert installation deadline into description local_date = munki.discardTimeZoneFromDate( force_install_after_date) date_str = munki.stringFromDate(local_date) forced_date_text = NSLocalizedString( u"This item must be installed by ", None) description = update["description"] # prepend deadline info to description. This will fail if # the description is HTML... update["description"] = (forced_date_text + date_str + "\n\n" + description) if installinfo.get("removals"): removallist = installinfo.get("removals") restartNeeded = False logoutNeeded = False showRemovalDetail = munki.getRemovalDetailPrefs() for item in removallist: restartAction = item.get("RestartAction") if restartAction in ["RequireRestart", "RecommendRestart"]: restartNeeded = True if restartAction in ["RequireLogout", "RecommendLogout"]: logoutNeeded = True if showRemovalDetail: item["display_name"] = ( (item.get("display_name") or item.get("name", "")) + NSLocalizedString(u" (will be removed)", None)) item["description"] = NSLocalizedString( u"This item will be removed.", None) updatelist.append(item) if not showRemovalDetail: row = {} row["display_name"] = NSLocalizedString( u"Software removals", None) row["version"] = "" row["description"] = NSLocalizedString( u"Scheduled removal of managed software.", None) if restartNeeded: row["RestartAction"] = "RequireRestart" elif logoutNeeded: row["RestartAction"] = "RequireLogout" updatelist.append(row) if updatelist: #self._sortUpdateList(updatelist) self._listofupdates = updatelist self.enableUpdateNowBtn_(YES) #self.performSelector_withObject_afterDelay_( # "enableUpdateNowBtn:", YES, 4) self.getOptionalInstalls() else: self._listofupdates = [] self.update_view_controller.updateNowBtn.setEnabled_(NO) self.getOptionalInstalls()