minstall: check 5 times for an answer to the elevation prompt

The user might press enter by accident and miss the message.
pull/11366/head
Eli Schwartz 2 years ago
parent ecb32bf457
commit 55abcbb8f6
No known key found for this signature in database
GPG Key ID: CEB167EFB5722BD6
  1. 9
      mesonbuild/minstall.py

@ -566,10 +566,13 @@ class Installer:
if rootcmd is not None:
print('Installation failed due to insufficient permissions.')
ans = input(f'Attempt to use {rootcmd} to gain elevated privileges? [y/n] ')
if ans not in {'y', 'n'}:
for attempt in range(5):
ans = input(f'Attempt to use {rootcmd} to gain elevated privileges? [y/n] ')
if ans in {'y', 'n'}:
break
else:
raise MesonException('Answer not one of [y/n]')
elif ans == 'y':
if ans == 'y':
os.execlp(rootcmd, rootcmd, sys.executable, main_file, *sys.argv[1:],
'-C', os.getcwd(), '--no-rebuild')
raise

Loading…
Cancel
Save