def updatesRequireLogout(): '''Return True if any item in the update list requires a logout or if Munki's InstallRequiresLogout preference is true.''' if munki.installRequiresLogout(): return True return len([item for item in getUpdateList() if 'Logout' in item.get('RestartAction', '')]) > 0
def confirmUpdatesAndInstall(self): '''Make sure it's OK to proceed with installing if logout or restart is required''' if self.alertedToMultipleUsers(): return elif MunkiItems.updatesRequireRestart(): alert = NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_( NSLocalizedString(u"Restart Required", u"Restart Required title"), NSLocalizedString(u"Log out and update", u"Log out and Update button text"), NSLocalizedString(u"Cancel", u"Cancel button title/short action text"), nil, u"%@", NSLocalizedString( (u"A restart is required after updating. Please be patient " "as there may be a short delay at the login window. Log " "out and update now?"), u"Restart Required detail")) alert.beginSheetModalForWindow_modalDelegate_didEndSelector_contextInfo_( self.window, self, self.logoutAlertDidEnd_returnCode_contextInfo_, nil) elif MunkiItems.updatesRequireLogout() or munki.installRequiresLogout(): alert = NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_( NSLocalizedString(u"Logout Required", u"Logout Required title"), NSLocalizedString(u"Log out and update", u"Log out and Update button text"), NSLocalizedString(u"Cancel", u"Cancel button title/short action text"), nil, u"%@", NSLocalizedString( (u"A logout is required before updating. Please be patient " "as there may be a short delay at the login window. Log " "out and update now?"), u"Logout Required detail")) alert.beginSheetModalForWindow_modalDelegate_didEndSelector_contextInfo_( self.window, self, self.logoutAlertDidEnd_returnCode_contextInfo_, nil) else: # we shouldn't have been invoked if neither a restart or logout was required msclog.debug_log( 'confirmUpdatesAndInstall was called but no restart or logout was needed')
def confirmInstallUpdates(self): if self.mainWindowController.theWindow.isVisible() == objc.NO: return if len(munki.currentGUIusers()) > 1: alert = NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_( NSLocalizedString(u"Other users logged in", None), NSLocalizedString(u"Cancel", None), objc.nil, objc.nil, NSLocalizedString( (u"There are other users logged into this computer.\n" "Updating now could cause other users to lose their " "work.\n\nPlease try again later after the other users " "have logged out."), None)) self._currentAlert = alert alert.beginSheetModalForWindow_modalDelegate_didEndSelector_contextInfo_( self.mainWindowController.theWindow, self, self.multipleUserAlertDidEnd_returnCode_contextInfo_, objc.nil) elif self.restart_required: alert = NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_( NSLocalizedString(u"Restart Required", None), NSLocalizedString(u"Log out and update", None), NSLocalizedString(u"Cancel", None), objc.nil, NSLocalizedString( (u"A restart is required after updating. Please be patient " "as there may be a short delay at the login window. Logout " "and update now?"), None)) self._currentAlert = alert alert.beginSheetModalForWindow_modalDelegate_didEndSelector_contextInfo_( self.mainWindowController.theWindow, self, self.logoutAlertDidEnd_returnCode_contextInfo_, objc.nil) elif self.logout_required or munki.installRequiresLogout(): alert = NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_( NSLocalizedString(u"Logout Required", None), NSLocalizedString(u"Log out and update", None), NSLocalizedString(u"Cancel", None), objc.nil, NSLocalizedString( (u"A logout is required before updating. Please be patient " "as there may be a short delay at the login window. Logout " "and update now?"), None)) self._currentAlert = alert alert.beginSheetModalForWindow_modalDelegate_didEndSelector_contextInfo_( self.mainWindowController.theWindow, self, self.logoutAlertDidEnd_returnCode_contextInfo_, objc.nil) else: alert = NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_( NSLocalizedString(u"Logout Recommended", None), NSLocalizedString(u"Log out and update", None), NSLocalizedString(u"Cancel", None), NSLocalizedString(u"Update without logging out", None), NSLocalizedString( (u"A logout is recommended before updating. Please be " "patient as there may be a short delay at the login " "window. Log out and update now?"), None)) self._currentAlert = alert alert.beginSheetModalForWindow_modalDelegate_didEndSelector_contextInfo_( self.mainWindowController.theWindow, self, self.logoutAlertDidEnd_returnCode_contextInfo_, objc.nil)
def getRestartActionForUpdateList(update_list): '''Returns a localized overall restart action message for the list of updates''' if not update_list: return '' if [item for item in update_list if 'Restart' in item.get('RestartAction', '')]: # found at least one item containing 'Restart' in its RestartAction return NSLocalizedString(u"Restart Required", u"Restart Required title") if ([item for item in update_list if 'Logout' in item.get('RestartAction', '')] or munki.installRequiresLogout()): # found at least one item containing 'Logout' in its RestartAction return NSLocalizedString(u"Logout Required", u"Logout Required title") else: return ''
def confirmInstallUpdates(self): if self.mainWindowController.theWindow.isVisible() == objc.NO: return if len(munki.currentGUIusers()) > 1: alert = NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_( NSLocalizedString(u"Other users logged in", None), NSLocalizedString(u"Cancel", None), objc.nil, objc.nil, NSLocalizedString( "There are other users logged into this computer.\nUpdating now could cause other users to lose their work.\n\nPlease try again later after the other users have logged out.", None)) self._currentAlert = alert alert.beginSheetModalForWindow_modalDelegate_didEndSelector_contextInfo_( self.mainWindowController.theWindow, self, self.multipleUserAlertDidEnd_returnCode_contextInfo_, objc.nil) elif self.restart_required: alert = NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_( NSLocalizedString(u"Restart Required", None), NSLocalizedString(u"Logout and update", None), NSLocalizedString(u"Cancel", None), objc.nil, NSLocalizedString( u"A restart is required after updating. Please be patient as there may be a short delay at the login window. Logout and update now?", None)) self._currentAlert = alert alert.beginSheetModalForWindow_modalDelegate_didEndSelector_contextInfo_( self.mainWindowController.theWindow, self, self.logoutAlertDidEnd_returnCode_contextInfo_, objc.nil) elif self.logout_required or munki.installRequiresLogout(): alert = NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_( NSLocalizedString(u"Logout Required", None), NSLocalizedString(u"Logout and update", None), NSLocalizedString(u"Cancel", None), objc.nil, NSLocalizedString( u"A logout is required before updating. Please be patient as there may be a short delay at the login window. Logout and update now?", None)) self._currentAlert = alert alert.beginSheetModalForWindow_modalDelegate_didEndSelector_contextInfo_( self.mainWindowController.theWindow, self, self.logoutAlertDidEnd_returnCode_contextInfo_, objc.nil) else: alert = NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_( NSLocalizedString(u"Logout Recommended", None), NSLocalizedString(u"Logout and update", None), NSLocalizedString(u"Cancel", None), NSLocalizedString(u"Update without logging out", None), NSLocalizedString( u"A logout is recommended before updating. Please be patient as there may be a short delay at the login window. Logout and update now?", None)) self._currentAlert = alert alert.beginSheetModalForWindow_modalDelegate_didEndSelector_contextInfo_( self.mainWindowController.theWindow, self, self.logoutAlertDidEnd_returnCode_contextInfo_, objc.nil)
def confirmUpdatesAndInstall(self): '''Make sure it's OK to proceed with installing if logout or restart is required''' if self.alertedToMultipleUsers(): return elif MunkiItems.updatesRequireRestart(): alert = NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_( NSLocalizedString(u"Restart Required", u"Restart Required title"), NSLocalizedString(u"Log out and update", u"Log out and Update button text"), NSLocalizedString(u"Cancel", u"Cancel button title/short action text"), nil, u"%@", NSLocalizedString( u"A restart is required after updating. Please be patient " "as there may be a short delay at the login window. Log " "out and update now?", u"Restart Required detail")) alert.beginSheetModalForWindow_modalDelegate_didEndSelector_contextInfo_( self.window, self, self.logoutAlertDidEnd_returnCode_contextInfo_, nil) elif MunkiItems.updatesRequireLogout() or munki.installRequiresLogout( ): alert = NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_( NSLocalizedString(u"Logout Required", u"Logout Required title"), NSLocalizedString(u"Log out and update", u"Log out and Update button text"), NSLocalizedString(u"Cancel", u"Cancel button title/short action text"), nil, u"%@", NSLocalizedString( u"A logout is required before updating. Please be patient " "as there may be a short delay at the login window. Log " "out and update now?", u"Logout Required detail")) alert.beginSheetModalForWindow_modalDelegate_didEndSelector_contextInfo_( self.window, self, self.logoutAlertDidEnd_returnCode_contextInfo_, nil) else: # we shouldn't have been invoked if neither a restart or logout was # required msclog.debug_log( 'confirmUpdatesAndInstall was called but no restart or logout ' 'was needed')