comparison mercurial/util.py @ 8347:a3826fff1e87

util.termwidth: a file-like object may legitimately lack a fileno() method Spotted in the wild when running a hook while pushing over HTTPS.
author Bryan O'Sullivan <bos@serpentine.com>
date Mon, 11 May 2009 11:53:27 -0700
parents fce065538bcf
children beae42f3d93b
comparison
equal deleted inserted replaced
8346:b579823cc546 8347:a3826fff1e87
1436 pass 1436 pass
1437 try: 1437 try:
1438 import termios, array, fcntl 1438 import termios, array, fcntl
1439 for dev in (sys.stdout, sys.stdin): 1439 for dev in (sys.stdout, sys.stdin):
1440 try: 1440 try:
1441 fd = dev.fileno() 1441 try:
1442 fd = dev.fileno()
1443 except AttributeError:
1444 continue
1442 if not os.isatty(fd): 1445 if not os.isatty(fd):
1443 continue 1446 continue
1444 arri = fcntl.ioctl(fd, termios.TIOCGWINSZ, '\0' * 8) 1447 arri = fcntl.ioctl(fd, termios.TIOCGWINSZ, '\0' * 8)
1445 return array.array('h', arri)[1] 1448 return array.array('h', arri)[1]
1446 except ValueError: 1449 except ValueError: