def quoteIfNeeded(txt, quoteChar='"'):
  """
  quoteIfNeededtxt)
  
  surrounds txt with quotes if txt includes spaces or the quote char
  """
  if isinstance(txt, bytes):
    txt=txt.decode()
  if txt.find(quoteChar) or txt.find(' '):
    return "%s%s%s" % (quoteChar, txt.replace(quoteChar, "\\%s" % quoteChar), quoteChar)
  return txt