Skip to content

Commit

Permalink
Handle when underneath tests and no tty.
Browse files Browse the repository at this point in the history
  • Loading branch information
redshodan committed Sep 25, 2017
1 parent 2bc4008 commit d4fcf9f
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/eyed3/utils/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,10 +491,14 @@ def cformat(msg, fg, bg=None, styles=None):


def getTtySize(fd=sys.stdout, check_tty=True):
hw = None
if check_tty:
data = fcntl.ioctl(fd, termios.TIOCGWINSZ, '\0' * 4)
hw = struct.unpack("hh", data)
else:
try:
data = fcntl.ioctl(fd, termios.TIOCGWINSZ, '\0' * 4)
hw = struct.unpack("hh", data)
except:
pass
if not hw:
try:
hw = (int(os.environ.get('LINES')),
int(os.environ.get('COLUMNS')))
Expand Down

0 comments on commit d4fcf9f

Please sign in to comment.