def _read(self, n): """Read n bytes from image display and return as string Raises IOError on failure. If a tkinter widget exists, runs a Tk mainloop while waiting for data so that the Tk widgets remain responsive. """ try: return irafutils.tkread(self._fdin, n) except (EOFError, IOError): raise IOError("Error reading from image display")
def _read(self, n): """Read n bytes from image display and return as string Raises IOError on failure. If a Tkinter widget exists, runs a Tk mainloop while waiting for data so that the Tk widgets remain responsive. """ try: return irafutils.tkread(self._fdin, n) except (EOFError, IOError): raise IOError("Error reading from image display")
def getSingleTTYChar(): # return type str in all Python versions """Returns None if Control-C is typed or any other exception occurs""" # Ripped off from python FAQ fd = sys.stdin.fileno() old = termios.tcgetattr(fd) new = termios.tcgetattr(fd) new[3] = new[3] & ~(termios.ICANON | termios.ECHO | termios.ISIG) new[6][termios.VMIN] = 1 new[6][termios.VTIME] = 0 termios.tcsetattr(fd, termios.TCSANOW, new) c = None try: # allow Tk mainloop to run while waiting... # vanilla version would be c = os.read(fd, 1) if capable.OF_GRAPHICS: c = irafutils.tkread(fd, 1) else: c = os.read(fd, 1).decode(errors='replace') finally: termios.tcsetattr(fd, termios.TCSAFLUSH, old) return c
def getSingleTTYChar(): # return type str in all Python versions """Returns None if Control-C is typed or any other exception occurs""" # Ripped off from python FAQ fd = sys.stdin.fileno() old = termios.tcgetattr(fd) new = termios.tcgetattr(fd) new[3] = new[3] & ~(TERMIOS.ICANON | TERMIOS.ECHO | TERMIOS.ISIG) new[6][TERMIOS.VMIN] = 1 new[6][TERMIOS.VTIME] = 0 termios.tcsetattr(fd, TERMIOS.TCSANOW, new) c = None try: # allow Tk mainloop to run while waiting... # vanilla version would be c = os.read(fd, 1) if capable.OF_GRAPHICS: c = irafutils.tkread(fd, 1) else: c = os.read(fd, 1) if for2to3.PY3K: c = c.decode('ascii') finally: termios.tcsetattr(fd, TERMIOS.TCSAFLUSH, old) return c