Added error handling to sys_command's peak function.

This commit is contained in:
Anton Hvornum 2021-04-04 15:13:06 +02:00
parent 2f6a71756a
commit 81822e6444
No known key found for this signature in database
GPG Key ID: F1234C5BA67C59DF
2 changed files with 9 additions and 3 deletions

View File

@ -159,10 +159,16 @@ class sys_command():#Thread):
'exit_code': self.exit_code
}
def peak(self, output):
def peak(self, output :str):
if type(output) == bytes:
try:
output = output.decode('UTF-8')
except UnicodeDecodeError:
return None
if self.peak_output:
from .user_interaction import get_terminal_width
# Move back to the beginning of the terminal
sys.stdout.flush()
sys.stdout.write("\033[%dG" % 0)

View File

@ -137,7 +137,7 @@ class Installer():
self.log(f'Installing packages: {packages}', level=LOG_LEVELS.Info)
if (sync_mirrors := sys_command('/usr/bin/pacman -Syy')).exit_code == 0:
if (pacstrap := sys_command(f'/usr/bin/pacstrap {self.mountpoint} {" ".join(packages)}', **kwargs)).exit_code == 0:
if (pacstrap := sys_command(f'/usr/bin/pacstrap {self.mountpoint} {" ".join(packages)}', peak_output=True, **kwargs)).exit_code == 0:
return True
else:
self.log(f'Could not strap in packages: {pacstrap.exit_code}', level=LOG_LEVELS.Info)