aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZev Weiss <zev@bewilderbeest.net>2016-11-26 20:11:35 -0600
committerZev Weiss <zev@bewilderbeest.net>2016-11-27 00:38:17 -0600
commitbb65cf158c22f0dabb7adecab3b86c2b9f3b8732 (patch)
tree5d7e1bdd3d5e77efc8a29a927c4c5829a1cc3314
parent83c9e4e4c15a4f5f9876b927c257ce7307377623 (diff)
downloadvirtme-bb65cf158c22f0dabb7adecab3b86c2b9f3b8732.tar.gz
virtme-run: Handle non-tty stdout
Catch and ignore ENOTTY exceptions from os.get_terminal_size(). Signed-off-by: Zev Weiss <zev@bewilderbeest.net>
-rw-r--r--virtme/commands/run.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/virtme/commands/run.py b/virtme/commands/run.py
index 8a2a3d7..cd3396d 100644
--- a/virtme/commands/run.py
+++ b/virtme/commands/run.py
@@ -9,6 +9,7 @@ import argparse
import tempfile
import shutil
import os
+import errno
import fcntl
import sys
import shlex
@@ -260,9 +261,14 @@ def main():
# Fix the terminal defaults (and set iutf8 because that's a better
# default nowadays). I don't know of any way to keep this up to date
# after startup, though.
- terminal_size = os.get_terminal_size()
- kernelargs.extend(['virtme_stty_con=rows %d cols %d iutf8' %
- (terminal_size.lines, terminal_size.columns)])
+ try:
+ terminal_size = os.get_terminal_size()
+ kernelargs.extend(['virtme_stty_con=rows %d cols %d iutf8' %
+ (terminal_size.lines, terminal_size.columns)])
+ except OSError as e:
+ # don't die if running with a non-TTY stdout
+ if e.errno != errno.ENOTTY:
+ raise
# Propagate the terminal type
if 'TERM' in os.environ: