code: def runGetResults(cmd, stdout=True, stderr=True, encoding=sys.getdefaultencoding()):
          '''
              runGetResults - Simple method to run a command and return the results of the execution as a dict.
              @param cmd <str/list> - String of command and arguments, or list of command and arguments
                  If cmd is a string, the command will be executed as if ran exactly as written in a shell. This mode supports shell-isms like '&&' and '|'
                  If cmd is a list, the first element will be the executable, and further elements are arguments that will be passed to that executable.
              @param stdout <True/False> - Default True, Whether to gather and include program's stdout data in results.
                  If False, that data the program prints to stdout will just be output to the current tty and not recorded.
                  If True, it will NOT be output to the tty, and will be recorded under the key "stdout" in the return dict.
              @param stderr <True/False or "stdout"/subprocess.STDOUT> - Default True, Whether to gather and include program's stderr data in results, or to combine with "stdout" data.
                  If False, the data the program prints to stderr will just be output to the current tty and not recorded
                  If True, it will NOT be output to the tty, and will be recorded under the key "stderr" in the return dict.
                  If "stdout" or subprocess.STDOUT - stderr data will be blended with stdout data. This requires that stdout=True.
              @param encoding <None/str> - Default sys.getdefaultencoding(), the program's output will automatically be decoded using the provided codec (e.x. "utf-8" or "ascii").
                  If None or False-ish, data will not be decoded (i.e. in python3 will be "bytes" type)
                  If unsure, leave this as it's default value, or provide "utf-8"
              @return <dict> - Dict of results. Has following keys:
                  'returnCode' - <int> - Always present, included the integer return-code from the command.
                  'stdout'       <unciode/str/bytes (depending on
                  'stderr'       <unicode/str/bytes (depending on
              @raises - SimpleCommandFailure if it cannot launch the given command, for reasons such as: cannot find the executable, or no permission to execute, etc
          '''
          if stderr in ('stdout', subprocess.STDOUT):
              stderr = subprocess.STDOUT
          elif stderr == True or stderr == subprocess.PIPE:
              stderr = subprocess.PIPE
          else:
              stderr = None
          if stdout == True or stdout == subprocess.STDOUT:
              stdout = subprocess.PIPE
          else:
              stdout = None
              if stderr == subprocess.PIPE:
                  raise ValueError('Cannot redirect stderr to stdout if stdout is not captured.')
          if issubclass(cmd.__class__, (list, tuple)):
              shell = False
          else:
              shell = True
          try:
              pipe = subprocess.Popen(cmd, stdout=stdout, stderr=stderr, shell=shell)
          except Exception as e:
              try:
                  if shell is True:
                      cmdStr = ' '.join(cmd)
                  else:
                      cmdStr = cmd
              except:
                  cmdStr = repr(cmd)
              raise SimpleCommandFailure('Failed to execute "%s": %s' %(cmdStr, str(e)), returnCode=255)
          streams = []
          fileNoToKey = {}
          ret = {}
          if stdout == subprocess.PIPE:
              streams.append(pipe.stdout)
              fileNoToKey[pipe.stdout.fileno()] = 'stdout'
              ret['stdout'] = []
          if stderr == subprocess.PIPE:
              streams.append(pipe.stderr)
              fileNoToKey[pipe.stderr.fileno()] = 'stderr'
              ret['stderr'] = []
          returnCode = None
          time.sleep(.02)
          while returnCode is None or streams:
              returnCode = pipe.poll()
              while True:
                  (readyToRead, junk1, junk2) = select.select(streams, [], [], .005)
                  if not readyToRead:
                      time.sleep(.01)
                      break
                  for readyStream in readyToRead:
                      retKey = fileNoToKey[readyStream.fileno()]
                      curRead = readyStream.read()
                      if curRead in (b'', ''):
                          streams.remove(readyStream)
                          continue
                      ret[retKey].append(curRead)
          for key in list(ret.keys()):
              ret[key] = b''.join(ret[key])
              if encoding:
                  ret[key] = ret[key].decode(encoding)
          ret['returnCode'] = returnCode
          return ret