Additional PEP8 cleanup

This commit is contained in:
Samuel Keeley
2016-01-28 17:45:20 -08:00
committed by Samuel Keeley
parent e9986c4439
commit c7114bdec4
+30 -24
View File
@@ -253,10 +253,12 @@ class AppleUpdates(object):
if rewrite_pkg_urls and 'URL' in package:
package['URL'] = self.RewriteURL(package['URL'])
if 'MetadataURL' in package:
package['MetadataURL'] = self.RewriteURL(package['MetadataURL'])
package['MetadataURL'] = self.RewriteURL(
package['MetadataURL'])
distributions = product['Distributions']
for dist_lang in distributions.keys():
distributions[dist_lang] = self.RewriteURL(distributions[dist_lang])
distributions[dist_lang] = self.RewriteURL(
distributions[dist_lang])
def RewriteCatalogURLs(self, catalog, rewrite_pkg_urls=False):
"""Rewrites URLs in a catalog to point to our local replica.
@@ -353,7 +355,7 @@ class AppleUpdates(object):
product_key)
self.RetrieveURLToCacheDir(
package['MetadataURL'], copy_only_if_missing=True)
#if 'URL' in package:
# if 'URL' in package:
# munkicommon.display_status_minor(
# 'Caching package for product ID %s',
# product_key)
@@ -470,12 +472,11 @@ class AppleUpdates(object):
html = readmes[0].firstChild.data
html_data = buffer(html.encode('utf-8'))
attributed_string, attributes = NSAttributedString.alloc(
).initWithHTML_documentAttributes_(html_data, None)
).initWithHTML_documentAttributes_(html_data, None)
firmware_alert_text = attributed_string.string()
return firmware_alert_text
return ''
def GetBlockingApps(self, product_key):
'''Given a product key, finds the cached softwareupdate dist file,
then parses it, looking for must-close apps and converting them to
@@ -804,7 +805,8 @@ class AppleUpdates(object):
except CatalogNotFoundError:
return False
except (ReplicationError, fetch.MunkiDownloadError), err:
munkicommon.display_warning('Could not download Apple SUS catalog:')
munkicommon.display_warning(
'Could not download Apple SUS catalog:')
munkicommon.display_warning('\t%s', str(err))
return False
@@ -1003,7 +1005,7 @@ class AppleUpdates(object):
software_update_key_list = CFPreferencesCopyKeyList(
APPLE_SOFTWARE_UPDATE_PREFS_DOMAIN,
kCFPreferencesAnyUser, kCFPreferencesCurrentHost) or []
if not self.ORIGINAL_CATALOG_URL_KEY in software_update_key_list:
if self.ORIGINAL_CATALOG_URL_KEY not in software_update_key_list:
# store the original CatalogURL
original_catalog_url = self._GetCatalogURL()
if not original_catalog_url:
@@ -1043,7 +1045,7 @@ class AppleUpdates(object):
software_update_key_list = CFPreferencesCopyKeyList(
APPLE_SOFTWARE_UPDATE_PREFS_DOMAIN,
kCFPreferencesAnyUser, kCFPreferencesCurrentHost) or []
if not self.ORIGINAL_CATALOG_URL_KEY in software_update_key_list:
if self.ORIGINAL_CATALOG_URL_KEY not in software_update_key_list:
# do nothing
return
original_catalog_url = CFPreferencesCopyValue(
@@ -1160,7 +1162,7 @@ class AppleUpdates(object):
while True:
output = proc.stdout.readline().decode('UTF-8')
if munkicommon.stopRequested():
os.kill(proc.pid, 15) #15 is SIGTERM
os.kill(proc.pid, 15) # 15 is SIGTERM
break
if not output and (proc.poll() != None):
break
@@ -1210,7 +1212,7 @@ class AppleUpdates(object):
Returns:
Integer softwareupdate exit code.
"""
if results == None:
if results is None:
# we're not interested in the results,
# but need to create a temporary dict anyway
results = {}
@@ -1222,7 +1224,9 @@ class AppleUpdates(object):
# Try to find our ptyexec tool
# first look in the parent directory of this file's directory
# (../)
parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
parent_dir = os.path.dirname(
os.path.dirname(
os.path.abspath(__file__)))
ptyexec_path = os.path.join(parent_dir, 'ptyexec')
if not os.path.exists(ptyexec_path):
# try absolute path in munki's normal install dir
@@ -1368,7 +1372,8 @@ class AppleUpdates(object):
retcode = job.returncode()
if retcode == 0:
# get SoftwareUpdate's LastResultCode
last_result_code = self.GetSoftwareUpdatePref('LastResultCode') or 0
last_result_code = self.GetSoftwareUpdatePref(
'LastResultCode') or 0
if last_result_code > 2:
retcode = last_result_code
@@ -1403,7 +1408,7 @@ class AppleUpdates(object):
# ensure that we don't restart for unattended installations
restartneeded = False
if not unattended_install_items:
return False # didn't find any unattended installs
return False # didn't find any unattended installs
else:
msg = 'Installing available Apple Software Updates...'
restartneeded = self.IsRestartNeeded()
@@ -1418,7 +1423,7 @@ class AppleUpdates(object):
return False # didn't do anything, so no restart needed
installlist = self.GetSoftwareUpdateInfo()
installresults = {'installed':[], 'download':[]}
installresults = {'installed': [], 'download': []}
catalog_url = 'file://localhost' + urllib2.quote(
self.local_catalog_path)
@@ -1537,7 +1542,8 @@ class AppleUpdates(object):
'LastAppleSoftwareUpdateCheck')
if last_su_check_string:
try:
last_su_check = NSDate.dateWithString_(last_su_check_string)
last_su_check = NSDate.dateWithString_(
last_su_check_string)
# dateWithString_ returns None if invalid date string.
if not last_su_check:
raise ValueError
@@ -1591,12 +1597,12 @@ class AppleUpdates(object):
# Mapping of supported RestartActions to
# equal or greater auxiliary actions
RestartActions = {
'RequireRestart' : ['RequireRestart', 'RecommendRestart'],
'RequireRestart': ['RequireRestart', 'RecommendRestart'],
'RecommendRestart': ['RequireRestart', 'RecommendRestart'],
'RequireLogout' : ['RequireRestart', 'RecommendRestart',
'RequireLogout'],
'None' : ['RequireRestart', 'RecommendRestart',
'RequireLogout']
'RequireLogout': ['RequireRestart', 'RecommendRestart',
'RequireLogout'],
'None': ['RequireRestart', 'RecommendRestart',
'RequireLogout']
}
for key in metadata:
@@ -1655,8 +1661,8 @@ class AppleUpdates(object):
for item in apple_updates:
if (item.get('unattended_install') or
(munkicommon.pref('AutomaticAppleUpdates') and
item.get('RestartAction', 'None') = 'None' and
os_version_tuple >= (10, 10))):
item.get('RestartAction', 'None')='None' and
os_version_tuple >= (10, 10))):
if munkicommon.blockingApplicationsRunning(item):
munkicommon.display_detail(
'Skipping unattended install of %s because '
@@ -1673,8 +1679,8 @@ class AppleUpdates(object):
return item_list, product_ids
# Make the new appleupdates module easily dropped in with exposed funcs for now.
# Make the new appleupdates module easily dropped in with exposed funcs
# for now.
apple_updates_object = None