[issue35060] subprocess output seems to depend on size of terminal screen

2018-10-24 Thread Edward Pratt


New submission from Edward Pratt :

I am looking for a string inside of a process, and it seems that the output of 
the check_output command depends on the screen size of the terminal I run the 
code in. 

Here I ran the code with a normal screen resolution:
>>> result = subprocess.check_output(['ps', 'aux']).decode('ascii', 
>>> errors='ignore')
>>> 'app-id' in result
False
 
Then I zoom out to the point where I can barely read the text on the screen, 
and this is the output I get:
>>> result = subprocess.check_output(['ps', 'aux']).decode('ascii', 
>>> errors='ignore')
>>> 'app-id' in result
True

--
components: Demos and Tools
messages: 328371
nosy: epsolos
priority: normal
severity: normal
status: open
title: subprocess output seems to depend on size of terminal screen
type: behavior
versions: Python 3.5

___
Python tracker 
<https://bugs.python.org/issue35060>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35060] subprocess output seems to depend on size of terminal screen

2018-10-24 Thread Edward Pratt

Edward Pratt  added the comment:

I don’t think that is true. I tried grepping for what I need in a very small 
terminal and still got the correct result.

> On Oct 24, 2018, at 1:40 PM, Eryk Sun  wrote:
> 
> 
> Eryk Sun  added the comment:
> 
> This is due to the ps command itself. You'd have the same problem when piping 
> to grep or redirecting output to a file. I don't know how it determines 
> terminal size. I tried overriding stdin, stdout and stderr to pipes and 
> calling setsid() in the forked child process to detach from the controlling 
> terminal, but it still detected the terminal size. Anyway, the "ww" option of 
> ps overrides this behavior.
> 
> --
> nosy: +eryksun
> resolution:  -> third party
> stage:  -> resolved
> status: open -> closed
> 
> ___
> Python tracker 
> <https://bugs.python.org/issue35060>
> ___

--

___
Python tracker 
<https://bugs.python.org/issue35060>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35060] subprocess output seems to depend on size of terminal screen

2018-10-24 Thread Edward Pratt

Edward Pratt  added the comment:

You are correct. It works as expected outside of the REPL.

> On Oct 24, 2018, at 4:34 PM, Stéphane Wirtel  wrote:
> 
> 
> Stéphane Wirtel  added the comment:
> 
> My script:
> 
> #!/usr/bin/env python
> import pathlib
> import subprocess
> 
> output = subprocess.check_output(['ps', 'aux'])
> pathlib.Path('/tmp/ps_aux.txt').write_bytes(output)
> 
> 
> When I execute the following script in the REPL, I get your issue but for me, 
> it's normal because the REPL is running in a terminal with a limited size. 
> 
> And when I execute the same script like as a simple python script, I don't 
> have your issue.
> 
> --
> status: closed -> open
> 
> ___
> Python tracker 
> <https://bugs.python.org/issue35060>
> ___

--

___
Python tracker 
<https://bugs.python.org/issue35060>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com