On 13Mar2015 10:17, Skip Montanaro <skip.montan...@gmail.com> wrote:
I have this tweak I'd like to make to the top command (Linux only is fine).
[...] However... I have a feeling I might be fairly seriously
challenged trying to work with top's raw output, as it probably does
something more sophisticated than clear the screen and spit out rows. Will
I be in over my head trying to tweak the output? Hmmm... maybe if I tell
top TERM=dumb?

You may need to tell it TERM=dumb, though it might also refuse to run.

Like many full screen terminal apps, top is built on top of curses or ncurses; these libraries try to do minimal tty output, so they maintain an in memory image of the screen and only emit the terminal sequences requires to update changes. Much escape sequence parsing etc if you want to hack their output.

Now, if TERM-dumb is a no-go with top, another alternative is to write your own terminal definition (not trivial, but not too hard either as you don't need to implement all the operations, or even many of them: curses, given _sufficient_ capabilities, will figure it out). You might write an easy to parse terminal definition and run your own parser, and have _it_ output to python curses (with the correct $TERM on the output side).

But I suspect it might be just as easy to implement your own top by parsing stuff from /proc.

Your call...

Cheers,
Cameron Simpson <c...@zip.com.au>
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to