parameters: (command_args, **kwargs)
docstring: Executes a command and returns the string tuple (stdout, stderr)
      keyword argument timeout can be specified to time out command (defaults to 1 sec)
docstring_summary: Executes a command and returns the string tuple (stdout, stderr)
      keyword argument timeout can be specified to time out command (defaults to 1 sec)
docstring_tokens: Executes a command and returns the string tuple ( stdout stderr ) keyword argument timeout can be specified to time out command ( defaults to 1 sec )
function: def command_output(command_args, **kwargs):
      """ Executes a command and returns the string tuple (stdout, stderr)
      keyword argument timeout can be specified to time out command (defaults to 1 sec)
      """
      timeout = kwargs.pop("timeout", 1)
      def command_output_aux():
          try:
              proc = subprocess.Popen(command_args, stdout=subprocess.PIPE,
                                      stderr=subprocess.PIPE)
              return proc.communicate()
          except Exception as excp:
              return "", str(excp)
      if not timeout:
          return command_output_aux()
  
      exec_queue = queue.Queue()
      def execute_in_thread():
          exec_queue.put(command_output_aux())
      thrd = threading.Thread(target=execute_in_thread)
      thrd.start()
      try:
          return exec_queue.get(block=True, timeout=timeout)
      except queue.Empty:
          return "", "Timed out after %s seconds" % timeout
function_tokens: def command_output ( command_args , * * kwargs ) : timeout = kwargs . pop ( "timeout" , 1 ) def command_output_aux ( ) : try : proc = subprocess . Popen ( command_args , stdout = subprocess . PIPE , stderr = subprocess . PIPE ) return proc . communicate ( ) except Exception as excp : return "" , str ( excp ) if not timeout : return command_output_aux ( ) exec_queue = queue . Queue ( ) def execute_in_thread ( ) : exec_queue . put ( command_output_aux ( ) ) thrd = threading . Thread ( target = execute_in_thread ) thrd . start ( ) try : return exec_queue . get ( block = True , timeout = timeout ) except queue . Empty : return "" , "Timed out after %s seconds" % timeout