summaryrefslogtreecommitdiff
path: root/pexpect/tools/step.py
blob: 5f281ae01c438d6935530d4730a5a2a279ef6e8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env python

# This single steps through a log file.

import tty, termios, sys

def getkey():
        file = sys.stdin.fileno()
        mode = termios.tcgetattr(file)
        try:
                tty.setraw(file, termios.TCSANOW)
                ch = sys.stdin.read(1)
        finally:
                termios.tcsetattr(file, termios.TCSANOW, mode)
        return ch

fin = open ('log', 'rb')
fout = open ('log2', 'wb')

while 1:
        foo = fin.read(1)
        if foo == '':
                sys.exit(0)
        sys.stdout.write(foo)
        getkey()
        fout.write (foo)
        fout.flush()