title: Python 3.4.3 subprocess.Popen get output of command without piping?
body: <p>I am trying to assign the output of a command to a variable without the command thinking that it is being piped. The reason for this is that the command in question gives unformatted text as output if it is being piped, but it gives color formatted text if it is being run from the terminal. I need to get this color formatted text.</p>
  
  <p>So far I've tried a few things. I've tried Popen like so:</p>
  
  <pre><code>output = subprocess.Popen(command, stdout=subprocess.PIPE)
  output = output.communicate()[0]
  output = output.decode()
  print(output)
  </code></pre>
  
  <p>This will let me print the output, but it gives me the unformatted output that I get when the command is piped. That makes sense, as I'm piping it here in the Python code. But I am curious if there is a way to assign the output of this command, directly to a variable, without the command running the piped version of itself.</p>
  
  <p>I have also tried the following version that relies on check_output instead:</p>
  
  <pre><code>output = subprocess.check_output(command)
  output = output.decode()
  print(output)
  </code></pre>
  
  <p>And again I get the same unformatted output that the command returns when the command is piped.</p>
  
  <p>Is there a way to get the formatted output, the output the command would normally give from the terminal, when it is not being piped?</p>