Fix some bytes vs unicode handling for Python 3 compatibility

This commit is contained in:
Greg Neagle
2019-06-23 17:48:03 -07:00
parent ff6248daaf
commit 6730fbb74a
3 changed files with 7 additions and 5 deletions
+3 -2
View File
@@ -362,11 +362,12 @@ def getResourceIfChangedAtomically(url,
# If we already have a downloaded file & its (cached) hash matches what
# we need, do nothing, return unchanged.
if resume and expected_hash and os.path.isfile(destinationpath):
xattr_hash = getxattr(destinationpath, XATTR_SHA)
xattr_hash = getxattr(destinationpath, XATTR_SHA).decode('UTF-8')
if not xattr_hash:
xattr_hash = writeCachedChecksum(destinationpath)
if xattr_hash == expected_hash:
#File is already current, no change.
munkilog.log(" Cached item is current.")
return False
elif prefs.pref(
'PackageVerificationMode').lower() in ['hash_strict', 'hash']:
@@ -374,7 +375,7 @@ def getResourceIfChangedAtomically(url,
os.unlink(destinationpath)
except OSError:
pass
munkilog.log('Cached payload does not match hash in catalog, '
munkilog.log('Cached item does not match hash in catalog, '
'will check if changed and redownload: %s'
% destinationpath)
# continue with normal if-modified-since/etag update methods.
+2 -2
View File
@@ -39,7 +39,7 @@ def get_running_processes():
stderr=subprocess.PIPE)
(output, dummy_err) = proc.communicate()
if proc.returncode == 0:
proc_list = [item for item in output.splitlines()
proc_list = [item for item in output.decode("UTF-8").splitlines()
if item.startswith('/')]
launchcfmapp = ('/System/Library/Frameworks/Carbon.framework'
'/Versions/A/Support/LaunchCFMApp')
@@ -52,7 +52,7 @@ def get_running_processes():
(output, dummy_err) = proc.communicate()
if proc.returncode == 0:
carbon_apps = [item[len(launchcfmapp)+1:]
for item in output.splitlines()
for item in output.decode("UTF-8").splitlines()
if item.startswith(launchcfmapp)]
if carbon_apps:
proc_list.extend(carbon_apps)
+2 -1
View File
@@ -250,7 +250,8 @@ def download_icons(item_list):
icon_path = os.path.join(icon_dir, icon_name)
if os.path.isfile(icon_path):
# have we already downloaded it? If so get the hash
local_hash = fetch.getxattr(icon_path, fetch.XATTR_SHA)
local_hash = fetch.getxattr(
icon_path, fetch.XATTR_SHA).decode("UTF-8")
if not local_hash:
local_hash = munkihash.getsha256hash(icon_path)
fetch.writeCachedChecksum(icon_path, local_hash)