[Numpy-discussion] Silencing NumPy output

David Cournapeau cournape at gmail.com
Fri Nov 15 14:28:29 EST 2013


On Fri, Nov 15, 2013 at 6:21 PM, Charles R Harris <charlesr.harris at gmail.com
> wrote:

>
>
>
> On Fri, Nov 15, 2013 at 11:05 AM, Frédéric Bastien <nouiz at nouiz.org>wrote:
>
>> I found a line like this in the file:
>>
>> numpy/distutils/fcompiler/__init__.py
>>
>> I changed the -2 to 2, but it didn't change anything. In fact, this
>> line wasn't called.
>>
>> The fct set_verbosity() is called only once, with the value of 0. The
>> default value set at import. If I change that to 2 or -2, it do not
>> change anything.
>>
>> I think that the problem is related to the exec_command as you told.
>> It seam it call it in a way that don't take the stdout/stderr set in
>> Python. So I can't redirect it. The problem is that is use os.system()
>> and we can't redirect its stdout/stderr.
>>
>> What about replacing the os.system call to  subprocess.Popen? This
>> would allow us to catch the stdout/stderr. We use this call in Theano
>> and it is compatible with python 2.4.
>>
>>
> Numpy 1.8 doesn't support python 2.4 in any case, so that isn't a problem
> ;)
>
> Sure, give it a shot. Looks like subprocess.Popen was intended to replace
> os.system in any case.
>

Except that output is not 'real time' with straight Popen, and doing so
reliably on every platform (cough - windows - cough) is not completely
trivial. You also have to handle buffered output, etc... That code is very
fragile, so this would be quite a lot of testing to change, and I am not
sure it worths it.

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20131115/095c29f7/attachment.html>


More information about the NumPy-Discussion mailing list