[issue17647] subprocess.communicate() should preserve colored output on Windows

2013-04-12 Thread Terry J. Reedy

Terry J. Reedy added the comment:

We seem to agree that this is an OS+application issue, not a Python issue.

I think the red FAILEDs would be nice for unittest (a possible separate issue).

--
nosy: +terry.reedy
resolution:  - invalid
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17647
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17647] subprocess.communicate() should preserve colored output on Windows

2013-04-12 Thread Caitlin Potter

Caitlin Potter added the comment:

A suggestion to work around this from #waf on freenode:
http://codepad.org/1Y8K9e2m

So it is probably not a big deal and can be wrapped up. But still it would
be nice if Windows had native support for ANSI colours.

On Fri, Apr 12, 2013 at 2:08 PM, Terry J. Reedy rep...@bugs.python.orgwrote:


 Terry J. Reedy added the comment:

 We seem to agree that this is an OS+application issue, not a Python issue.

 I think the red FAILEDs would be nice for unittest (a possible separate
 issue).

 --
 nosy: +terry.reedy
 resolution:  - invalid
 status: open - closed

 ___
 Python tracker rep...@bugs.python.org
 http://bugs.python.org/issue17647
 ___


--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17647
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17647] subprocess.communicate() should preserve colored output on Windows

2013-04-12 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Caitlin, when you reply by email, please snip the previous post as I 
have here, as it is already displayed directly above the reply on the 
website.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17647
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17647] subprocess.communicate() should preserve colored output on Windows

2013-04-12 Thread Caitlin Potter

Caitlin Potter added the comment:

Sorry Terry, gmail hides it by default, didn't notice.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17647
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17647] subprocess.communicate() should preserve colored output on Windows

2013-04-07 Thread Richard Oudkerk

Richard Oudkerk added the comment:

I don't see how this is a subprocess problem, or could be fixed in subprocess.

IIUC, SetConsoleTextAttribute() only has an effect if the output is connected 
to a console.  But that is not the case if you redirect the output to a pipe 
(which is presumably what Waf does so it can capture the output).

--
nosy: +sbt

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17647
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17647] subprocess.communicate() should preserve colored output on Windows

2013-04-07 Thread R. David Murray

R. David Murray added the comment:

Oh, good, I thought that was probably the case but I don't know Windows enough 
to have been sure.

Caitlin: if you can prove sbt and me wrong by writing a patch that works 
(without breaking anything else :), I think it would be considered.  Certainly 
on unix if you write ANSI color codes to stdout and the reader doesn't strip 
them, they will be preserved and can be redisplayed, so being able to do 
something similar on Windows would be nice.  I'm pretty sure there isn't any 
place stdout.read() is called, though.  The stdout output from the originating 
process will be being read by a different process via stdin.read().  And as sbt 
pointed out, neither one of those will be a console.

--
nosy: +r.david.murray

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17647
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17647] subprocess.communicate() should preserve colored output on Windows

2013-04-07 Thread Richard Oudkerk

Richard Oudkerk added the comment:

On 07/04/2013 7:21pm, R. David Murray wrote:
 Certainly on unix if you write ANSI color codes to stdout and the reader
 doesn't strip them, they will be preserved and can be redisplayed, so
 being able to do something similar on Windows would be nice.

Although sensible unix programs capable of producing coloured text 
refuse to do so (by default) if output is a pipe rather than a tty.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17647
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17647] subprocess.communicate() should preserve colored output on Windows

2013-04-07 Thread Caitlin Potter

Caitlin Potter added the comment:

I'm not entirely positive that it would be doable, but looking at the
subprocess code, it looks like we do have an open handle to the windows
stdout buffer, including buffer attributes, so it should be possible to
translate coloured attributes into ANSI codes,

Whether this would or would not break anything else is a different story,
of course. Obviously there are times where you wouldn't want ANSI color
codes in the output, and I'm not sure how you could differentiate between a
pipe to a terminal buffer, or a pipe to a file.

Somewhat relevant, but perhaps not so much:
The google test framework does actually test isatty() before using ANSI
escape characters, however I've tested this same test program in a
development environment, with colours preserved, which was a bit curious
(the test I've put together is available at http://github.com/caitp/waftest,
however it will break on a lot of systems, depending on the way pthread
needs to be used)

On Sun, Apr 7, 2013 at 2:39 PM, Richard Oudkerk rep...@bugs.python.orgwrote:


 Richard Oudkerk added the comment:

 On 07/04/2013 7:21pm, R. David Murray wrote:
  Certainly on unix if you write ANSI color codes to stdout and the reader
  doesn't strip them, they will be preserved and can be redisplayed, so
  being able to do something similar on Windows would be nice.

 Although sensible unix programs capable of producing coloured text
 refuse to do so (by default) if output is a pipe rather than a tty.

 --

 ___
 Python tracker rep...@bugs.python.org
 http://bugs.python.org/issue17647
 ___


--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17647
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17647] subprocess.communicate() should preserve colored output on Windows

2013-04-07 Thread Caitlin Potter

Caitlin Potter added the comment:

 however I've tested this same test program in a
 development environment,

*unix* development environment (xterm, ubuntu 12.04), rather.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17647
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17647] subprocess.communicate() should preserve colored output on Windows

2013-04-07 Thread Richard Oudkerk

Richard Oudkerk added the comment:

On 07/04/2013 9:02pm, Caitlin Potter wrote:
 I'm not entirely positive that it would be doable, but looking at the
 subprocess code, it looks like we do have an open handle to the windows
 stdout buffer, including buffer attributes, so it should be possible to
 translate coloured attributes into ANSI codes,

The handle for stdout is just the readable end of a pipe.  It is not a 
console, GetConsoleScreenBufferInfo() will not work with it, and there 
are no coloured attributes associated with it.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17647
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17647] subprocess.communicate() should preserve colored output on Windows

2013-04-07 Thread Caitlin Potter

Caitlin Potter added the comment:

Then perhaps nothing can be done from the python side of things, that's too
bad.

On Sun, Apr 7, 2013 at 4:38 PM, Richard Oudkerk rep...@bugs.python.orgwrote:


 Richard Oudkerk added the comment:

 On 07/04/2013 9:02pm, Caitlin Potter wrote:
  I'm not entirely positive that it would be doable, but looking at the
  subprocess code, it looks like we do have an open handle to the windows
  stdout buffer, including buffer attributes, so it should be possible to
  translate coloured attributes into ANSI codes,

 The handle for stdout is just the readable end of a pipe.  It is not a
 console, GetConsoleScreenBufferInfo() will not work with it, and there
 are no coloured attributes associated with it.

 --

 ___
 Python tracker rep...@bugs.python.org
 http://bugs.python.org/issue17647
 ___


--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17647
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17647] subprocess.communicate() should preserve colored output on Windows

2013-04-06 Thread Caitlin Potter

New submission from Caitlin Potter:

In migrating from GNU autoconf/automake build systems to a python-based build 
system (Waf), I've been slightly annoyed that coloured text output from unit 
test programs is lost on the windows platform (the gtest framework uses 
::SetConsoleTextAttribute on windows)

Ideally, the coloured output from the test sets would be preserved so that 
problems could be easily identified and stand out (See attached image for 
demonstration of problem)

This might be scoffed at as a minor problem because nobody uses 
SetConsoleTextAttribute anyways, and even if they do it would only affect the 
windows platform. But just the same, preserving coloured output on windows 
should be doable.

I'd be happy to work on a patch for this myself, but I'm new to the python tree 
and am not completely sure where to find what I'm looking for. I think an if 
mswindows: clause wherever stdout.read() is would probably work, but I'm not 
sure where that would be.

--
components: IO, Windows
files: unit-tests.png
messages: 186168
nosy: Caitlin.Potter
priority: normal
severity: normal
status: open
title: subprocess.communicate() should preserve colored output on Windows
type: behavior
versions: Python 2.7
Added file: http://bugs.python.org/file29699/unit-tests.png

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17647
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com