def build_updates_page(): '''available/pending updates''' page_name = u'updates.html' # need to consolidate/centralize this flag. Accessing it this way is ugly. if NSApp.delegate().mainWindowController._update_in_progress: return build_update_status_page() item_list = MunkiItems.getEffectiveUpdateList() other_updates = [ item for item in MunkiItems.getOptionalInstallItems() if item['status'] == 'update-available' ] page = {} page['update_rows'] = u'' page['hide_progress_spinner'] = u'hidden' page['hide_other_updates'] = u'hidden' page['install_all_button_classes'] = u'' item_template = get_template('update_row_template.html') if item_list: for item in item_list: escapeAndQuoteCommonFields(item) page['update_rows'] += item_template.safe_substitute(item) elif not other_updates: status_results_template = get_template('status_results_template.html') alert = {} alert['primary_status_text'] = NSLocalizedString( u"Your software is up to date.", u"No Pending Updates primary text") alert['secondary_status_text'] = NSLocalizedString( u"There is no new software for your computer at this time.", u"No Pending Updates secondary text") alert['hide_progress_bar'] = u'hidden' alert['progress_bar_value'] = u'' page['update_rows'] = status_results_template.safe_substitute(alert) count = len(item_list) page['update_count'] = msclib.updateCountMessage(count) page['install_btn_label'] = msclib.getInstallAllButtonTextForCount(count) page['warning_text'] = get_warning_text() page['other_updates_header_message'] = NSLocalizedString( u"Other available updates", u"Other Available Updates label") page['other_update_rows'] = u'' if other_updates: page['hide_other_updates'] = u'' for item in other_updates: escapeAndQuoteCommonFields(item) page['other_update_rows'] += item_template.safe_substitute(item) footer = get_template('footer_template.html', raw=True) generate_page(page_name, 'updates_template.html', page, footer=footer)
def build_updates_page(): '''available/pending updates''' page_name = u'updates.html' # need to consolidate/centralize this flag. Accessing it this way is ugly. if NSApp.delegate().mainWindowController._update_in_progress: return build_update_status_page() item_list = MunkiItems.getEffectiveUpdateList() other_updates = [ item for item in MunkiItems.getOptionalInstallItems() if item['status'] == 'update-available'] page = {} page['update_rows'] = u'' page['hide_progress_spinner'] = u'hidden' page['hide_other_updates'] = u'hidden' page['install_all_button_classes'] = u'' item_template = get_template('update_row_template.html') if item_list: for item in item_list: escapeAndQuoteCommonFields(item) page['update_rows'] += item_template.safe_substitute(item) elif not other_updates: status_results_template = get_template('status_results_template.html') alert = {} alert['primary_status_text'] = NSLocalizedString( u"Your software is up to date.", u"No Pending Updates primary text") alert['secondary_status_text'] = NSLocalizedString( u"There is no new software for your computer at this time.", u"No Pending Updates secondary text") alert['hide_progress_bar'] = u'hidden' alert['progress_bar_value'] = u'' page['update_rows'] = status_results_template.safe_substitute(alert) count = len(item_list) page['update_count'] = msclib.updateCountMessage(count) page['install_btn_label'] = msclib.getInstallAllButtonTextForCount(count) page['warning_text'] = get_warning_text() page['other_updates_header_message'] = NSLocalizedString( u"Other available updates", u"Other Available Updates label") page['other_update_rows'] = u'' if other_updates: page['hide_other_updates'] = u'' for item in other_updates: escapeAndQuoteCommonFields(item) page['other_update_rows'] += item_template.safe_substitute(item) footer = get_template('footer_template.html', raw=True) generate_page(page_name, 'updates_template.html', page, footer=footer)
def get_warning_text(): '''Return localized text warning about forced installs and/or logouts and/or restarts''' item_list = MunkiItems.getEffectiveUpdateList() warning_text = u'' forced_install_date = munki.earliestForceInstallDate(item_list) if forced_install_date: date_str = munki.stringFromDate(forced_install_date) forced_date_text = NSLocalizedString( u"One or more items must be installed by %s", u"Forced Install Date summary") warning_text = forced_date_text % date_str restart_text = getRestartActionForUpdateList(item_list) if restart_text: if warning_text: warning_text += u' • ' + restart_text else: warning_text = restart_text return warning_text
def build_updates_page(): '''available/pending updates''' page_name = u'updates.html' # need to consolidate/centralize this flag. Accessing it this way is ugly. if NSApp.delegate().mainWindowController._update_in_progress: return build_update_status_page() item_list = MunkiItems.getEffectiveUpdateList() problem_updates = MunkiItems.getProblemItems() for item in problem_updates: item['hide_cancel_button'] = u'hidden' # find any optional installs with update available other_updates = [ item for item in MunkiItems.getOptionalInstallItems() if item['status'] == 'update-available' ] # find any listed optional install updates that require a higher OS # or have insufficient disk space or other blockers (because they have a # note) blocked_optional_updates = [ item for item in MunkiItems.getOptionalInstallItems() if item['status'] == 'installed' and item.get('note') ] for item in blocked_optional_updates: item['hide_cancel_button'] = u'hidden' other_updates.extend(blocked_optional_updates) page = {} page['update_rows'] = u'' page['hide_progress_spinner'] = u'hidden' page['hide_problem_updates'] = u'hidden' page['hide_other_updates'] = u'hidden' page['install_all_button_classes'] = u'' item_template = get_template('update_row_template.html') # build pending updates table if item_list: for item in item_list: escapeAndQuoteCommonFields(item) page['update_rows'] += item_template.safe_substitute(item) elif not other_updates and not problem_updates: status_results_template = get_template('status_results_template.html') alert = {} alert['primary_status_text'] = NSLocalizedString( u"Your software is up to date.", u"No Pending Updates primary text") alert['secondary_status_text'] = NSLocalizedString( u"There is no new software for your computer at this time.", u"No Pending Updates secondary text") alert['hide_progress_bar'] = u'hidden' alert['progress_bar_value'] = u'' page['update_rows'] = status_results_template.safe_substitute(alert) count = len( [item for item in item_list if item['status'] != 'problem-item']) page['update_count'] = msclib.updateCountMessage(count) page['install_btn_label'] = msclib.getInstallAllButtonTextForCount(count) page['warning_text'] = get_warning_text() # build problem updates table page['problem_updates_header_message'] = NSLocalizedString( u"Problem updates", u"Problem Updates label") page['problem_update_rows'] = u'' if problem_updates: page['hide_problem_updates'] = u'' for item in problem_updates: escapeAndQuoteCommonFields(item) page['problem_update_rows'] += item_template.safe_substitute(item) # build other available updates table page['other_updates_header_message'] = NSLocalizedString( u"Other available updates", u"Other Available Updates label") page['other_update_rows'] = u'' if other_updates: page['hide_other_updates'] = u'' for item in other_updates: escapeAndQuoteCommonFields(item) page['other_update_rows'] += item_template.safe_substitute(item) footer = get_template('footer_template.html', raw=True) generate_page(page_name, 'updates_template.html', page, footer=footer)
def build_updates_page(): '''available/pending updates''' page_name = u'updates.html' # need to consolidate/centralize this flag. Accessing it this way is ugly. if NSApp.delegate().mainWindowController._update_in_progress: return build_update_status_page() item_list = MunkiItems.getEffectiveUpdateList() problem_updates = MunkiItems.getProblemItems() for item in problem_updates: item['hide_cancel_button'] = u'hidden' # find any optional installs with update available other_updates = [ item for item in MunkiItems.getOptionalInstallItems() if item['status'] == 'update-available'] # find any listed optional install updates that require a higher OS # or have insufficient disk space or other blockers (because they have a # note) blocked_optional_updates = [ item for item in MunkiItems.getOptionalInstallItems() if item['status'] == 'installed' and item.get('note')] for item in blocked_optional_updates: item['hide_cancel_button'] = u'hidden' other_updates.extend(blocked_optional_updates) page = {} page['update_rows'] = u'' page['hide_progress_spinner'] = u'hidden' page['hide_problem_updates'] = u'hidden' page['hide_other_updates'] = u'hidden' page['install_all_button_classes'] = u'' item_template = get_template('update_row_template.html') # build pending updates table if item_list: for item in item_list: escapeAndQuoteCommonFields(item) page['update_rows'] += item_template.safe_substitute(item) elif not other_updates and not problem_updates: status_results_template = get_template('status_results_template.html') alert = {} alert['primary_status_text'] = NSLocalizedString( u"Your software is up to date.", u"No Pending Updates primary text") alert['secondary_status_text'] = NSLocalizedString( u"There is no new software for your computer at this time.", u"No Pending Updates secondary text") alert['hide_progress_bar'] = u'hidden' alert['progress_bar_value'] = u'' page['update_rows'] = status_results_template.safe_substitute(alert) count = len([item for item in item_list if item['status'] != 'problem-item']) page['update_count'] = msclib.updateCountMessage(count) page['install_btn_label'] = msclib.getInstallAllButtonTextForCount(count) page['warning_text'] = get_warning_text() # build problem updates table page['problem_updates_header_message'] = NSLocalizedString( u"Problem updates", u"Problem Updates label") page['problem_update_rows'] = u'' if problem_updates: page['hide_problem_updates'] = u'' for item in problem_updates: escapeAndQuoteCommonFields(item) page['problem_update_rows'] += item_template.safe_substitute(item) # build other available updates table page['other_updates_header_message'] = NSLocalizedString( u"Other available updates", u"Other Available Updates label") page['other_update_rows'] = u'' if other_updates: page['hide_other_updates'] = u'' for item in other_updates: escapeAndQuoteCommonFields(item) page['other_update_rows'] += item_template.safe_substitute(item) footer = get_template('footer_template.html', raw=True) generate_page(page_name, 'updates_template.html', page, footer=footer)
def getUpdateCount(self): '''Get the count of effective updates''' if self._update_in_progress: return 0 return len(MunkiItems.getEffectiveUpdateList())