Module/lib for controlling a terminal program using redrawing?

Terry Reedy tjreedy at udel.edu
Sat Mar 14 14:50:47 EDT 2015


On 3/14/2015 6:50 AM, Jason Heeris wrote:
> I am trying to automate the use of some old, in-house terminal-based
> programs that use screen redrawing for their interface. This includes
> single line redrawing (eg. using '\r' and overwriting), complete screen
> clearing, and fine-grained cursor movement and overwriting (probably not
> all in the same program at the same time though).
>
> Is there a module/library that can help me with this?
>
> I know of pexpect, but that seems more oriented towards line-by-line
> prompts that don't involve redraws (eg. login prompt, then password
> prompt on a new line). Think instead of trying to automate applications
> like emacs, aptitude or even nethack that redraw sections of the screen
> without making the terminal scroll.
>
> This automation requires more than just sending a set of keystrokes, but
> also reading what is displayed on screen and making decisions based up
> on that.
>
> Is there a library that can abstract the received redrawing activity so
> I don't have to even know if the application has, eg. used a carriage
> return or some other kind of cursor movement? Is there a way to just ask
> "if this were to be run in an ANSI terminal, what would be in each cell?"
>
> Python 2 or 3 are both fine, external packages are fine, but it has to
> work on Linux (eg. Ubuntu 14.04 or later, Debian Wheezy or later).
>
> Any pointers appreciated.

Perhaps you can use the guts of a terminal emulation program, removing 
the part that displays the interpreted stream (a 24 x 80 array) on the 
screen.  Searching 'python terminal emulation' returns these

terminal.py - A Pure Python Terminal Emulator - GitHub Pages
liftoff.github.io/GateOne/Developer/terminal.html
This crux of this module is the Terminal class which is a pure-Python 
implementation of the quintessential Unix terminal emulator. It does its 
best to emulate an ...

pyte 0.4.9 : Python Package Index
https://pypi.python.org/pypi/pyte/
Python
Dec 3, 2014 - What is pyte? It's an in memory VTXXX-compatible terminal 
emulator. XXX stands for a series of video terminals, developed by DEC 
between ...

-- 
Terry Jan Reedy




More information about the Python-list mailing list