The checkreceipt function is using a python2 method of readPlistFromString. This results in the below exception being raised:
AttributeError: module plistlib has no attribute readPlistFromString
This results in InstallApplications always returning 0.0.0.0.0 for the pkg-version, thereby re-installing applications already installed. The fix for this is to replace readPlistFromString with loads.
import subprocess
import plistlib
packageid = com.getchef.pkg.chef
def checkreceipt(packageid):
try:
cmd = ["/usr/sbin/pkgutil", "--pkg-info-plist", packageid]
proc = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output = proc.communicate()
receiptout = output[0]
if receiptout:
plist = plistlib.loads(receiptout)
version = plist["pkg-version"]
else:
version = "0.0.0.0.0"
return version
except Exception:
version = "0.0.0.0.0"
return version
The
checkreceipt
function is using a python2 method ofreadPlistFromString
. This results in the below exception being raised:This results in InstallApplications always returning
0.0.0.0.0
for thepkg-version
, thereby re-installing applications already installed. The fix for this is to replacereadPlistFromString
withloads
.