[1/2] aurweb.spawn: Support stdout redirections to non-tty

Message ID 20200727124348.GA462322@tsubame.mg0.fr
State New
Headers show
Series [1/2] aurweb.spawn: Support stdout redirections to non-tty | expand

Commit Message

Frédéric Mangano-Tarumi July 27, 2020, 12:43 p.m. UTC
Only ttys have a terminal size. If we can’t obtain it, we’ll just use 80
as a sane default.
---
 aurweb/spawn.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Lukas Fleischer July 27, 2020, 9:38 p.m. UTC | #1
On Mon, 27 Jul 2020 at 08:43:48, Frédéric Mangano-Tarumi wrote:
> Only ttys have a terminal size. If we can\u2019t obtain it, we\u2019ll just use 80
> as a sane default.
> ---
>  aurweb/spawn.py | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)

Merged, thanks!

Patch

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