Skip to content

Commit

Permalink
fix generatejson
Browse files Browse the repository at this point in the history
  • Loading branch information
erikng committed Feb 27, 2020
1 parent f18e864 commit daf7a75
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions generatejson.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ def getpkginfopath(filename):
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
(bom, err) = proc.communicate()
bom = bom.strip().split('\n')
bom = bom.strip().split(b'\n')
if proc.returncode == 0:
for entry in bom:
if entry.startswith('PackageInfo'):
if entry.startswith(b'PackageInfo'):
return entry
elif entry.endswith('.pkg/PackageInfo'):
elif entry.endswith(b'.pkg/PackageInfo'):
return entry
else:
print("Error: %s while extracting BOM for %s" % (err, filename))
Expand All @@ -71,7 +71,7 @@ def extractpkginfo(filename):
tmpFolder = tempfile.mkdtemp()
os.chdir(tmpFolder)
# need to get path from BOM
pkgInfoPath = getpkginfopath(filename)
pkgInfoPath = getpkginfopath(filename).decode('utf-8')

extractedPkgInfoPath = os.path.join(tmpFolder, pkgInfoPath)
cmd = ['/usr/bin/xar', '-xf', filename, pkgInfoPath]
Expand All @@ -94,8 +94,8 @@ def getpkginfo(filename):
dom = minidom.parse(pkgInfoPath)
pkgRefs = dom.getElementsByTagName('pkg-info')
for ref in pkgRefs:
pkgId = ref.attributes['identifier'].value.encode('UTF-8')
pkgVersion = ref.attributes['version'].value.encode('UTF-8')
pkgId = ref.attributes['identifier'].value
pkgVersion = ref.attributes['version'].value
return pkgId, pkgVersion


Expand Down

3 comments on commit daf7a75

@captam3rica
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works in my env!

@erikng
Copy link
Member Author

@erikng erikng commented on daf7a75 Feb 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Sorry about all the back and forth on this.

@captam3rica
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries! Glad to find a solution :)

Please sign in to comment.