  
      def getch(self):
          """ Returns a keyboard character after kbhit() has been called.
              Should not be called in the same program as getarrow(). """
          if self.is_gui and os.name != "nt":
              return None
          if os.name == "nt":
              return msvcrt.getch().decode("utf-8")
          return sys.stdin.read(1)
  
 
</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 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 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 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 self.is_gui and os.name != "nt" or not sys.stdout.isatty():
  
      def getch(self):
          """ Returns a keyboard character after kbhit() has been called.
              Should not be called in the same program as getarrow(). """
        if self.is_gui and os.name != "nt" or not sys.stdout.isatty():
              return None
          if os.name == "nt":
              return msvcrt.getch().decode("utf-8")
          return sys.stdin.read(1)
  
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