def applicationDidFinishLaunching_(self, sender):
        '''NSApplication delegate method called at launch'''
        # setup client logging
        msclog.setup_logging()
        
        # userInfo dict can be nil, seems to be with 10.6
        if sender.userInfo():
            userNotification = sender.userInfo().get('NSApplicationLaunchUserNotificationKey')
            # we get this notification at launch because it's too early to have declared ourself
            # a NSUserNotificationCenterDelegate
            if userNotification:
                NSLog("Launched via Notification interaction")
                self.userNotificationCenter_didActivateNotification_(
                    NSUserNotificationCenter.defaultUserNotificationCenter(), userNotification)
        
        # 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)

        # if we are running under Mountain Lion or later set ourselves as a delegate
        # for NSUserNotificationCenter notifications
        if os.uname()[2].split('.')[0] > '11':
            NSUserNotificationCenter.defaultUserNotificationCenter().setDelegate_(self)

        # 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()
dataset/ETHPy150Open munki/munki/code/apps/Managed Software Center/Managed Software Center/MSCAppDelegate.py/MSCAppDelegate.applicationDidFinishLaunching_/original