当前位置: 首页>>代码示例>>Python>>正文


Python msclog.log函数代码示例

本文整理汇总了Python中msclog.log函数的典型用法代码示例。如果您正苦于以下问题:Python log函数的具体用法?Python log怎么用?Python log使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了log函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: alertedToRunningOnBatteryAndCancelled

 def alertedToRunningOnBatteryAndCancelled(self):
     '''Returns True if we are running on battery and user clicks
     the Cancel button'''
     power_info = munki.getPowerInfo()
     if (power_info.get('PowerSource') == 'Battery Power'
         and power_info.get('BatteryCharge', 0) < 50):
         alert = NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_(
             NSLocalizedString(
                 u"Your computer is not connected to a power source.", u"No Power Source Warning text"),
             NSLocalizedString(u"Continue", u"Continue button text"),
             NSLocalizedString(u"Cancel", u"Cancel button title/short action text"),
             nil,
             u"%@", NSLocalizedString(
                 (u"For best results, you should connect your computer to a "
                 "power source before updating. Are you sure you want to "
                 "continue the update?"), u"No Power Source Warning detail"))
         msclog.log("MSU", "alert_on_battery_power")
         # making UI consistent with Apple Software Update...
         # set Cancel button to be activated by return key
         alert.buttons()[1].setKeyEquivalent_('\r')
         # set Continue button to be activated by Escape key
         alert.buttons()[0].setKeyEquivalent_(chr(27))
         buttonPressed = alert.runModal()
         if buttonPressed == NSAlertAlternateReturn:
             return True
     return False
开发者ID:LTSAdmin,项目名称:munki,代码行数:26,代码来源:AlertController.py

示例2: kickOffInstallSession

 def kickOffInstallSession(self):
     '''start an update install/removal session'''
     # check for need to logout, restart, firmware warnings
     # warn about blocking applications, etc...
     # then start an update session
     if MunkiItems.updatesRequireRestart() or MunkiItems.updatesRequireLogout():
         # switch to updates view
         self.loadUpdatesPage_(self)
         # warn about need to logout or restart
         self.alert_controller.confirmUpdatesAndInstall()
     else:
         if self.alert_controller.alertedToBlockingAppsRunning():
             self.loadUpdatesPage_(self)
             return
         if self.alert_controller.alertedToRunningOnBatteryAndCancelled():
             self.loadUpdatesPage_(self)
             return
         self.managedsoftwareupdate_task = None
         msclog.log("user", "install_without_logout")
         self._update_in_progress = True
         self.displayUpdateCount()
         self.setStatusViewTitle_(NSLocalizedString(u"Updating...", u"Updating message"))
         result = munki.justUpdate()
         if result:
             msclog.debug_log("Error starting install session: %s" % result)
             self.munkiStatusSessionEnded_(2)
         else:
             self.managedsoftwareupdate_task = "installwithnologout"
             NSApp.delegate().statusController.startMunkiStatusSession()
             self.markPendingItemsAsInstalling()
开发者ID:altyus,项目名称:munki,代码行数:30,代码来源:MSCMainWindowController.py

示例3: alertedToBlockingAppsRunning

    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
开发者ID:50kaliber,项目名称:munki,代码行数:58,代码来源:AlertController.py

示例4: forceLogoutWarningDidEnd_returnCode_contextInfo_

 def forceLogoutWarningDidEnd_returnCode_contextInfo_(
                                     self, alert, returncode, contextinfo):
     '''Called when the forced logout warning alert ends'''
     btn_pressed = self._force_warning_btns.get(returncode)
     if btn_pressed == self._force_warning_logout_btn:
         msclog.log("user", "install_with_logout")
         result = munki.logoutAndUpdate()
     elif btn_pressed == self._force_warning_ok_btn:
         msclog.log("user", "dismissed_forced_logout_warning")
开发者ID:LTSAdmin,项目名称:munki,代码行数:9,代码来源:AlertController.py

示例5: userNotificationCenter_didActivateNotification_

 def userNotificationCenter_didActivateNotification_(self, center, notification):
     '''User clicked on a Notification Center alert'''
     user_info = notification.userInfo()
     if user_info.get('action') == 'open_url':
         url = user_info.get('value', 'munki://updates')
         msclog.log("MSU", "Got user notification to open %s" % url)
         self.openMunkiURL(url)
         center.removeDeliveredNotification_(notification)
     else:
         msclog.log("MSU", "Got user notification with unrecognized userInfo")
开发者ID:clburlison,项目名称:munki,代码行数:10,代码来源:MSCAppDelegate.py

示例6: forceLogoutWarningDidEnd_returnCode_contextInfo_

 def forceLogoutWarningDidEnd_returnCode_contextInfo_(
         self, alert, returncode, contextinfo):
     '''Called when the forced logout warning alert ends'''
     btn_pressed = self._force_warning_btns.get(returncode)
     if btn_pressed == self._force_warning_logout_btn:
         msclog.log("user", "install_with_logout")
         self.handlePossibleAuthRestart()
         try:
             munki.logoutAndUpdate()
         except munki.ProcessStartError, err:
             self.installSessionErrorAlert_(err)
开发者ID:SteveKueng,项目名称:munki,代码行数:11,代码来源:AlertController.py

示例7: installSessionErrorAlert

 def installSessionErrorAlert(self):
     '''Something has gone wrong and we can't trigger an install at logout'''
     msclog.log("user", "install_session_failed")
     alertMessageText = NSLocalizedString(
         u"Install session failed", u"Install Session Failed title")
     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")
     alert = NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_(
         alertMessageText, OKButtonTitle, nil, nil, u"%@", detailText)
     alert.beginSheetModalForWindow_modalDelegate_didEndSelector_contextInfo_(
         self.window(), self,
         self.installSessionErrorAlertDidEnd_returnCode_contextInfo_, nil)
开发者ID:50kaliber,项目名称:munki,代码行数:14,代码来源:AlertController.py

示例8: updateAlertDidEnd_returnCode_contextInfo_

 def updateAlertDidEnd_returnCode_contextInfo_(
                                self, alert, returncode, contextinfo):
     '''Called when alert invoked by alertToPendingUpdates ends'''
     if returncode == NSAlertDefaultReturn:
         msclog.log("user", "quit")
         NSApp.terminate_(self)
     elif returncode == NSAlertOtherReturn:
         msclog.log("user", "install_now_clicked")
         # make sure this alert panel is gone before we proceed
         # which might involve opening another alert sheet
         alert.window().orderOut_(self)
         # initiate the updates
         self.updateNow()
         self.loadUpdatesPage_(self)
开发者ID:altyus,项目名称:munki,代码行数:14,代码来源:MSCMainWindowController.py

示例9: applicationDidFinishLaunching_

    def applicationDidFinishLaunching_(self, sender):
        '''NSApplication delegate method called at launch'''
        # Prevent automatic relaunching at login on Lion+
        if NSApp.respondsToSelector_('disableRelaunchOnLogin'):
            NSApp.disableRelaunchOnLogin()

        ver = NSBundle.mainBundle().infoDictionary().get('CFBundleShortVersionString')
        msclog.log("MSC", "launched", "VER=%s" % ver)
        
        # if we're running under Snow Leopard, swap out the Dock icon for one
        # without the Retina assets to avoid an appearance issue when the
        # icon has a badge in the Dock (and App Switcher)
        # Darwin major version 10 is Snow Leopard (10.6)
        if os.uname()[2].split('.')[0] == '10':
            myImage = NSImage.imageNamed_("Managed Software Center 10_6")
            NSApp.setApplicationIconImage_(myImage)

        # setup client logging
        msclog.setup_logging()

        # have the statuscontroller register for its own notifications
        self.statusController.registerForNotifications()

        # user may have launched the app manually, or it may have
        # been launched by /usr/local/munki/managedsoftwareupdate
        # to display available updates
        if munki.thereAreUpdatesToBeForcedSoon(hours=2):
            # skip the check and just display the updates
            # by pretending the lastcheck is now
            lastcheck = NSDate.date()
        else:
            lastcheck = munki.pref('LastCheckDate')
        max_cache_age = munki.pref('CheckResultsCacheSeconds')
        # if there is no lastcheck timestamp, check for updates.
        if not lastcheck:
            self.mainWindowController.checkForUpdates()
        elif lastcheck.timeIntervalSinceNow() * -1 > int(max_cache_age):
            # check for updates if the last check is over the
            # configured manualcheck cache age max.
            self.mainWindowController.checkForUpdates()
        elif MunkiItems.updateCheckNeeded():
            # check for updates if we have optional items selected for install
            # or removal that have not yet been processed
            self.mainWindowController.checkForUpdates()
        
        # load the initial view only if we are not already loading something else.
        # enables launching the app to a specific panel, eg. from URL handler
        if not self.mainWindowController.webView.isLoading():
            self.mainWindowController.loadInitialView()
开发者ID:LTSAdmin,项目名称:munki,代码行数:49,代码来源:MSCAppDelegate.py

示例10: doRestartAlert

 def doRestartAlert(self):
     '''Display a restart alert -- some item just installed or removed requires a restart'''
     msclog.log("MSC", "restart_required")
     self._status_restartAlertDismissed = 0
     alert = NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_(
         NSLocalizedString(u"Restart Required", u"Restart Required title"),
         NSLocalizedString(u"Restart", u"Restart button title"),
         nil,
         nil,
         u"%@", NSLocalizedString(
             u"Software installed or removed requires a restart. You will "
             "have a chance to save open documents.", u"Restart Required alert detail"))
     alert.beginSheetModalForWindow_modalDelegate_didEndSelector_contextInfo_(
         self.statusWindowController.window(),
         self, self.restartAlertDidEnd_returnCode_contextInfo_, nil)
开发者ID:50kaliber,项目名称:munki,代码行数:15,代码来源:MSCStatusController.py

示例11: alertToExtraUpdates

 def alertToExtraUpdates(self):
     '''Notify user of additional pending updates'''
     msclog.log("user", "extra_updates_pending")
     alert = NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_(
         NSLocalizedString(
             u"Additional Pending Updates",
             u"Additional Pending Updates title"),
         NSLocalizedString(u"OK", u"OK button title"),
         nil,
         nil,
         u"%@", NSLocalizedString(
             u"There are additional pending updates to install or remove.",
             u"Additional Pending Updates detail")
         )
     alert.beginSheetModalForWindow_modalDelegate_didEndSelector_contextInfo_(
         self.window, self,
         self.extraUpdatesAlertDidEnd_returnCode_contextInfo_, nil)
开发者ID:50kaliber,项目名称:munki,代码行数:17,代码来源:AlertController.py

示例12: openURL_withReplyEvent_

 def openURL_withReplyEvent_(self, event, replyEvent):
     '''Handle openURL messages'''
     keyDirectObject = struct.unpack(">i", "----")[0]
     url = event.paramDescriptorForKeyword_(keyDirectObject).stringValue().decode('utf8')
     msclog.log("MSU", "Called by external URL: %s", url)
     parsed_url = urlparse(url)
     if parsed_url.scheme != 'munki':
         msclog.debug_log("URL %s has unsupported scheme" % url)
         return
     filename = mschtml.unquote(parsed_url.netloc)
     # add .html if no extension
     if not os.path.splitext(filename)[1]:
         filename += u'.html'
     if filename.endswith(u'.html'):
         mschtml.build_page(filename)
         self.mainWindowController.load_page(filename)
     else:
         msclog.debug_log("%s doesn't have a valid extension. Prevented from opening" % url)
开发者ID:LTSAdmin,项目名称:munki,代码行数:18,代码来源:MSCAppDelegate.py

示例13: promptForPasswordForAuthRestart

 def promptForPasswordForAuthRestart(self):
     '''Set up and display our alert that prompts for password'''
     # Set up all the fields and buttons with localized text
     alert = NSAlert.alloc().init()
     alert.addButtonWithTitle_(
         NSLocalizedString(u"Allow", u"Allow button text"))
     alert.addButtonWithTitle_(
         NSLocalizedString(u"Deny", u"Deny button text"))
     alert.setMessageText_(NSLocalizedString(
         u"Managed Software Center wants to unlock the startup disk after "
         "restarting to complete all pending updates.",
         u"Password prompt title"))
     alert.setInformativeText_(NSLocalizedString(
         u"To allow this, enter your login password.",
         u"Password explanation"))
     alert.setAccessoryView_(self.passwordView)
     self.passwordLabel.setStringValue_(NSLocalizedString(
         u"Password:",u"Password label"))
     self.passwordField.setStringValue_(u"")
     # resize label to fit the text
     self.passwordLabel.sizeToFit()
     # resize the password field to use the rest of the available space
     viewWidth = self.passwordView.frame().size.width
     labelWidth = self.passwordLabel.frame().size.width
     fieldFrame = self.passwordField.frame()
     fieldFrame.origin.x = labelWidth + 8
     fieldFrame.size.width = viewWidth - labelWidth - 8
     self.passwordField.setFrame_(fieldFrame)
     # add esc as a key equivalent for the Deny button
     alert.buttons().objectAtIndex_(1).setKeyEquivalent_(chr(27))
     # change the Allow button to call our password validation method
     allowButton = alert.buttons().objectAtIndex_(0)
     allowButton.setTarget_(self)
     allowButton.setAction_(self.verifyPassword_)
     # make sure our password field is ready to accept input
     alert.window().setInitialFirstResponder_(self.passwordField)
     # we can finally run the alert!
     result = alert.runModal()
     if result == NSAlertFirstButtonReturn:
         # they clicked "Allow". We handled it in the verifyPassword method
         msclog.log("user", "stored password for auth restart")
     if result == NSAlertSecondButtonReturn:
         # they clicked "Deny"
         msclog.log("user", "denied password for auth restart")
开发者ID:munki,项目名称:munki,代码行数:44,代码来源:MSCPasswordAlertController.py

示例14: alertedToMultipleUsers

 def alertedToMultipleUsers(self):
     '''Returns True if there are multiple GUI logins; alerts as a side effect'''
     if len(munki.currentGUIusers()) > 1:
         msclog.log("MSC", "multiple_gui_users_update_cancelled")
         alert = NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_(
             NSLocalizedString(u"Other users logged in", u"Other Users Logged In title"),
             NSLocalizedString(u"Cancel", u"Cancel button title/short action text"),
             nil,
             nil,
             u"%@", 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."), u"Other Users Logged In detail"))
         alert.beginSheetModalForWindow_modalDelegate_didEndSelector_contextInfo_(
             self.window, self, self.multipleUserAlertDidEnd_returnCode_contextInfo_, nil)
         return True
     else:
         return False
开发者ID:LTSAdmin,项目名称:munki,代码行数:19,代码来源:AlertController.py

示例15: updateNow

 def updateNow(self):
     '''If user has added to/removed from the list of things to be updated,
     run a check session. If there are no more changes, proceed to an update
     installation session if items to be installed/removed are exclusively
     those selected by the user in this session'''
     if self.stop_requested:
         # reset the flag
         self.stop_requested = False
         self.resetAndReload()
         return
     if MunkiItems.updateCheckNeeded():
         # any item status changes that require an update check?
         msclog.debug_log('updateCheck needed')
         msclog.log("user", "check_then_install_without_logout")
         # since we are just checking for changed self-service items
         # we can suppress the Apple update check
         suppress_apple_update_check = True
         self._update_in_progress = True
         self.displayUpdateCount()
         result = munki.startUpdateCheck(suppress_apple_update_check)
         if result:
             msclog.debug_log("Error starting check-then-install session: %s" % result)
             self.munkiStatusSessionEnded_(2)
         else:
             self.managedsoftwareupdate_task = "checktheninstall"
             NSApp.delegate().statusController.startMunkiStatusSession()
             self.markRequestedItemsAsProcessing()
     elif (not self._alertedUserToOutstandingUpdates
           and MunkiItems.updatesContainNonUserSelectedItems()):
         # current list of updates contains some not explicitly chosen by the user
         msclog.debug_log('updateCheck not needed, items require user approval')
         self._update_in_progress = False
         self.displayUpdateCount()
         self.loadUpdatesPage_(self)
         self.alert_controller.alertToExtraUpdates()
     else:
         msclog.debug_log('updateCheck not needed')
         self._alertedUserToOutstandingUpdates = False
         self.kickOffInstallSession()
开发者ID:altyus,项目名称:munki,代码行数:39,代码来源:MSCMainWindowController.py


注:本文中的msclog.log函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。