diff options
author | Andrew Lutomirski <andy@luto.us> | 2016-11-27 10:59:42 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-27 10:59:42 -0800 |
commit | 4adb4fb3601215d3e059d37c60111b857095160a (patch) | |
tree | 5d7e1bdd3d5e77efc8a29a927c4c5829a1cc3314 | |
parent | 83c9e4e4c15a4f5f9876b927c257ce7307377623 (diff) | |
parent | bb65cf158c22f0dabb7adecab3b86c2b9f3b8732 (diff) | |
download | virtme-4adb4fb3601215d3e059d37c60111b857095160a.tar.gz |
Merge pull request #8 from zevweiss/non-tty-stdout
virtme-run: Handle non-tty stdout
-rw-r--r-- | virtme/commands/run.py | 12 |
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: |