def markPendingItemsAsInstalling(self): '''While an install/removal session is happening, mark optional items that are being installed/removed with the appropriate status''' msclog.debug_log('marking pendingItems as installing') install_info = munki.getInstallInfo() items_to_be_installed_names = [item['name'] for item in install_info.get('managed_installs', [])] items_to_be_removed_names = [item['name'] for item in install_info.get('removals', [])] for name in items_to_be_installed_names: # remove names for user selections since we are installing MunkiItems.user_install_selections.discard(name) for name in items_to_be_removed_names: # remove names for user selections since we are removing MunkiItems.user_removal_selections.discard(name) for item in MunkiItems.getOptionalInstallItems(): new_status = None if item['name'] in items_to_be_installed_names: msclog.debug_log('Setting status for %s to "installing"' % item['name']) new_status = u'installing' elif item['name'] in items_to_be_removed_names: msclog.debug_log('Setting status for %s to "removing"' % item['name']) new_status = u'removing' if new_status: item['status'] = new_status self.updateDOMforOptionalItem(item)
def getOptionalInstalls(self): optionalInstalls = [] installinfo = munki.getInstallInfo() if installinfo: optionalInstalls = installinfo.get("optional_installs", []) if optionalInstalls: self._optionalInstalls = optionalInstalls self.update_view_controller.optionalSoftwareBtn.setHidden_(NO) else: self.update_view_controller.optionalSoftwareBtn.setHidden_(YES)
def getAvailableUpdates(self): updatelist = [] installinfo = munki.getInstallInfo() if installinfo: updatelist = installinfo.get("managed_installs", []) 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 showRemovalDetail = munki.getRemovalDetailPrefs() for item in removallist: if item.get("RestartAction") == "RequireRestart" or item.get("RestartAction") == "RecommendRestart": restartNeeded = 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" updatelist.append(row) if updatelist: self._listofupdates = updatelist self.enableUpdateNowBtn_(YES) #self.performSelector_withObject_afterDelay_("enableUpdateNowBtn:", YES, 4) self.getOptionalInstalls() else: appleupdates = munki.getAppleUpdates() if appleupdates: munki.log("MSU", "appleupdates") self._listofupdates = appleupdates.get("AppleUpdates", []) self.update_view_controller.updateNowBtn.setEnabled_(YES) self.update_view_controller.optionalSoftwareBtn.setHidden_(YES) else: self.update_view_controller.updateNowBtn.setEnabled_(NO) self.getOptionalInstalls()
def getAvailableUpdates(self): updatelist = [] installinfo = munki.getInstallInfo() if installinfo: updatelist = installinfo.get("managed_installs", []) if installinfo.get("removals"): removallist = installinfo.get("removals") restartNeeded = False showRemovalDetail = munki.getRemovalDetailPrefs() for item in removallist: if item.get("RestartAction") == "RequireRestart" or item.get("RestartAction") == "RecommendRestart": restartNeeded = 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" updatelist.append(row) if updatelist: self._listofupdates = updatelist self.enableUpdateNowBtn_(YES) #self.performSelector_withObject_afterDelay_("enableUpdateNowBtn:", YES, 4) self.getOptionalInstalls() else: appleupdates = munki.getAppleUpdates() if appleupdates: munki.log("MSU", "appleupdates") self._listofupdates = appleupdates.get("AppleUpdates", []) self.update_view_controller.updateNowBtn.setEnabled_(YES) self.update_view_controller.optionalSoftwareBtn.setHidden_(YES) else: self.update_view_controller.updateNowBtn.setEnabled_(NO) self.getOptionalInstalls()
def getInstallInfo(): if not 'install_info' in _cache: _cache['install_info'] = munki.getInstallInfo() return _cache['install_info']
def getAvailableUpdates(self): updatelist = [] installinfo = munki.getInstallInfo() if installinfo: updatelist = installinfo.get("managed_installs", []) 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 showRemovalDetail = munki.getRemovalDetailPrefs() for item in removallist: if item.get( "RestartAction") == "RequireRestart" or item.get( "RestartAction") == "RecommendRestart": restartNeeded = 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" updatelist.append(row) if updatelist: self._sortUpdateList(updatelist) self._listofupdates = updatelist self.enableUpdateNowBtn_(YES) #self.performSelector_withObject_afterDelay_("enableUpdateNowBtn:", YES, 4) self.getOptionalInstalls() else: appleupdates = munki.getAppleUpdates() if appleupdates: munki.log("MSU", "appleupdates") self._listofupdates = appleupdates.get("AppleUpdates", []) self.update_view_controller.updateNowBtn.setEnabled_(YES) self.update_view_controller.optionalSoftwareBtn.setHidden_(YES) else: self._listofupdates = [] self.update_view_controller.updateNowBtn.setEnabled_(NO) self.getOptionalInstalls()