Update of /cvsroot/python/python/dist/src/Demo/curses In directory usw-pr-cvs1:/tmp/cvs-serv19728 Modified Files: README Added Files: repeat.py Log Message: Added "repeat.py" -- repeatedly execute a shell command (like watch(1)). Updated and untabified the README file. --- NEW FILE: repeat.py --- #! /usr/bin/env python """repeat <shell-command> This simple program repeatedly (with 1-second intervals) executes the shell command given on the command line and displays the output (or as much of it as fits on the screen). It uses curses to paint each new output on top of the old output, so that if nothing changes, the screen doesn't change. This is handy to watch for changes in e.g. a directory or process listing. To end, hit Control-C. """ # Author: Guido van Rossum # Disclaimer: there's a Linux program named 'watch' that does the same # thing. Honestly, I didn't know of its existence when I wrote this! # To do: add features until it has the same functionality as watch(1); # then compare code size and development time. import os import sys import time import curses def main(): if not sys.argv[1:]: print __doc__ sys.exit(0) cmd = " ".join(sys.argv[1:]) p = os.popen(cmd, "r") text = p.read() sts = p.close() if sts: print >>sys.stderr, "Exit code:", sts sys.exit(sts) w = curses.initscr() try: while 1: w.erase() try: w.addstr(text) except curses.error: pass w.refresh() time.sleep(1) p = os.popen(cmd, "r") text = p.read() sts = p.close() if sts: print >>sys.stderr, "Exit code:", sts sys.exit(sts) finally: curses.endwin() main() Index: README =================================================================== RCS file: /cvsroot/python/python/dist/src/Demo/curses/README,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** README 2000/12/21 16:26:37 1.3 --- README 2001/01/05 20:54:07 1.4 *************** *** 11,19 **** course. ! ncurses.py -- currently only a panels demo XXX this won't work until panel support is checked in ! rain.py -- raindrops keep falling on my desktop ! tclock.py -- ASCII clock, by Howard Jones ! xmas.py -- I'm dreaming of an ASCII christmas Please send bugfixes and new contributions to me or, even better, --- 11,19 ---- course. ! ncurses.py -- currently only a panels demo XXX this won't work until panel support is checked in ! rain.py -- raindrops keep falling on my desktop ! tclock.py -- ASCII clock, by Howard Jones ! xmas.py -- I'm dreaming of an ASCII christmas Please send bugfixes and new contributions to me or, even better, *************** *** 25,29 **** =========== ! life.py Simple game of Life ! ! --- 25,28 ---- =========== ! life.py -- Simple game of Life ! repeat.py -- Repeatedly execute a shell command (like watch(1))
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4