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

Restructured main loop. Etc.

parent 144ffc81
......@@ -15,19 +15,16 @@ def main():
vt = vt100win.VT100win()
#
host = 'biefstuk.cwi.nl'
port = 0
timeout = 10.0
tn = telnetlib.Telnet(host, port)
tn.set_timeout(timeout)
tn = telnetlib.Telnet(host, 0)
#
try:
vt.send(tn.read_until('login: '))
vt.send(tn.read_until('login: ', 10))
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')
#
vt.send(tn.read_until('QUIT'))
vt.send(tn.read_until('QUIT', 20))
except EOFError:
sys.stderr.write('Connection closed prematurely\n')
sys.exit(1)
......@@ -35,20 +32,26 @@ def main():
define_screens(vt)
matches = vt.which_screens()
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)
#
tn.set_timeout(0)
tn.write('\r\r')
vt.open('Progress -- CWI Library')
vt.set_debuglevel(0)
ui = UserInterface()
#
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()
if not event:
rfd, wfd, xfd = select.select([stdwin, tn], [], [])
if stdwin in rfd:
event = stdwin.getevent()
if event:
type, window, detail = event
if window == None and type == WE_LOST_SEL:
......@@ -88,24 +91,8 @@ def main():
print '*** VT100 event:', type, detail
else:
print '*** Alien event:', type, window, detail
elif tn in rfd:
vt.window.setwincursor('watch')
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
continue
rfd, wfd, xfd = select.select([tn, stdwin], [], [])
# 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