0 0 1
default
Jean-Francois Pieronne - 5 years ago 2014-10-20 18:10:51
jf.pieronne@laposte.net
Initial version of ptd4.py
1 file changed with 49 insertions and 0 deletions:
↑ Collapse Diff ↑
 
new file 100755
1
 
import time
2
 
from vms.starlet import ptdlib
3
 
from vms.ssdef import SS__TIMEOUT
4
 

	
5
 
fo = open("trace.log", "w")
6
 
def execute_until(ptd, cmd, maxtime):
7
 
    endtime = time.time() + maxtime
8
 
    s = ptd.writeln(cmd)
9
 
    print s,
10
 
    print >>fo, repr(s)
11
 
    try:
12
 
        while(True):
13
 
            curtime = time.time()
14
 
            timeout = int(endtime - curtime)
15
 
            if timeout <= 0:
16
 
                break      
17
 
            status, s = ptd.read(timeout)
18
 
            print s,
19
 
            print >>fo, repr(s)
20
 
    except VMSError, e:
21
 
        return
22
 

	
23
 
def execute(ptd, cmd):
24
 
    e,lines = ptd.execute(cmd)
25
 
    print e,
26
 
    print >>fo, repr(e)
27
 
    for line in lines:
28
 
        print line,
29
 
        print >>fo, repr(line)
30
 

	
31
 
ptd = ptdlib.Ptd()
32
 
lines = ptd.read_until_prompt()
33
 
for line in lines:
34
 
    print line,
35
 
    print >>fo, repr(line)
36
 

	
37
 
execute(ptd, 'set terminal/dev=vt100/pag=24/widt=80')
38
 

	
39
 
execute(ptd, 'show terminal')
40
 

	
41
 
execute_until(ptd, 'edit', 5)
42
 
ptd.write('toto')
43
 
ptd.write(ptdlib.KEYS["DO"])
44
 
ptd.writeln('quit')
45
 
ptd.writeln('')
46
 
lines = ptd.read_until_prompt()
47
 
for line in lines:
48
 
    print line,
49
 
    print >>fo, repr(line)
0 comments (0 inline, 0 general)