s/GuiCacheAgeSecs/CheckResultsCacheSeconds/ per a discussion with gneagle.

Also, add to default_prefs, even though default is None/unset, a rrmiddleton pointed out this documents which prefs MSU might use.
This commit is contained in:
Justin McWilliams
2012-12-17 10:52:13 -05:00
parent dc37943b46
commit 15e082ae45
2 changed files with 12 additions and 10 deletions
@@ -121,7 +121,8 @@ class MSUAppDelegate(NSObject):
# otherwise, only check for updates if the last check is over the # otherwise, only check for updates if the last check is over the
# configured manualcheck cache age max. # configured manualcheck cache age max.
max_cache_age = ( max_cache_age = (
munki.pref('GuiCacheAgeSecs') or DEFAULT_GUI_CACHE_AGE_SECS) munki.pref('CheckResultsCacheSeconds') or
DEFAULT_GUI_CACHE_AGE_SECS)
if lastcheck.timeIntervalSinceNow() * -1 > int(max_cache_age): if lastcheck.timeIntervalSinceNow() * -1 > int(max_cache_age):
self.checkForUpdates() self.checkForUpdates()
return return
@@ -133,8 +134,8 @@ class MSUAppDelegate(NSObject):
if self._listofupdates: if self._listofupdates:
self.displayUpdatesWindow() self.displayUpdatesWindow()
else: else:
# only check for updates if GuiCacheAgeSecs is not defined. # only check for updates if cache secs config is not defined.
if munki.pref('GuiCacheAgeSecs'): if munki.pref('CheckResultsCacheSeconds'):
self.mainWindowController.theWindow.makeKeyAndOrderFront_(self) self.mainWindowController.theWindow.makeKeyAndOrderFront_(self)
self.noUpdatesAlert() self.noUpdatesAlert()
else: else:
+8 -7
View File
@@ -128,6 +128,7 @@ def pref(pref_name):
'AppleSoftwareUpdatesOnly': False, 'AppleSoftwareUpdatesOnly': False,
'ShowRemovalDetail': False, 'ShowRemovalDetail': False,
'InstallRequiresLogout': False 'InstallRequiresLogout': False
'CheckResultsCacheSeconds': None,
} }
pref_value = CFPreferencesCopyAppValue(pref_name, BUNDLE_ID) pref_value = CFPreferencesCopyAppValue(pref_name, BUNDLE_ID)
if pref_value == None: if pref_value == None:
@@ -211,25 +212,25 @@ def earliestForceInstallDate():
Returns None or earliest force_install_after_date converted to local time Returns None or earliest force_install_after_date converted to local time
""" """
earliest_date = None earliest_date = None
installinfo = getInstallInfo() installinfo = getInstallInfo()
for install in installinfo.get('managed_installs', []): for install in installinfo.get('managed_installs', []):
this_force_install_date = install.get('force_install_after_date') this_force_install_date = install.get('force_install_after_date')
if this_force_install_date: if this_force_install_date:
this_force_install_date = discardTimeZoneFromDate( this_force_install_date = discardTimeZoneFromDate(
this_force_install_date) this_force_install_date)
if not earliest_date or this_force_install_date < earliest_date: if not earliest_date or this_force_install_date < earliest_date:
earliest_date = this_force_install_date earliest_date = this_force_install_date
return earliest_date return earliest_date
def discardTimeZoneFromDate(the_date): def discardTimeZoneFromDate(the_date):
"""Input: NSDate object """Input: NSDate object
Output: NSDate object with same date and time as the UTC. Output: NSDate object with same date and time as the UTC.
In Los Angeles (PDT), '2011-06-20T12:00:00Z' becomes In Los Angeles (PDT), '2011-06-20T12:00:00Z' becomes
'2011-06-20 12:00:00 -0700'. '2011-06-20 12:00:00 -0700'.
In New York (EDT), it becomes '2011-06-20 12:00:00 -0400'. In New York (EDT), it becomes '2011-06-20 12:00:00 -0400'.
""" """
@@ -356,7 +357,7 @@ def logoutAndUpdate():
try: try:
if not os.path.exists(INSTALLATLOGOUTFILE): if not os.path.exists(INSTALLATLOGOUTFILE):
open(INSTALLATLOGOUTFILE, 'w').close() open(INSTALLATLOGOUTFILE, 'w').close()
logoutNow() logoutNow()
except (OSError, IOError): except (OSError, IOError):
return 1 return 1
@@ -384,7 +385,7 @@ def justUpdate():
return 0 return 0
except (OSError, IOError): except (OSError, IOError):
return 1 return 1
def getRunningProcesses(): def getRunningProcesses():
"""Returns a list of paths of running processes""" """Returns a list of paths of running processes"""