aurweb.spawn: Support stdout redirections to non-tty

Only ttys have a terminal size. If we can’t obtain it, we’ll just use 80
as a sane default.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
This commit is contained in:
Frédéric Mangano-Tarumi 2020-07-27 14:43:48 +02:00 committed by Lukas Fleischer
parent 445a991ef1
commit a1a742b518

View file

@ -87,12 +87,16 @@ def start():
return return
atexit.register(stop) atexit.register(stop)
try:
terminal_width = os.get_terminal_size().columns
except OSError:
terminal_width = 80
print("{ruler}\n" print("{ruler}\n"
"Spawing PHP and FastAPI, then nginx as a reverse proxy.\n" "Spawing PHP and FastAPI, then nginx as a reverse proxy.\n"
"Check out {aur_location}\n" "Check out {aur_location}\n"
"Hit ^C to terminate everything.\n" "Hit ^C to terminate everything.\n"
"{ruler}" "{ruler}"
.format(ruler=("-" * os.get_terminal_size().columns), .format(ruler=("-" * terminal_width),
aur_location=aurweb.config.get('options', 'aur_location'))) aur_location=aurweb.config.get('options', 'aur_location')))
# PHP # PHP