Skip to content
This repository has been archived by the owner on May 17, 2020. It is now read-only.

Commit

Permalink
macrecovery: Fixed python3 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
vit9696 committed Nov 20, 2019
1 parent fd02c48 commit 983c84e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ MacInfoPkg changelog
====================
#### v2.0.9
- Added MacBookPro16,1 model codes
- Fixed python3 compatibility for macrecovery

#### v2.0.8
- Fixed Production Years
Expand Down
7 changes: 6 additions & 1 deletion macrecovery/macrecovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
def run_query(url, headers, post=None):
if post is not None:
data = '\n'.join([entry + '=' + post[entry] for entry in post])
if sys.version_info[0] >= 3:
data = data.encode('utf-8')
else:
data = None

Expand Down Expand Up @@ -114,6 +116,9 @@ def get_image_info(session, bid, mlb=MLB_ZERO, diag = False, os_type = 'default'

headers, output = run_query(url, headers, post)

if sys.version_info[0] >= 3:
output = output.decode('utf-8')

info = {}
for line in output.split('\n'):
try:
Expand Down Expand Up @@ -144,7 +149,7 @@ def save_image(url, sess, filename='', dir=''):

print('Saving ' + url + ' to ' + filename + '...')

with open (os.path.join(dir, filename), 'w') as fh:
with open (os.path.join(dir, filename), 'wb') as fh:
fh.write(run_query(url, headers)[1])

def action_download(args):
Expand Down

0 comments on commit 983c84e

Please sign in to comment.