Added error handling to sys_command's peak function.
This commit is contained in:
parent
2f6a71756a
commit
81822e6444
|
|
@ -159,10 +159,16 @@ class sys_command():#Thread):
|
||||||
'exit_code': self.exit_code
|
'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:
|
if self.peak_output:
|
||||||
from .user_interaction import get_terminal_width
|
from .user_interaction import get_terminal_width
|
||||||
|
|
||||||
# Move back to the beginning of the terminal
|
# Move back to the beginning of the terminal
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
sys.stdout.write("\033[%dG" % 0)
|
sys.stdout.write("\033[%dG" % 0)
|
||||||
|
|
|
||||||
|
|
@ -137,7 +137,7 @@ class Installer():
|
||||||
self.log(f'Installing packages: {packages}', level=LOG_LEVELS.Info)
|
self.log(f'Installing packages: {packages}', level=LOG_LEVELS.Info)
|
||||||
|
|
||||||
if (sync_mirrors := sys_command('/usr/bin/pacman -Syy')).exit_code == 0:
|
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
|
return True
|
||||||
else:
|
else:
|
||||||
self.log(f'Could not strap in packages: {pacstrap.exit_code}', level=LOG_LEVELS.Info)
|
self.log(f'Could not strap in packages: {pacstrap.exit_code}', level=LOG_LEVELS.Info)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue