class_docstr: Runs a shell command in a 'with' context.
  
  This implementation is Win32-specific.
  
  Example:
      # Runs the command interactively with default console stdin/stdout
      with ShellCommandController('python -i') as scc:
          scc.run()
  
      # Runs the command using the provided functions for stdin/stdout
      def my_stdout_func(s):
          # print or save the string 's'
          write_to_stdout(s)
      def my_stdin_func():
          # If input is available, return it as a string.
          if input_available():
              return get_input()
          # If no input available, return None after a short delay to
          # keep from blocking.
          else:
              time.sleep(0.01)
              return None
    
      with ShellCommandController('python -i') as scc:
          scc.run(my_stdout_func, my_stdin_func)
class_docstr_tok: ["Runs","a","shell","command","in","a","'with","'","context",".","This","implementation","is","Win32-specific",".","Example",":","#","Runs","the","command","interactively","with","default","console","stdin\/stdout","with","ShellCommandController","(","'python","-i","'",")","as","scc",":","scc.run","(",")","#","Runs","the","command","using","the","provided","functions","for","stdin\/stdout","def","my_stdout_func","(","s",")",":","#","print","or","save","the","string","'s'","write_to_stdout","(","s",")","def","my_stdin_func","(",")",":","#","If","input","is","available",",","return","it","as","a","string",".","if","input_available","(",")",":","return","get_input","(",")","#","If","no","input","available",",","return","None","after","a","short","delay","to","#","keep","from","blocking",".","else",":","time.sleep","(","0.01",")","return","None","with","ShellCommandController","(","'python","-i","'",")","as","scc",":","scc.run","(","my_stdout_func",",","my_stdin_func",")"]
docstr: Use a blocking stdin read
docstr_tok: ["Use","a","blocking","stdin","read"]
code: def _stdin_raw_block(self):
      """Use a blocking stdin read"""
      # The big problem with the blocking read is that it doesn't
      # exit when it's supposed to in all contexts. An extra
      # key-press may be required to trigger the exit.
      try:
          data = sys.stdin.read(1)
          data = data.replace("\r", "\n")
          return data
      except WindowsError as we:
          if we.winerror == ERROR_NO_DATA:
              # This error occurs when the pipe is closed
              return None
          else:
              # Otherwise let the error propagate
              raise we
  
imports: import os, sys, threading
  import ctypes, msvcrt
  from ctypes import POINTER
  from ctypes.wintypes import HANDLE, HLOCAL, LPVOID, WORD, DWORD, BOOL, ULONG, LPCWSTR
label_desc: Use image node_id 7 for calling the Win32ShellCommandController obj's underlying member method code with example usage: obj._stdin_raw_block() and returns: data, None