Re: Module/lib for controlling a terminal program using redrawing?
Yes, Paul Rubin had it right: I hadn't thought of the term "screen scraper," but that might help my searching. On 15 March 2015 at 05:50, Terry Reedy wrote: > > 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 Thanks for those results. I also discovered that someone wrote a Python ANSI terminal scraper originally for use with Nethack: https://github.com/helgefmi/ansiterm (although it seems generic enough). Cheers, Jason -- https://mail.python.org/mailman/listinfo/python-list
Re: Module/lib for controlling a terminal program using redrawing?
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 -- https://mail.python.org/mailman/listinfo/python-list
Re: Module/lib for controlling a terminal program using redrawing?
Dave Angel writes: >> Is there a module/library that can help me with this? > https://docs.python.org/3/howto/curses.html That's the opposite of what the OP wanted. Curses generates the escape codes and so on to draw your desired stuff on the terminal. The OP wants a screen scraper, something that takes the escape codes generated by another program and interprets them to figure out what the screen is supposed to look like. The classic program that does this is Rog-o-matic. I don't happen to know of any Python code that does it but the search terms "python ansi screen scraping" find some results that might be worth looking into. It also shouldn't be all that terribly hard to implement. Leaving out the "ansi" keyword finds mostly HTML scrapers which aren't what is wanted. Trying other terminal types like "vt100" might find desirable stuff though. -- https://mail.python.org/mailman/listinfo/python-list
Re: Module/lib for controlling a terminal program using redrawing?
On 03/14/2015 06: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? https://docs.python.org/3/howto/curses.html That's in the standard library for both Python2 and 3. I don't know if it'll do everything you need, but if not, there are also various wrappers for curses that can be found with a google search. -- DaveA -- https://mail.python.org/mailman/listinfo/python-list
Module/lib for controlling a terminal program using redrawing?
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. Cheers, Jason -- https://mail.python.org/mailman/listinfo/python-list