Managed Software Update 2.0.2: bounces icon in the Dock to request user attention if there are updates but the app is not active; changes in logic around checking for updates.

git-svn-id: http://munki.googlecode.com/svn/trunk@531 a4e17f2e-e282-11dd-95e1-755cbddbdd66
This commit is contained in:
Greg Neagle
2010-04-27 20:47:42 +00:00
parent 12f7e81c8a
commit 49246c448c
3 changed files with 24 additions and 28 deletions
+2 -2
View File
@@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>2.0</string>
<string>2.0.2</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>2.0</string>
<string>2.0.2</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
@@ -35,11 +35,7 @@ class Managed_Software_UpdateAppDelegate(NSObject):
restart_required = False
logout_required = False
def applicationDidFinishLaunching_(self, sender):
pass
def applicationDidBecomeActive_(self, sender):
# display updates if available; if no available updates
# trigger an update check
if not self._listofupdates:
@@ -47,6 +43,7 @@ class Managed_Software_UpdateAppDelegate(NSObject):
if self._listofupdates:
self.buildTableData()
self.window_controller.theWindow.makeKeyAndOrderFront_(self)
NSApp.requestUserAttention_(NSCriticalRequest)
else:
# no updates available. Should we check for some?
result = munki.checkForUpdates()
@@ -63,6 +60,9 @@ class Managed_Software_UpdateAppDelegate(NSObject):
alert = NSAlert.alertWithMessageText_defaultButton_alternateButton_otherButton_informativeTextWithFormat_(u"Update check failed", u"Quit", objc.nil, objc.nil, "There is a configuration problem with the managed software installer. Could not start the update check process. Contact your systems administrator.")
alert.beginSheetModalForWindow_modalDelegate_didEndSelector_contextInfo_(self.window_controller.theWindow, self, self.quitAlertDidEnd_returnCode_contextInfo_, objc.nil)
def applicationDidBecomeActive_(self, sender):
pass
def getAvailableUpdates(self):
updatelist = []
installinfo = munki.getInstallInfo()
+18 -22
View File
@@ -24,11 +24,8 @@ import FoundationPlist
import time
from Foundation import NSDate, NSURL
from ScriptingBridge import SBApplication
_updatechecklaunchfile = "/private/tmp/.com.googlecode.munki.updatecheck.launchd"
_MunkiStatusIdentifier = "com.googlecode.munki.MunkiStatus"
_MunkiStatusApp = None
def getManagedInstallsPrefs():
# define default values
@@ -100,25 +97,14 @@ def startUpdateCheck():
pass
return result
def updateInProgress():
global _MunkiStatusApp
if not _MunkiStatusApp:
# we record this in a module global so we don't have to call
# SBApplication.applicationWithBundleIdentifier_ more than once
_MunkiStatusApp = SBApplication.applicationWithBundleIdentifier_(_MunkiStatusIdentifier)
if not _MunkiStatusApp:
# LaunchServices can't find MunkiStatus.app
# Maybe it's never been launched. Let's look by path
fileurl = NSURL.fileURLWithPath_("/Applications/Utilities/Managed Software Update.app/Contents/Resources/MunkiStatus.app")
_MunkiStatusApp = SBApplication.applicationWithURL_(fileurl)
if not _MunkiStatusApp:
# OK, now we're screwed. Can't find MunkiStatus.app at all.
return -1
# if MunkiStatus is running, we're doing an update right now
if _MunkiStatusApp.isRunning():
# bring it back to the front
_MunkiStatusApp.activate()
cmd = ['/usr/bin/killall', '-s', 'MunkiStatus']
result = subprocess.call(cmd)
munkiStatusIsRunning = (result == 0)
if munkiStatusIsRunning:
# we're doing an update. Bring it back to the front
tellMunkiStatusToActivate()
return 1
elif os.path.exists(_updatechecklaunchfile):
# we tried to trigger the update, but it failed?
@@ -126,8 +112,18 @@ def updateInProgress():
else:
# we're not updating right now
return 0
def tellMunkiStatusToActivate():
# uses oscascript to run an AppleScript
# ugly, but it works.
cmd = ['/usr/bin/osascript', '-e',
'tell application "MunkiStatus" to activate']
p = subprocess.Popen(cmd, bufsize=1, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
(output, err) = p.communicate()
def checkForUpdates():
# returns 1 if we've kicked off an update check (or one is in progress),
# returns 0 if we're not going to check (because we just did)