Пример #1
0
 def laterBtnClicked(self):
     if munki.thereAreUpdatesToBeForcedSoon():
         deadline = munki.earliestForceInstallDate()
         time_til_logout = deadline.timeIntervalSinceNow()
         if time_til_logout > 0:
             deadline_str = munki.stringFromDate(deadline)
             formatString = NSLocalizedString(
                 (u"One or more updates must be installed by %s. A logout "
                 "may be forced if you wait too long to update."), None) 
             infoText = formatString % deadline_str
         else:
             infoText = NSLocalizedString(
                 (u"One or more mandatory updates are overdue for "
                 "installation. A logout will be forced soon."), None)
         alert = NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_(
                 NSLocalizedString(u"Manadatory Updates Pending", None),
                 NSLocalizedString(u"Show updates", None),
                 NSLocalizedString(u"Update later", None),
                 objc.nil,
                 infoText)
         self._currentAlert = alert
         alert.beginSheetModalForWindow_modalDelegate_didEndSelector_contextInfo_(
             self.mainWindowController.theWindow, self, 
             self.confirmLaterAlertDidEnd_returnCode_contextInfo_, objc.nil)
     else:
         munki.log("user", "exit_later_clicked")
         NSApp.terminate_(self)
Пример #2
0
    def forcedLogoutWarning(self, notification_obj):
        NSApp.activateIgnoringOtherApps_(True)
        info = notification_obj.userInfo()
        moreText = NSLocalizedString(
            (u"\nAll pending updates will be installed. Unsaved work will be "
            "lost.\nYou may avoid the forced logout by logging out now."), None)
        logout_time = None
        if info:
            logout_time = info.get('logout_time')
        elif munki.thereAreUpdatesToBeForcedSoon():
            logout_time = munki.earliestForceInstallDate()
        if not logout_time:
            return
        time_til_logout = int(logout_time.timeIntervalSinceNow() / 60)
        if time_til_logout > 55:
            deadline_str = munki.stringFromDate(logout_time)
            munki.log("user", "forced_logout_warning_initial")
            formatString = NSLocalizedString(
                    u"A logout will be forced at approximately %s.", None) 
            infoText = formatString % deadline_str + moreText
        elif time_til_logout > 0:
            munki.log("user", "forced_logout_warning_%s" % time_til_logout)
            formatString = NSLocalizedString(
                    u"A logout will be forced in less than %s minutes.", None) 
            infoText = formatString % time_til_logout + moreText
        else:
            munki.log("user", "forced_logout_warning_final")
            infoText = NSLocalizedString(
                (u"A logout will be forced in less than a minute.\nAll pending "
                "updates will be installed. Unsaved work will be lost."), None)

        # Set the OK button to default, unless less than 5 minutes to logout
        # in which case only the Logout button should be displayed.
        self._force_warning_logout_btn = NSLocalizedString(
            u"Log out and update now", None)
        self._force_warning_ok_btn = NSLocalizedString(u"OK", None)
        if time_til_logout > 5:
            self._force_warning_btns = {
                NSAlertDefaultReturn: self._force_warning_ok_btn,
                NSAlertAlternateReturn: self._force_warning_logout_btn,
            }
        else:
            self._force_warning_btns = {
                NSAlertDefaultReturn: self._force_warning_logout_btn,
                NSAlertAlternateReturn: objc.nil,
            }

        if self._currentAlert:
            NSApp.endSheet_(self._currentAlert.window())
            self._currentAlert = None
        alert = NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_(
                    NSLocalizedString(
                        u"Forced Logout for Mandatory Install", None),
                    self._force_warning_btns[NSAlertDefaultReturn],
                    self._force_warning_btns[NSAlertAlternateReturn],
                    objc.nil,
                    infoText)
        self._currentAlert = alert
        alert.beginSheetModalForWindow_modalDelegate_didEndSelector_contextInfo_(
            self.mainWindowController.theWindow, self, self.forceLogoutWarningDidEnd_returnCode_contextInfo_, objc.nil)
Пример #3
0
 def alertToPendingUpdates(self):
     '''Alert user to pending updates before quitting the application'''
     self._alertedUserToOutstandingUpdates = True
     # show the updates
     self.loadUpdatesPage_(self)
     if munki.thereAreUpdatesToBeForcedSoon():
         alertTitle = NSLocalizedString(u"Mandatory Updates Pending",
                                        u"Mandatory Updates Pending text")
         deadline = munki.earliestForceInstallDate()
         time_til_logout = deadline.timeIntervalSinceNow()
         if time_til_logout > 0:
             deadline_str = munki.stringFromDate(deadline)
             formatString = NSLocalizedString(
                 (u"One or more updates must be installed by %s. A logout "
                 "may be forced if you wait too long to update."),
                 u"Mandatory Updates Pending detail")
             alertDetail = formatString % deadline_str
         else:
             alertDetail = NSLocalizedString(
                 (u"One or more mandatory updates are overdue for "
                 "installation. A logout will be forced soon."),
                 u"Mandatory Updates Imminent detail")
     else:
         alertTitle = NSLocalizedString(u"Pending updates", u"Pending Updates alert title")
         alertDetail = NSLocalizedString(u"There are pending updates for this computer.",
                                         u"Pending Updates alert detail text")
     alert = NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_(
         alertTitle,
         NSLocalizedString(u"Quit", u"Quit button title"),
         nil,
         NSLocalizedString(u"Update now", u"Update Now button title"),
         u"%@", alertDetail)
     alert.beginSheetModalForWindow_modalDelegate_didEndSelector_contextInfo_(
         self.window(), self,
         self.updateAlertDidEnd_returnCode_contextInfo_, objc.nil)
Пример #4
0
    def forcedLogoutWarning(self, notification_obj):
        NSApp.activateIgnoringOtherApps_(True)
        info = notification_obj.userInfo()
        moreText = NSLocalizedString(
            u"\nAll pending updates will be installed. Unsaved work will be lost.\nYou may avoid the forced logout by logging out now.",
            None)
        logout_time = None
        if info:
            logout_time = info.get('logout_time')
        elif munki.thereAreUpdatesToBeForcedSoon():
            logout_time = munki.earliestForceInstallDate()
        if not logout_time:
            return
        time_til_logout = int(logout_time.timeIntervalSinceNow() / 60)
        if time_til_logout > 55:
            deadline_str = munki.stringFromDate(logout_time)
            munki.log("user", "forced_logout_warning_initial")
            infoText = NSLocalizedString(
                u"A logout will be forced at approximately %s.",
                None) % deadline_str + moreText
        elif time_til_logout > 0:
            munki.log("user", "forced_logout_warning_%s" % time_til_logout)
            infoText = NSLocalizedString(
                u"A logout will be forced in less than %s minutes.",
                None) % time_til_logout + moreText
        else:
            munki.log("user", "forced_logout_warning_final")
            infoText = NSLocalizedString(
                u"A logout will be forced in less than a minute.\nAll pending updates will be installed. Unsaved work will be lost.",
                None)

        # Set the OK button to default, unless less than 5 minutes to logout
        # in which case only the Logout button should be displayed.
        self._force_warning_logout_btn = NSLocalizedString(
            u"Logout and update now", None)
        self._force_warning_ok_btn = NSLocalizedString(u"OK", None)
        if time_til_logout > 5:
            self._force_warning_btns = {
                NSAlertDefaultReturn: self._force_warning_ok_btn,
                NSAlertAlternateReturn: self._force_warning_logout_btn,
            }
        else:
            self._force_warning_btns = {
                NSAlertDefaultReturn: self._force_warning_logout_btn,
                NSAlertAlternateReturn: objc.nil,
            }

        if self._currentAlert:
            NSApp.endSheet_(self._currentAlert.window())
            self._currentAlert = None
        alert = NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_(
            NSLocalizedString(u"Forced Logout for Mandatory Install", None),
            self._force_warning_btns[NSAlertDefaultReturn],
            self._force_warning_btns[NSAlertAlternateReturn], objc.nil,
            infoText)
        self._currentAlert = alert
        alert.beginSheetModalForWindow_modalDelegate_didEndSelector_contextInfo_(
            self.mainWindowController.theWindow, self,
            self.forceLogoutWarningDidEnd_returnCode_contextInfo_, objc.nil)
Пример #5
0
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
Пример #6
0
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
Пример #7
0
 def laterBtnClicked(self):
     if munki.thereAreUpdatesToBeForcedSoon():
         deadline = munki.earliestForceInstallDate()
         time_til_logout = deadline.timeIntervalSinceNow()
         if time_til_logout > 0:
             deadline_str = munki.stringFromDate(deadline)
             infoText = NSLocalizedString(
                 "One or more updates must be installed by %s. A logout may be forced if you wait too long to update.",
                 None) % deadline_str
         else:
             infoText = NSLocalizedString(
                 "One or more mandatory updates are overdue for installation. A logout will be forced soon.",
                 None)
         alert = NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_(
             NSLocalizedString(u"Manadatory Updates Pending", None),
             NSLocalizedString(u"Show updates", None),
             NSLocalizedString(u"Update later", None), objc.nil, infoText)
         self._currentAlert = alert
         alert.beginSheetModalForWindow_modalDelegate_didEndSelector_contextInfo_(
             self.mainWindowController.theWindow, self,
             self.confirmLaterAlertDidEnd_returnCode_contextInfo_, objc.nil)
     else:
         munki.log("user", "exit_later_clicked")
         NSApp.terminate_(self)
Пример #8
0
    def forcedLogoutWarning(self, notification_obj):
        '''Display a forced logout warning'''
        NSApp.activateIgnoringOtherApps_(True)
        info = notification_obj.userInfo()
        moreText = NSLocalizedString(
            u"All pending updates will be installed. Unsaved work will be lost."
            "\nYou may avoid the forced logout by logging out now.",
            u"Forced Logout warning detail")
        logout_time = None
        if info:
            logout_time = info.get('logout_time')
        elif munki.thereAreUpdatesToBeForcedSoon():
            logout_time = munki.earliestForceInstallDate()
        if not logout_time:
            return
        time_til_logout = int(logout_time.timeIntervalSinceNow() / 60)
        if time_til_logout > 55:
            deadline_str = munki.stringFromDate(logout_time)
            msclog.log("user", "forced_logout_warning_initial")
            formatString = NSLocalizedString(
                u"A logout will be forced at approximately %s.",
                u"Logout warning string when logout is an hour or more away")
            infoText = formatString % deadline_str + u"\n" + moreText
        elif time_til_logout > 0:
            msclog.log("user", "forced_logout_warning_%s" % time_til_logout)
            formatString = NSLocalizedString(
                u"A logout will be forced in less than %s minutes.",
                u"Logout warning string when logout is in < 60 minutes")
            infoText = formatString % time_til_logout + u"\n" + moreText
        else:
            msclog.log("user", "forced_logout_warning_final")
            infoText = NSLocalizedString(
                u"A logout will be forced in less than a minute.\nAll pending "
                "updates will be installed. Unsaved work will be lost.",
                u"Logout warning string when logout is in less than a minute")

        # Set the OK button to default, unless less than 5 minutes to logout
        # in which case only the Logout button should be displayed.
        self._force_warning_logout_btn = NSLocalizedString(
            u"Log out and update now", u"Logout and Update Now button text")
        self._force_warning_ok_btn = NSLocalizedString(u"OK",
                                                       u"OK button title")
        if time_til_logout > 5:
            self._force_warning_btns = {
                NSAlertDefaultReturn: self._force_warning_ok_btn,
                NSAlertAlternateReturn: self._force_warning_logout_btn,
            }
        else:
            self._force_warning_btns = {
                NSAlertDefaultReturn: self._force_warning_logout_btn,
                NSAlertAlternateReturn: nil,
            }

        if self.window.attachedSheet():
            # there's an existing sheet open
            NSApp.endSheet_(self.window.attachedSheet())

        alert = NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_(
            NSLocalizedString(u"Forced Logout for Mandatory Install",
                              u"Forced Logout title text"),
            self._force_warning_btns[NSAlertDefaultReturn],
            self._force_warning_btns[NSAlertAlternateReturn], nil, u"%@",
            infoText)
        alert.beginSheetModalForWindow_modalDelegate_didEndSelector_contextInfo_(
            self.window, self,
            self.forceLogoutWarningDidEnd_returnCode_contextInfo_, nil)
Пример #9
0
    def forcedLogoutWarning(self, notification_obj):
        '''Display a forced logout warning'''
        NSApp.activateIgnoringOtherApps_(True)
        info = notification_obj.userInfo()
        moreText = NSLocalizedString(
            (u"All pending updates will be installed. Unsaved work will be lost."
            "\nYou may avoid the forced logout by logging out now."),
            u"Forced Logout warning detail")
        logout_time = None
        if info:
            logout_time = info.get('logout_time')
        elif munki.thereAreUpdatesToBeForcedSoon():
            logout_time = munki.earliestForceInstallDate()
        if not logout_time:
            return
        time_til_logout = int(logout_time.timeIntervalSinceNow() / 60)
        if time_til_logout > 55:
            deadline_str = munki.stringFromDate(logout_time)
            msclog.log("user", "forced_logout_warning_initial")
            formatString = NSLocalizedString(
                    u"A logout will be forced at approximately %s.",
                    u"Logout warning string when logout is an hour or more away")
            infoText = formatString % deadline_str + u"\n" + moreText
        elif time_til_logout > 0:
            msclog.log("user", "forced_logout_warning_%s" % time_til_logout)
            formatString = NSLocalizedString(
                    u"A logout will be forced in less than %s minutes.",
                    u"Logout warning string when logout is in < 60 minutes")
            infoText = formatString % time_til_logout + u"\n" + moreText
        else:
            msclog.log("user", "forced_logout_warning_final")
            infoText = NSLocalizedString(
                (u"A logout will be forced in less than a minute.\nAll pending "
                  "updates will be installed. Unsaved work will be lost."),
                u"Logout warning string when logout is in less than a minute")

        # Set the OK button to default, unless less than 5 minutes to logout
        # in which case only the Logout button should be displayed.
        self._force_warning_logout_btn = NSLocalizedString(
            u"Log out and update now", u"Logout and Update Now button text")
        self._force_warning_ok_btn = NSLocalizedString(u"OK", u"OK button title")
        if time_til_logout > 5:
            self._force_warning_btns = {
                NSAlertDefaultReturn: self._force_warning_ok_btn,
                NSAlertAlternateReturn: self._force_warning_logout_btn,
            }
        else:
            self._force_warning_btns = {
                NSAlertDefaultReturn: self._force_warning_logout_btn,
                NSAlertAlternateReturn: nil,
            }

        if self.window.attachedSheet():
            # there's an existing sheet open
            NSApp.endSheet_(self.window.attachedSheet())

        alert = NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_(
                    NSLocalizedString(
                        u"Forced Logout for Mandatory Install", u"Forced Logout title text"),
                    self._force_warning_btns[NSAlertDefaultReturn],
                    self._force_warning_btns[NSAlertAlternateReturn],
                    nil,
                    u"%@", infoText)
        alert.beginSheetModalForWindow_modalDelegate_didEndSelector_contextInfo_(
            self.window, self, self.forceLogoutWarningDidEnd_returnCode_contextInfo_, nil)