def build_updatedetail_page(identifier): '''Build detail page for a non-optional update''' items = MunkiItems.getUpdateList() page_name = u'updatedetail-%s.html' % identifier name, sep, version = identifier.partition('--version-') for item in items: if item['name'] == name and item.get('version_to_install', '') == version: page = MunkiItems.UpdateItem(item) escapeAndQuoteCommonFields(page) addDetailSidebarLabels(page) force_install_after_date = item.get('force_install_after_date') if force_install_after_date: try: local_date = munki.discardTimeZoneFromDate( force_install_after_date) date_str = munki.shortRelativeStringFromDate( local_date) page['dueLabel'] += u' ' page['short_due_date'] = date_str except munki.BadDateError: # some issue with the stored date msclog.debug_log('Problem with force_install_after_date for %s' % identifier) page['dueLabel'] = u'' page['short_due_date'] = u'' else: page['dueLabel'] = u'' page['short_due_date'] = u'' footer = get_template('footer_template.html', raw=True) generate_page(page_name, 'updatedetail_template.html', page, footer=footer) return # if we get here we didn't find any item matching identifier msclog.debug_log('No update detail found for %s' % identifier) build_item_not_found_page(page_name)
def build_updatedetail_page(identifier): '''Build detail page for a non-optional update''' items = MunkiItems.getUpdateList() page_name = u'updatedetail-%s.html' % identifier name, sep, version = identifier.partition('--version-') for item in items: if item['name'] == name and item['version_to_install'] == version: page = MunkiItems.UpdateItem(item) addDetailSidebarLabels(page) force_install_after_date = item.get('force_install_after_date') if force_install_after_date: local_date = munki.discardTimeZoneFromDate( force_install_after_date) date_str = munki.shortRelativeStringFromDate(local_date) page['dueLabel'] += u' ' page['short_due_date'] = date_str else: page['dueLabel'] = u'' page['short_due_date'] = u'' footer = get_template('footer_template.html', raw=True) generate_page(page_name, 'updatedetail_template.html', page, footer=footer) return # if we get here we didn't find any item matching identifier msclog.debug_log('No update detail found for %s' % item_name) build_item_not_found_page(page_name)
def alertedToBlockingAppsRunning(self): '''Returns True if blocking_apps are running; alerts as a side-effect''' apps_to_check = [] for update_item in MunkiItems.getUpdateList(): if 'blocking_applications' in update_item: apps_to_check.extend(update_item['blocking_applications']) else: apps_to_check.extend( [os.path.basename(item.get('path')) for item in update_item.get('installs', []) if item['type'] == 'application'] ) running_apps = munki.getRunningBlockingApps(apps_to_check) if running_apps: current_user = munki.getconsoleuser() other_users_apps = [item['display_name'] for item in running_apps if item['user'] != current_user] my_apps = [item['display_name'] for item in running_apps if item['user'] == current_user] msclog.log( "MSC", "conflicting_apps", ','.join(other_users_apps + my_apps)) if other_users_apps: detailText = NSLocalizedString( u"Other logged in users are using the following " "applications. Try updating later when they are no longer " "in use:\n\n%s", u"Other Users Blocking Apps Running detail") alert = NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_( NSLocalizedString( u"Applications in use by others", u"Other Users Blocking Apps Running title"), NSLocalizedString(u"OK", u'OKButtonText'), nil, nil, u"%@", detailText % u'\n'.join(set(other_users_apps)) ) else: detailText = NSLocalizedString( u"You must quit the following applications before " "proceeding with installation or removal:\n\n%s", u"Blocking Apps Running detail") alert = NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_( NSLocalizedString( u"Conflicting applications running", u"Blocking Apps Running title"), NSLocalizedString(u"OK", u"OK button title"), nil, nil, u"%@", detailText % u'\n'.join(set(my_apps)) ) alert.beginSheetModalForWindow_modalDelegate_didEndSelector_contextInfo_( self.window, self, self.blockingAppsRunningAlertDidEnd_returnCode_contextInfo_, nil) return True else: return False
def alertedToBlockingAppsRunning(self): '''Returns True if blocking_apps are running; alerts as a side-effect''' apps_to_check = [] for update_item in MunkiItems.getUpdateList(): if 'blocking_applications' in update_item: apps_to_check.extend(update_item['blocking_applications']) else: apps_to_check.extend( [os.path.basename(item.get('path')) for item in update_item.get('installs', []) if item['type'] == 'application'] ) running_apps = munki.getRunningBlockingApps(apps_to_check) if running_apps: current_user = munki.getconsoleuser() other_users_apps = [item['display_name'] for item in running_apps if item['user'] != current_user] my_apps = [item['display_name'] for item in running_apps if item['user'] == current_user] msclog.log( "MSC", "conflicting_apps", ','.join(other_users_apps + my_apps)) if other_users_apps: detailText = NSLocalizedString( u"Other logged in users are using the following " "applications. Try updating later when they are no longer " "in use:\n\n%s", u"Other Users Blocking Apps Running detail") alert = NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_( NSLocalizedString( u"Applications in use by others", u"Other Users Blocking Apps Running title"), NSLocalizedString(u"OK", u'OKButtonText'), nil, nil, u"%@", detailText % u'\n'.join(set(other_users_apps)) ) else: detailText = NSLocalizedString( u"You must quit the following applications before " "proceeding with installation or removal:\n\n%s", u"Blocking Apps Running detail") alert = NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_( NSLocalizedString( u"Conflicting applications running", u"Blocking Apps Running title"), NSLocalizedString(u"OK", u"OK button title"), nil, nil, u"%@", detailText % u'\n'.join(set(my_apps)) ) alert.beginSheetModalForWindow_modalDelegate_didEndSelector_contextInfo_( self.window, self, self.blockingAppsRunningAlertDidEnd_returnCode_contextInfo_, nil) return True else: return False
def getFirmwareAlertInfo(self): '''Get detail about a firmware update''' info = [] for update_item in MunkiItems.getUpdateList(): if 'firmware_alert_text' in update_item: info_item = {} info_item['name'] = update_item.get('display_name', 'name') alert_text = update_item['firmware_alert_text'] if alert_text == u'_DEFAULT_FIRMWARE_ALERT_TEXT_': # substitute localized default alert text alert_text = NSLocalizedString( (u"Firmware will be updated on your computer. " "Your computer's power cord must be connected " "and plugged into a working power source. " "It may take several minutes for the update to " "complete. Do not disturb or shut off the power " "on your computer during this update."), u"Firmware Alert Default detail") info_item['alert_text'] = alert_text info.append(info_item) return info
def getFirmwareAlertInfo(self): '''Get detail about a firmware update''' info = [] for update_item in MunkiItems.getUpdateList(): if 'firmware_alert_text' in update_item: info_item = {} info_item['name'] = update_item.get('display_name', 'name') alert_text = update_item['firmware_alert_text'] if alert_text == u'_DEFAULT_FIRMWARE_ALERT_TEXT_': # substitute localized default alert text alert_text = NSLocalizedString( (u"Firmware will be updated on your computer. " "Your computer's power cord must be connected " "and plugged into a working power source. " "It may take several minutes for the update to " "complete. Do not disturb or shut off the power " "on your computer during this update."), u"Firmware Alert Default detail") info_item['alert_text'] = alert_text info.append(info_item) return info