Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #87449

Re: Pexpect idea - but can I handle curses?

Path csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <cameron@cskk.homeip.net>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.009
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'output': 0.05; 'apps,': 0.07; 'escape': 0.09; 'output,': 0.09; 'parsing': 0.09; 'python': 0.11; 'emit': 0.16; 'fine).': 0.16; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16; 'message-id:@cskk.homeip.net': 0.16; 'output?': 0.16; 'simpson': 0.16; 'spit': 0.16; 'tty': 0.16; 'tweak': 0.16; 'wrote:': 0.18; '(not': 0.18; 'trying': 0.19; 'command': 0.22; 'memory': 0.22; 'hack': 0.22; 'header:User-Agent:1': 0.23; 'parse': 0.24; 'skip': 0.24; 'fairly': 0.24; 'cheers,': 0.24; 'header:In-Reply-To:1': 0.27; 'correct': 0.29; 'operations,': 0.30; 'libraries': 0.31; 'probably': 0.32; 'figure': 0.32; 'stuff': 0.32; 'run': 0.32; 'another': 0.32; 'minimal': 0.33; 'raw': 0.33; 'screen': 0.34; 'maybe': 0.34; "i'd": 0.34; 'definition': 0.35; 'etc': 0.35; 'but': 0.35; 'sequence': 0.36; 'charset:us-ascii': 0.36; 'subject:?': 0.36; 'too': 0.37; 'clear': 0.37; 'implement': 0.38; 'to:addr:python-list': 0.38; 'does': 0.39; 'subject:can': 0.39; 'to:addr:python.org': 0.39; 'either': 0.39; 'even': 0.60; 'easy': 0.60; 'tell': 0.60; 'full': 0.61; 'content-disposition:inline': 0.62; 'more': 0.64; 'feeling': 0.68; '_it_': 0.84; 'parser,': 0.84; 'received:192.168.15': 0.84; 'subject:handle': 0.84; 'refuse': 0.93
Date Sun, 15 Mar 2015 09:01:36 +1100
From Cameron Simpson <cs@zip.com.au>
To Python <python-list@python.org>
Subject Re: Pexpect idea - but can I handle curses?
MIME-Version 1.0
Content-Type text/plain; charset=us-ascii; format=flowed
Content-Disposition inline
In-Reply-To <CANc-5UxT3a-fH_EswwLkTzHRo8dAF50qVd7MqzFiAt9H+eT=CA@mail.gmail.com>
User-Agent Mutt/1.5.23 (2014-03-12)
References <CANc-5UxT3a-fH_EswwLkTzHRo8dAF50qVd7MqzFiAt9H+eT=CA@mail.gmail.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.19
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.375.1426370502.21433.python-list@python.org> (permalink)
Lines 29
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1426370502 news.xs4all.nl 2838 [2001:888:2000:d::a6]:57224
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:87449

Show key headers only | View raw


On 13Mar2015 10:17, Skip Montanaro <skip.montanaro@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 <cs@zip.com.au>

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Pexpect idea - but can I handle curses? Cameron Simpson <cs@zip.com.au> - 2015-03-15 09:01 +1100

csiph-web