Skip to content

Commit 72edc76

Browse files
author
guido
committed
nannified
git-svn-id: http://svn.python.org/projects/python/trunk@11605 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent 7c2d668 commit 72edc76

22 files changed

Lines changed: 1651 additions & 1650 deletions

File tree

Demo/cwilib/cwilib.py

Lines changed: 121 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -18,162 +18,162 @@ def main():
1818
tn = telnetlib.Telnet(host, 0)
1919
#
2020
try:
21-
vt.send(tn.read_until('login: ', 10))
22-
tn.write('cwilib\r')
23-
#
24-
vt.send(tn.read_until('Hit <RETURN> to continue...', 10))
25-
tn.write('\r')
26-
#
27-
vt.send(tn.read_until('QUIT', 20))
21+
vt.send(tn.read_until('login: ', 10))
22+
tn.write('cwilib\r')
23+
#
24+
vt.send(tn.read_until('Hit <RETURN> to continue...', 10))
25+
tn.write('\r')
26+
#
27+
vt.send(tn.read_until('QUIT', 20))
2828
except EOFError:
29-
sys.stderr.write('Connection closed prematurely\n')
30-
sys.exit(1)
29+
sys.stderr.write('Connection closed prematurely\n')
30+
sys.exit(1)
3131
#
3232
define_screens(vt)
3333
matches = vt.which_screens()
3434
if 'menu' not in matches:
35-
sys.stderr.write('Main menu does not appear\n')
36-
sys.exit(1)
35+
sys.stderr.write('Main menu does not appear\n')
36+
sys.exit(1)
3737
#
3838
tn.write('\r\r')
3939
vt.open('Progress -- CWI Library')
4040
vt.set_debuglevel(0)
4141
ui = UserInterface()
4242
#
4343
while 1:
44-
try:
45-
data = tn.read_very_eager()
46-
except EOFError:
47-
stdwin.message('Connection closed--goodbye')
48-
break
49-
if data:
50-
print 'send...'
51-
vt.send(data)
52-
print 'send...done'
53-
continue
54-
event = stdwin.pollevent()
55-
if event:
56-
type, window, detail = event
57-
if window == None and type == WE_LOST_SEL:
58-
window = ui.queryform.window
59-
event = type, window, detail
60-
if type == WE_CLOSE:
61-
break
62-
if window in ui.windows:
63-
ui.dispatch(type, window, detail)
64-
elif window == vt.window:
65-
if type == WE_NULL:
66-
pass
67-
elif type == WE_COMMAND:
68-
if detail == WC_RETURN:
69-
tn.write('\r')
70-
elif detail == WC_BACKSPACE:
71-
tn.write('\b')
72-
elif detail == WC_TAB:
73-
tn.write('\t')
74-
elif detail == WC_UP:
75-
tn.write('\033[A')
76-
elif detail == WC_DOWN:
77-
tn.write('\033[B')
78-
elif detail == WC_RIGHT:
79-
tn.write('\033[C')
80-
elif detail == WC_LEFT:
81-
tn.write('\033[D')
82-
else:
83-
print '*** Command:', detail
84-
elif type == WE_CHAR:
85-
tn.write(detail)
86-
elif type == WE_DRAW:
87-
vt.draw(detail)
88-
elif type in (WE_ACTIVATE, WE_DEACTIVATE):
89-
pass
90-
else:
91-
print '*** VT100 event:', type, detail
92-
else:
93-
print '*** Alien event:', type, window, detail
94-
continue
95-
rfd, wfd, xfd = select.select([tn, stdwin], [], [])
44+
try:
45+
data = tn.read_very_eager()
46+
except EOFError:
47+
stdwin.message('Connection closed--goodbye')
48+
break
49+
if data:
50+
print 'send...'
51+
vt.send(data)
52+
print 'send...done'
53+
continue
54+
event = stdwin.pollevent()
55+
if event:
56+
type, window, detail = event
57+
if window == None and type == WE_LOST_SEL:
58+
window = ui.queryform.window
59+
event = type, window, detail
60+
if type == WE_CLOSE:
61+
break
62+
if window in ui.windows:
63+
ui.dispatch(type, window, detail)
64+
elif window == vt.window:
65+
if type == WE_NULL:
66+
pass
67+
elif type == WE_COMMAND:
68+
if detail == WC_RETURN:
69+
tn.write('\r')
70+
elif detail == WC_BACKSPACE:
71+
tn.write('\b')
72+
elif detail == WC_TAB:
73+
tn.write('\t')
74+
elif detail == WC_UP:
75+
tn.write('\033[A')
76+
elif detail == WC_DOWN:
77+
tn.write('\033[B')
78+
elif detail == WC_RIGHT:
79+
tn.write('\033[C')
80+
elif detail == WC_LEFT:
81+
tn.write('\033[D')
82+
else:
83+
print '*** Command:', detail
84+
elif type == WE_CHAR:
85+
tn.write(detail)
86+
elif type == WE_DRAW:
87+
vt.draw(detail)
88+
elif type in (WE_ACTIVATE, WE_DEACTIVATE):
89+
pass
90+
else:
91+
print '*** VT100 event:', type, detail
92+
else:
93+
print '*** Alien event:', type, window, detail
94+
continue
95+
rfd, wfd, xfd = select.select([tn, stdwin], [], [])
9696

9797

9898
# Subroutine to define our screen recognition patterns
9999

100100
def define_screens(vt):
101101
vt.define_screen('menu', {
102-
'title': ('search', 0, 0, 80,
103-
' SEARCH FUNCTIONS +OTHER FUNCTIONS '),
104-
})
102+
'title': ('search', 0, 0, 80,
103+
' SEARCH FUNCTIONS +OTHER FUNCTIONS '),
104+
})
105105
vt.define_screen('search', {
106-
'title': ('search', 0, 0, 80, ' Search '),
107-
})
106+
'title': ('search', 0, 0, 80, ' Search '),
107+
})
108108
vt.define_screen('shortlist', {'title': ('search', 0, 0, 80,
109-
' Short-list')})
109+
' Short-list')})
110110
vt.define_screen('showrecord', {
111-
'title': ('search', 0, 0, 80, ' Show record '),
112-
})
111+
'title': ('search', 0, 0, 80, ' Show record '),
112+
})
113113
vt.define_screen('timelimit', {
114-
'limit': ('search', 12, 0, 80, ' TIME LIMIT '),
115-
})
114+
'limit': ('search', 12, 0, 80, ' TIME LIMIT '),
115+
})
116116
vt.define_screen('attention', {
117-
'BASE': ('copy', 0, 0, 0, 'search'),
118-
'title': ('search', 10, 0, 80, ' ATTENTION ')})
117+
'BASE': ('copy', 0, 0, 0, 'search'),
118+
'title': ('search', 10, 0, 80, ' ATTENTION ')})
119119
vt.define_screen('syntaxerror', {
120-
'BASE': ('copy', 0, 0, 0, 'attention'),
121-
'message': ('search', 12, 0, 80, ' Syntax error'),
122-
})
120+
'BASE': ('copy', 0, 0, 0, 'attention'),
121+
'message': ('search', 12, 0, 80, ' Syntax error'),
122+
})
123123
vt.define_screen('emptyerror', {
124-
'BASE': ('copy', 0, 0, 0, 'attention'),
125-
'message': ('search', 12, 0, 80,
126-
' Check your input. Search at least one term'),
127-
})
124+
'BASE': ('copy', 0, 0, 0, 'attention'),
125+
'message': ('search', 12, 0, 80,
126+
' Check your input. Search at least one term'),
127+
})
128128
vt.define_screen('unsortedwarning', {
129-
'BASE': ('copy', 0, 0, 0, 'attention'),
130-
'message': ('search', 12, 0, 80,
131-
' Number of records exceeds sort limit'),
132-
})
129+
'BASE': ('copy', 0, 0, 0, 'attention'),
130+
'message': ('search', 12, 0, 80,
131+
' Number of records exceeds sort limit'),
132+
})
133133
vt.define_screen('thereismore', {
134-
'BASE': ('copy', 0, 0, 0, 'showrecord'),
135-
'message': ('search', 15, 0, 80,
136-
'There is more within this record. Use the arrow keys'),
137-
})
134+
'BASE': ('copy', 0, 0, 0, 'showrecord'),
135+
'message': ('search', 15, 0, 80,
136+
'There is more within this record. Use the arrow keys'),
137+
})
138138
vt.define_screen('nofurther', {
139-
'BASE': ('copy', 0, 0, 0, 'showrecord'),
140-
'message': ('search', 17, 0, 80, 'You cannot go further\.'),
141-
})
139+
'BASE': ('copy', 0, 0, 0, 'showrecord'),
140+
'message': ('search', 17, 0, 80, 'You cannot go further\.'),
141+
})
142142
vt.define_screen('nofurtherback', {
143-
'BASE': ('copy', 0, 0, 0, 'showrecord'),
144-
'message': ('search', 17, 0, 80,
145-
'You cannot go further back'),
146-
})
143+
'BASE': ('copy', 0, 0, 0, 'showrecord'),
144+
'message': ('search', 17, 0, 80,
145+
'You cannot go further back'),
146+
})
147147

148148

149149
# Class to implement our user interface.
150150

151151
class UserInterface:
152152

153153
def __init__(self):
154-
stdwin.setfont('7x14')
155-
self.queryform = QueryForm()
156-
self.listform = ListForm()
157-
self.recordform = RecordForm()
158-
self.forms = [self.queryform, self.listform, self.recordform]
159-
define_query_fields(self.queryform)
160-
self.windows = []
161-
for form in self.forms:
162-
if form.formheight > 0:
163-
form.open()
164-
self.windows.append(form.window)
154+
stdwin.setfont('7x14')
155+
self.queryform = QueryForm()
156+
self.listform = ListForm()
157+
self.recordform = RecordForm()
158+
self.forms = [self.queryform, self.listform, self.recordform]
159+
define_query_fields(self.queryform)
160+
self.windows = []
161+
for form in self.forms:
162+
if form.formheight > 0:
163+
form.open()
164+
self.windows.append(form.window)
165165

166166
def __del__(self):
167-
self.close()
167+
self.close()
168168

169169
def close(self):
170-
for form in self.forms:
171-
form.close()
170+
for form in self.forms:
171+
form.close()
172172

173173
def dispatch(self, type, window, detail):
174-
for form in self.forms:
175-
if window == form.window:
176-
form.dispatch(type, detail)
174+
for form in self.forms:
175+
if window == form.window:
176+
form.dispatch(type, detail)
177177

178178

179179
def define_query_fields(f):
@@ -189,25 +189,25 @@ def define_query_fields(f):
189189
class QueryForm(Form):
190190

191191
def __init__(self):
192-
Form.__init__(self, 'Query form -- CWI Library')
192+
Form.__init__(self, 'Query form -- CWI Library')
193193

194194
def dispatch(self, type, detail):
195-
if type == WE_COMMAND and detail == WC_RETURN:
196-
print '*** SUBMIT ***'
197-
else:
198-
Form.dispatch(self, type, detail)
195+
if type == WE_COMMAND and detail == WC_RETURN:
196+
print '*** SUBMIT ***'
197+
else:
198+
Form.dispatch(self, type, detail)
199199

200200

201201
class ListForm(Form):
202202

203203
def __init__(self):
204-
Form.__init__(self, 'Short list -- CWI Library')
204+
Form.__init__(self, 'Short list -- CWI Library')
205205

206206

207207
class RecordForm(Form):
208208

209209
def __init__(self):
210-
Form.__init__(self, 'Record detail -- CWI Library')
210+
Form.__init__(self, 'Record detail -- CWI Library')
211211

212212

213213
main()

Demo/dns/asgethost.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,29 @@
77
import select
88

99
def main():
10-
server = 'cnri.reston.va.us' # How?
10+
server = 'cnri.reston.va.us' # How?
1111
port = 53
1212
opcode = dnsopcode.QUERY
1313
rd = 0
1414
qtype = dnstype.MX
1515
qname = sys.argv[1:] and sys.argv[1] or 'www.python.org'
1616
m = dnslib.Mpacker()
1717
m.addHeader(0,
18-
0, opcode, 0, 0, rd, 0, 0, 0,
19-
1, 0, 0, 0)
18+
0, opcode, 0, 0, rd, 0, 0, 0,
19+
1, 0, 0, 0)
2020
m.addQuestion(qname, qtype, dnsclass.IN)
2121
request = m.getbuf()
2222
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
2323
s.connect((server, port))
2424
s.send(request)
2525
while 1:
26-
r, w, x = [s], [], []
27-
r, w, x = select.select(r, w, x, 0.333)
28-
print r, w, x
29-
if r:
30-
reply = s.recv(1024)
31-
u = dnslib.Munpacker(reply)
32-
dnslib.dumpM(u)
33-
break
26+
r, w, x = [s], [], []
27+
r, w, x = select.select(r, w, x, 0.333)
28+
print r, w, x
29+
if r:
30+
reply = s.recv(1024)
31+
u = dnslib.Munpacker(reply)
32+
dnslib.dumpM(u)
33+
break
3434

3535
main()

0 commit comments

Comments
 (0)