              atexit.register(self.set_normal_term)
  
      def set_normal_term(self):
          """ Resets to normal terminal.  On Windows this is a no-op. """
          if os.name == "nt" or self.is_gui:
              pass
          else:
              termios.tcsetattr(self.file_desc, termios.TCSAFLUSH, self.old_term)
  
      def getch(self):
 
</s> remove         if os.name == "nt" or self.is_gui:
 </s> add         if os.name == "nt" or self.is_gui or not sys.stdout.isatty(): </s> remove         if self.is_gui and os.name != "nt":
 </s> add         if self.is_gui and os.name != "nt" or not sys.stdout.isatty(): </s> remove         if self.is_gui and os.name != "nt":
 </s> add         if self.is_gui and os.name != "nt" or not sys.stdout.isatty(): </s> remove         if self.is_gui:
 </s> add         if self.is_gui or not sys.stdout.isatty(): </s> remove         logger.info("  Press '%s' to save and quit",
 </s> add         if sys.stdout.isatty():
            logger.info("  Press '%s' to save and quit",
        if os.name == "nt" or self.is_gui or not sys.stdout.isatty():
              atexit.register(self.set_normal_term)
  
      def set_normal_term(self):
          """ Resets to normal terminal.  On Windows this is a no-op. """
        if os.name == "nt" or self.is_gui or not sys.stdout.isatty():
              pass
          else:
              termios.tcsetattr(self.file_desc, termios.TCSAFLUSH, self.old_term)
  
      def getch(self):
keep keep keep keep replace keep keep keep keep keep
 trainer: add support for non-interactive jobs (#1193)

Add support for training in non-interactive shell environment such
as Sun Grid Engine, Univa Grid Engine and others.

Tested on Univa Grid Engine.

Reference: https://stackoverflow.com/questions/967369/python-find-out-if-running-in-shell-or-not-e-g-sun-grid-engine-queue. 
lib/keypress.py