  class KBHit:
      """ Creates a KBHit object that you can call to do various keyboard things. """
      def __init__(self, is_gui=False):
          self.is_gui = is_gui
          if os.name == "nt" or self.is_gui:
              pass
          else:
              # Save the terminal settings
              self.file_desc = sys.stdin.fileno()
              self.new_term = termios.tcgetattr(self.file_desc)
 
</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:
 </s> add         if 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 not self._args.redirect_gui and not self._args.colab:
 </s> add         if not self._args.redirect_gui and not self._args.colab and sys.stdout.isatty():
        if os.name == "nt" or self.is_gui or not sys.stdout.isatty():
  class KBHit:
      """ Creates a KBHit object that you can call to do various keyboard things. """
      def __init__(self, is_gui=False):
          self.is_gui = is_gui
        if os.name == "nt" or self.is_gui or not sys.stdout.isatty():
              pass
          else:
              # Save the terminal settings
              self.file_desc = sys.stdin.fileno()
              self.new_term = termios.tcgetattr(self.file_desc)
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