Commit 05e8823d authored by Guido van Rossum's avatar Guido van Rossum

Restructured main loop. Etc.

parent 144ffc81
...@@ -15,19 +15,16 @@ def main(): ...@@ -15,19 +15,16 @@ def main():
vt = vt100win.VT100win() vt = vt100win.VT100win()
# #
host = 'biefstuk.cwi.nl' host = 'biefstuk.cwi.nl'
port = 0 tn = telnetlib.Telnet(host, 0)
timeout = 10.0
tn = telnetlib.Telnet(host, port)
tn.set_timeout(timeout)
# #
try: try:
vt.send(tn.read_until('login: ')) vt.send(tn.read_until('login: ', 10))
tn.write('cwilib\r') tn.write('cwilib\r')
# #
vt.send(tn.read_until('Hit <RETURN> to continue...')) vt.send(tn.read_until('Hit <RETURN> to continue...', 10))
tn.write('\r') tn.write('\r')
# #
vt.send(tn.read_until('QUIT')) vt.send(tn.read_until('QUIT', 20))
except EOFError: except EOFError:
sys.stderr.write('Connection closed prematurely\n') sys.stderr.write('Connection closed prematurely\n')
sys.exit(1) sys.exit(1)
...@@ -35,20 +32,26 @@ def main(): ...@@ -35,20 +32,26 @@ def main():
define_screens(vt) define_screens(vt)
matches = vt.which_screens() matches = vt.which_screens()
if 'menu' not in matches: if 'menu' not in matches:
sys.stderr.write('No main menu within %g seconds\n' % timeout) sys.stderr.write('Main menu does not appear\n')
sys.exit(1) sys.exit(1)
# #
tn.set_timeout(0)
tn.write('\r\r') tn.write('\r\r')
vt.open('Progress -- CWI Library') vt.open('Progress -- CWI Library')
vt.set_debuglevel(0)
ui = UserInterface() ui = UserInterface()
# #
while 1: while 1:
try:
data = tn.read_very_eager()
except EOFError:
stdwin.message('Connection closed--goodbye')
break
if data:
print 'send...'
vt.send(data)
print 'send...done'
continue
event = stdwin.pollevent() event = stdwin.pollevent()
if not event:
rfd, wfd, xfd = select.select([stdwin, tn], [], [])
if stdwin in rfd:
event = stdwin.getevent()
if event: if event:
type, window, detail = event type, window, detail = event
if window == None and type == WE_LOST_SEL: if window == None and type == WE_LOST_SEL:
...@@ -88,24 +91,8 @@ def main(): ...@@ -88,24 +91,8 @@ def main():
print '*** VT100 event:', type, detail print '*** VT100 event:', type, detail
else: else:
print '*** Alien event:', type, window, detail print '*** Alien event:', type, window, detail
elif tn in rfd: continue
vt.window.setwincursor('watch') rfd, wfd, xfd = select.select([tn, stdwin], [], [])
try:
data = tn.read_now()
except EOFError:
stdwin.message('Connection closed--goodbye')
break
print 'send...'
vt.send(data)
print 'send...done'
vt.window.setwincursor('arrow')
matches = vt.which_screens()
if 'timelimit' in matches:
stdwin.message('Time limit--goodbye')
break
print '*** Matches:', matches
else:
print '*** Weird return from select:', rfd, wfd, xfd
# Subroutine to define our screen recognition patterns # Subroutine to define our screen recognition patterns
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment