def munkiStatusSessionEnded_(self, socketSessionResult): consoleuser = munki.getconsoleuser() if (self.runmode == "MunkiStatus" or consoleuser == None or consoleuser == u"loginwindow"): # Status Window only, so we should just quit munki.log("MSU", "exit_munkistatus") # clear launch trigger file so we aren't immediately # relaunched by launchd munki.clearLaunchTrigger() NSApp.terminate_(self) # The managedsoftwareupdate run will have changed state preferences # in ManagedInstalls.plist. Load the new values. munki.reload_prefs() alertMessageText = NSLocalizedString(u"Update check failed", None) if self.managedsoftwareupdate_task == "installwithnologout": alertMessageText = NSLocalizedString(u"Install session failed", None) if socketSessionResult == -1: # connection was dropped unexpectedly self.mainWindowController.theWindow.makeKeyAndOrderFront_(self) alert = NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_( alertMessageText, NSLocalizedString(u"Quit", None), objc.nil, objc.nil, NSLocalizedString( u"There is a configuration problem with the managed software installer. The process ended unexpectedly. Contact your systems administrator.", None)) alert.beginSheetModalForWindow_modalDelegate_didEndSelector_contextInfo_( self.mainWindowController.theWindow, self, self.quitAlertDidEnd_returnCode_contextInfo_, objc.nil) return elif socketSessionResult == -2: # socket timed out before connection self.mainWindowController.theWindow.makeKeyAndOrderFront_(self) alert = NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_( alertMessageText, NSLocalizedString(u"Quit", None), objc.nil, objc.nil, NSLocalizedString( u"There is a configuration problem with the managed software installer. Could not start the process. Contact your systems administrator.", None)) alert.beginSheetModalForWindow_modalDelegate_didEndSelector_contextInfo_( self.mainWindowController.theWindow, self, self.quitAlertDidEnd_returnCode_contextInfo_, objc.nil) return if self.managedsoftwareupdate_task == "installwithnologout": # we're done. munki.log("MSU", "exit_installwithnologout") NSApp.terminate_(self) elif self.managedsoftwareupdate_task == "manualcheck": self.managedsoftwareupdate_task = None self._listofupdates = [] self.getAvailableUpdates() #NSLog(u"Building table of available updates.") self.buildUpdateTableData() if self._optionalInstalls: #NSLog(u"Building table of optional software.") self.buildOptionalInstallsData() #NSLog(u"Showing main window.") self.mainWindowController.theWindow.makeKeyAndOrderFront_(self) #NSLog(u"Main window was made key and ordered front") if self._listofupdates: return # no list of updates; let's check the LastCheckResult for more info lastCheckResult = munki.pref("LastCheckResult") if lastCheckResult == 0: munki.log("MSU", "no_updates") self.noUpdatesAlert() elif lastCheckResult == 1: NSApp.requestUserAttention_(NSCriticalRequest) elif lastCheckResult == -1: munki.log("MSU", "cant_update", "cannot contact server") alert = NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_( NSLocalizedString(u"Cannot check for updates", None), NSLocalizedString(u"Quit", None), objc.nil, objc.nil, NSLocalizedString( u"Managed Software Update cannot contact the update server at this time.\nIf this situation continues, contact your systems administrator.", None)) alert.beginSheetModalForWindow_modalDelegate_didEndSelector_contextInfo_( self.mainWindowController.theWindow, self, self.quitAlertDidEnd_returnCode_contextInfo_, objc.nil) elif lastCheckResult == -2: munki.log("MSU", "cant_update", "failed preflight") alert = NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_( NSLocalizedString(u"Cannot check for updates", None), NSLocalizedString(u"Quit", None), objc.nil, objc.nil, NSLocalizedString( u"Managed Software Update failed its preflight check.\nTry again later.", None)) alert.beginSheetModalForWindow_modalDelegate_didEndSelector_contextInfo_( self.mainWindowController.theWindow, self, self.quitAlertDidEnd_returnCode_contextInfo_, objc.nil)
def munkiStatusSessionEnded_(self, socketSessionResult): consoleuser = munki.getconsoleuser() if (self.runmode == "MunkiStatus" or consoleuser == None or consoleuser == u"loginwindow"): # Status Window only, so we should just quit munki.log("MSU", "exit_munkistatus") NSApp.terminate_(self) # The managedsoftwareupdate run will have changed state preferences # in ManagedInstalls.plist. Load the new values. munki.reload_prefs() alertMessageText = NSLocalizedString(u"Update check failed", None) if self.managedsoftwareupdate_task == "installwithnologout": alertMessageText = NSLocalizedString(u"Install session failed", None) if socketSessionResult == -1: # connection was dropped unexpectedly self.mainWindowController.theWindow.makeKeyAndOrderFront_(self) alert = NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_( alertMessageText, NSLocalizedString(u"Quit", None), objc.nil, objc.nil, NSLocalizedString(u"There is a configuration problem with the managed software installer. The process ended unexpectedly. Contact your systems administrator.", None)) alert.beginSheetModalForWindow_modalDelegate_didEndSelector_contextInfo_( self.mainWindowController.theWindow, self, self.quitAlertDidEnd_returnCode_contextInfo_, objc.nil) return elif socketSessionResult == -2: # socket timed out before connection self.mainWindowController.theWindow.makeKeyAndOrderFront_(self) alert = NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_( alertMessageText, NSLocalizedString(u"Quit", None), objc.nil, objc.nil, NSLocalizedString(u"There is a configuration problem with the managed software installer. Could not start the process. Contact your systems administrator.", None)) alert.beginSheetModalForWindow_modalDelegate_didEndSelector_contextInfo_( self.mainWindowController.theWindow, self, self.quitAlertDidEnd_returnCode_contextInfo_, objc.nil) return if self.managedsoftwareupdate_task == "installwithnologout": # we're done. munki.log("MSU", "exit_installwithnologout") NSApp.terminate_(self) elif self.managedsoftwareupdate_task == "manualcheck": self.managedsoftwareupdate_task = None self._listofupdates = [] self.getAvailableUpdates() #NSLog(u"Building table of available updates.") self.buildUpdateTableData() if self._optionalInstalls: #NSLog(u"Building table of optional software.") self.buildOptionalInstallsData() #NSLog(u"Showing main window.") self.mainWindowController.theWindow.makeKeyAndOrderFront_(self) #NSLog(u"Main window was made key and ordered front") if self._listofupdates: return # no list of updates; let's check the LastCheckResult for more info lastCheckResult = munki.pref("LastCheckResult") if lastCheckResult == 0: munki.log("MSU", "no_updates") self.noUpdatesAlert() elif lastCheckResult == 1: NSApp.requestUserAttention_(NSCriticalRequest) elif lastCheckResult == -1: munki.log("MSU", "cant_update", "cannot contact server") alert = NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_( NSLocalizedString(u"Cannot check for updates", None), NSLocalizedString(u"Quit", None), objc.nil, objc.nil, NSLocalizedString(u"Managed Software Update cannot contact the update server at this time.\nIf this situation continues, contact your systems administrator.", None)) alert.beginSheetModalForWindow_modalDelegate_didEndSelector_contextInfo_( self.mainWindowController.theWindow, self, self.quitAlertDidEnd_returnCode_contextInfo_, objc.nil) elif lastCheckResult == -2: munki.log("MSU", "cant_update", "failed preflight") alert = NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_( NSLocalizedString(u"Cannot check for updates", None), NSLocalizedString(u"Quit", None), objc.nil, objc.nil, NSLocalizedString(u"Managed Software Update failed its preflight check.\nTry again later.", None)) alert.beginSheetModalForWindow_modalDelegate_didEndSelector_contextInfo_( self.mainWindowController.theWindow, self, self.quitAlertDidEnd_returnCode_contextInfo_, objc.nil)
def munkiStatusSessionEnded_(self, sessionResult): '''Called by StatusController when a Munki session ends''' msclog.debug_log(u"MunkiStatus session ended: %s" % sessionResult) msclog.debug_log(u"MunkiStatus session type: %s" % self.managedsoftwareupdate_task) tasktype = self.managedsoftwareupdate_task self.managedsoftwareupdate_task = None self._update_in_progress = False # The managedsoftwareupdate run will have changed state preferences # in ManagedInstalls.plist. Load the new values. munki.reload_prefs() lastCheckResult = munki.pref("LastCheckResult") if sessionResult != 0 or lastCheckResult < 0: OKButtonTitle = NSLocalizedString(u"OK", u"OK button title") alertMessageText = NSLocalizedString( u"Update check failed", u"Update Check Failed title") if tasktype == "installwithnologout": alertMessageText = NSLocalizedString( u"Install session failed", u"Install Session Failed title") if sessionResult == -1: # connection was dropped unexpectedly msclog.log("MSC", "cant_update", "unexpected process end") detailText = NSLocalizedString( (u"There is a configuration problem with the managed software installer. " "The process ended unexpectedly. Contact your systems administrator."), u"Unexpected Session End message") elif sessionResult == -2: # session never started msclog.log("MSC", "cant_update", "process did not start") detailText = NSLocalizedString( (u"There is a configuration problem with the managed software installer. " "Could not start the process. Contact your systems administrator."), u"Could Not Start Session message") elif lastCheckResult == -1: # server not reachable msclog.log("MSC", "cant_update", "cannot contact server") detailText = NSLocalizedString( (u"Managed Software Center cannot contact the update server at this time.\n" "Try again later. If this situation continues, " "contact your systems administrator."), u"Cannot Contact Server detail") elif lastCheckResult == -2: # preflight failed msclog.log("MSU", "cant_update", "failed preflight") detailText = NSLocalizedString( (u"Managed Software Center cannot check for updates now.\n" "Try again later. If this situation continues, " "contact your systems administrator."), u"Failed Preflight Check detail") # show the alert sheet self.window().makeKeyAndOrderFront_(self) alert = NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_( alertMessageText, OKButtonTitle, nil, nil, u"%@", detailText) alert.beginSheetModalForWindow_modalDelegate_didEndSelector_contextInfo_( self.window(), self, self.munkiSessionErrorAlertDidEnd_returnCode_contextInfo_, nil) return if tasktype == 'checktheninstall': MunkiItems.reset() # possibly check again if choices have changed self.updateNow() return # all done checking and/or installing: display results self.resetAndReload() if MunkiItems.updateCheckNeeded(): # more stuff pending? Let's do it... self.updateNow()