mirror of
https://github.com/acidanthera/OpenCorePkg.git
synced 2025-12-08 19:25:01 +00:00
macrecovery: Fix error when running headless (#550)
macrecovery: Fix error when running headless --------- Co-authored-by: Mike Beaton <mjsbeaton@gmail.com>
This commit is contained in:
parent
8ee5b37a3f
commit
a5a5e3ec75
@ -44,6 +44,8 @@ INFO_SIGN_HASH = 'CH'
|
||||
INFO_SIGN_SESS = 'CT'
|
||||
INFO_REQURED = [INFO_PRODUCT, INFO_IMAGE_LINK, INFO_IMAGE_HASH, INFO_IMAGE_SESS, INFO_SIGN_LINK, INFO_SIGN_HASH, INFO_SIGN_SESS]
|
||||
|
||||
# Use -2 for better resize stability on Windows
|
||||
TERMINAL_MARGIN = 2
|
||||
|
||||
def run_query(url, headers, post=None, raw=False):
|
||||
if post is not None:
|
||||
@ -223,10 +225,9 @@ def save_image(url, sess, filename='', directory=''):
|
||||
break
|
||||
fh.write(chunk)
|
||||
size += len(chunk)
|
||||
terminalsize = os.get_terminal_size().columns
|
||||
terminalsize = max(os.get_terminal_size().columns - TERMINAL_MARGIN, 0)
|
||||
if oldterminalsize != terminalsize:
|
||||
# Use -2 for better resize stability on Windows
|
||||
print(f'\r{"":<{terminalsize - 2}}', end='')
|
||||
print(f'\r{"":<{terminalsize}}', end='')
|
||||
oldterminalsize = terminalsize
|
||||
if totalsize > 0:
|
||||
progress = size / totalsize
|
||||
@ -249,7 +250,8 @@ def verify_image(dmgpath, cnkpath):
|
||||
|
||||
with open(dmgpath, 'rb') as dmgf:
|
||||
for cnkcount, (cnksize, cnkhash) in enumerate(verify_chunklist(cnkpath), 1):
|
||||
print(f'\r{f"Chunk {cnkcount} ({cnksize} bytes)":<{os.get_terminal_size().columns - 2}}', end='')
|
||||
terminalsize = max(os.get_terminal_size().columns - TERMINAL_MARGIN, 0)
|
||||
print(f'\r{f"Chunk {cnkcount} ({cnksize} bytes)":<{terminalsize}}', end='')
|
||||
sys.stdout.flush()
|
||||
cnk = dmgf.read(cnksize)
|
||||
if len(cnk) != cnksize:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user