get the terminal's size
Cameron Simpson
cs at cskk.id.au
Tue Jan 15 16:52:36 EST 2019
On 15Jan2019 13:08, Alex Ternaute <alex at lussinan.invalid> wrote:
>>>I tried : P = Popen(['stty', '-a'], stdout=subprocess.PIPE,
>>>universal_newlines=True) and it runs fine too, so the output seems not
>>>really related to that fd.
>
>> But it is! stty(1) fetches the terminal settings from its standard
>> input, so "fd" is used to supply this. In your Popen test case you
>> simply don't set the stdin parameter, so it is the Python process'
>> input. Which is usually what you want.
>
>> But I want to be able to ask this
>> of any terminal file, thus the parameter.
>
>Ah, Ok; smthlike:
> cs.tty.ttysize(0)
> WinSize(rows=50, columns=100)
> anotherTty=open('/dev/pts/3', 'rw')
> cs.tty.ttysize(anotherTty)
> WinSize(rows=43, columns=199)
>
>It runs :)
Exactly so.
BTW, you're aware of:
from cs.tty import ttysize
...
ttysize(0)
I presume, and the above is just your testing?
Cheers,
Cameron Simpson <cs at cskk.id.au>
More information about the Python-list
mailing list