Skip to content

Commit

Permalink
Don't enable_echo when we don't have a tty
Browse files Browse the repository at this point in the history
The following termios calls will fail (and unnecessarily).

Change-Id: I261ac4bbb6eac29df02bdd458aa65322ad81f316
Closes-bug: #1243845
  • Loading branch information
asalkeld committed Oct 23, 2013
1 parent 3e0ffc4 commit e85fe34
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions marconi/common/cli.py
Expand Up @@ -17,6 +17,7 @@
from __future__ import print_function
import atexit
import functools
import os
import sys
import termios

Expand All @@ -43,6 +44,10 @@ def _enable_echo(enable):
:param enable: pass True to enable echo, False to disable
"""
if not os.isatty(sys.stdin.fileno()):
# if we are not running in an interactive shell we will get
# termios.error: (25, 'Inappropriate ioctl for device')
return

fd = sys.stdin.fileno()
new_attr = termios.tcgetattr(fd)
Expand Down

0 comments on commit e85fe34

Please sign in to comment.