Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / v9 / html / python / lib / telnet-objects.html
CommitLineData
920dae64
AT
1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<html>
3<head>
4<link rel="STYLESHEET" href="lib.css" type='text/css' />
5<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
6<link rel='start' href='../index.html' title='Python Documentation Index' />
7<link rel="first" href="lib.html" title='Python Library Reference' />
8<link rel='contents' href='contents.html' title="Contents" />
9<link rel='index' href='genindex.html' title='Index' />
10<link rel='last' href='about.html' title='About this document...' />
11<link rel='help' href='about.html' title='About this document...' />
12<link rel="next" href="telnet-example.html" />
13<link rel="prev" href="module-telnetlib.html" />
14<link rel="parent" href="module-telnetlib.html" />
15<link rel="next" href="telnet-example.html" />
16<meta name='aesop' content='information' />
17<title>11.14.1 Telnet Objects </title>
18</head>
19<body>
20<DIV CLASS="navigation">
21<div id='top-navigation-panel' xml:id='top-navigation-panel'>
22<table align="center" width="100%" cellpadding="0" cellspacing="2">
23<tr>
24<td class='online-navigation'><a rel="prev" title="11.14 telnetlib "
25 href="module-telnetlib.html"><img src='../icons/previous.png'
26 border='0' height='32' alt='Previous Page' width='32' /></A></td>
27<td class='online-navigation'><a rel="parent" title="11.14 telnetlib "
28 href="module-telnetlib.html"><img src='../icons/up.png'
29 border='0' height='32' alt='Up One Level' width='32' /></A></td>
30<td class='online-navigation'><a rel="next" title="11.14.2 Telnet Example"
31 href="telnet-example.html"><img src='../icons/next.png'
32 border='0' height='32' alt='Next Page' width='32' /></A></td>
33<td align="center" width="100%">Python Library Reference</td>
34<td class='online-navigation'><a rel="contents" title="Table of Contents"
35 href="contents.html"><img src='../icons/contents.png'
36 border='0' height='32' alt='Contents' width='32' /></A></td>
37<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
38 border='0' height='32' alt='Module Index' width='32' /></a></td>
39<td class='online-navigation'><a rel="index" title="Index"
40 href="genindex.html"><img src='../icons/index.png'
41 border='0' height='32' alt='Index' width='32' /></A></td>
42</tr></table>
43<div class='online-navigation'>
44<b class="navlabel">Previous:</b>
45<a class="sectref" rel="prev" href="module-telnetlib.html">11.14 telnetlib </A>
46<b class="navlabel">Up:</b>
47<a class="sectref" rel="parent" href="module-telnetlib.html">11.14 telnetlib </A>
48<b class="navlabel">Next:</b>
49<a class="sectref" rel="next" href="telnet-example.html">11.14.2 Telnet Example</A>
50</div>
51<hr /></div>
52</DIV>
53<!--End of Navigation Panel-->
54
55<H2><A NAME="SECTION00131410000000000000000"></A><A NAME="telnet-objects"></A>
56<BR>
5711.14.1 Telnet Objects
58</H2>
59
60<P>
61<tt class="class">Telnet</tt> instances have the following methods:
62
63<P>
64<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
65 <td><nobr><b><tt id='l2h-3518' xml:id='l2h-3518' class="method">read_until</tt></b>(</nobr></td>
66 <td><var>expected</var><big>[</big><var>, timeout</var><big>]</big><var></var>)</td></tr></table></dt>
67<dd>
68Read until a given string, <var>expected</var>, is encountered or until
69<var>timeout</var> seconds have passed.
70
71<P>
72When no match is found, return whatever is available instead,
73possibly the empty string. Raise <tt class="exception">EOFError</tt> if the connection
74is closed and no cooked data is available.
75</dl>
76
77<P>
78<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
79 <td><nobr><b><tt id='l2h-3519' xml:id='l2h-3519' class="method">read_all</tt></b>(</nobr></td>
80 <td><var></var>)</td></tr></table></dt>
81<dd>
82Read all data until EOF; block until connection closed.
83</dl>
84
85<P>
86<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
87 <td><nobr><b><tt id='l2h-3520' xml:id='l2h-3520' class="method">read_some</tt></b>(</nobr></td>
88 <td><var></var>)</td></tr></table></dt>
89<dd>
90Read at least one byte of cooked data unless EOF is hit.
91Return <code>''</code> if EOF is hit. Block if no data is immediately
92available.
93</dl>
94
95<P>
96<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
97 <td><nobr><b><tt id='l2h-3521' xml:id='l2h-3521' class="method">read_very_eager</tt></b>(</nobr></td>
98 <td><var></var>)</td></tr></table></dt>
99<dd>
100Read everything that can be without blocking in I/O (eager).
101
102<P>
103Raise <tt class="exception">EOFError</tt> if connection closed and no cooked data
104available. Return <code>''</code> if no cooked data available otherwise.
105Do not block unless in the midst of an IAC sequence.
106</dl>
107
108<P>
109<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
110 <td><nobr><b><tt id='l2h-3522' xml:id='l2h-3522' class="method">read_eager</tt></b>(</nobr></td>
111 <td><var></var>)</td></tr></table></dt>
112<dd>
113Read readily available data.
114
115<P>
116Raise <tt class="exception">EOFError</tt> if connection closed and no cooked data
117available. Return <code>''</code> if no cooked data available otherwise.
118Do not block unless in the midst of an IAC sequence.
119</dl>
120
121<P>
122<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
123 <td><nobr><b><tt id='l2h-3523' xml:id='l2h-3523' class="method">read_lazy</tt></b>(</nobr></td>
124 <td><var></var>)</td></tr></table></dt>
125<dd>
126Process and return data already in the queues (lazy).
127
128<P>
129Raise <tt class="exception">EOFError</tt> if connection closed and no data available.
130Return <code>''</code> if no cooked data available otherwise. Do not block
131unless in the midst of an IAC sequence.
132</dl>
133
134<P>
135<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
136 <td><nobr><b><tt id='l2h-3524' xml:id='l2h-3524' class="method">read_very_lazy</tt></b>(</nobr></td>
137 <td><var></var>)</td></tr></table></dt>
138<dd>
139Return any data available in the cooked queue (very lazy).
140
141<P>
142Raise <tt class="exception">EOFError</tt> if connection closed and no data available.
143Return <code>''</code> if no cooked data available otherwise. This method
144never blocks.
145</dl>
146
147<P>
148<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
149 <td><nobr><b><tt id='l2h-3525' xml:id='l2h-3525' class="method">read_sb_data</tt></b>(</nobr></td>
150 <td><var></var>)</td></tr></table></dt>
151<dd>
152Return the data collected between a SB/SE pair (suboption begin/end).
153The callback should access these data when it was invoked with a
154<code>SE</code> command. This method never blocks.
155
156<P>
157
158<span class="versionnote">New in version 2.3.</span>
159
160</dl>
161
162<P>
163<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
164 <td><nobr><b><tt id='l2h-3526' xml:id='l2h-3526' class="method">open</tt></b>(</nobr></td>
165 <td><var>host</var><big>[</big><var>, port</var><big>]</big><var></var>)</td></tr></table></dt>
166<dd>
167Connect to a host.
168The optional second argument is the port number, which
169defaults to the standard Telnet port (23).
170
171<P>
172Do not try to reopen an already connected instance.
173</dl>
174
175<P>
176<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
177 <td><nobr><b><tt id='l2h-3527' xml:id='l2h-3527' class="method">msg</tt></b>(</nobr></td>
178 <td><var>msg</var><big>[</big><var>, *args</var><big>]</big><var></var>)</td></tr></table></dt>
179<dd>
180Print a debug message when the debug level is <code>&gt;</code> 0.
181If extra arguments are present, they are substituted in the
182message using the standard string formatting operator.
183</dl>
184
185<P>
186<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
187 <td><nobr><b><tt id='l2h-3528' xml:id='l2h-3528' class="method">set_debuglevel</tt></b>(</nobr></td>
188 <td><var>debuglevel</var>)</td></tr></table></dt>
189<dd>
190Set the debug level. The higher the value of <var>debuglevel</var>, the
191more debug output you get (on <code>sys.stdout</code>).
192</dl>
193
194<P>
195<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
196 <td><nobr><b><tt id='l2h-3529' xml:id='l2h-3529' class="method">close</tt></b>(</nobr></td>
197 <td><var></var>)</td></tr></table></dt>
198<dd>
199Close the connection.
200</dl>
201
202<P>
203<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
204 <td><nobr><b><tt id='l2h-3530' xml:id='l2h-3530' class="method">get_socket</tt></b>(</nobr></td>
205 <td><var></var>)</td></tr></table></dt>
206<dd>
207Return the socket object used internally.
208</dl>
209
210<P>
211<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
212 <td><nobr><b><tt id='l2h-3531' xml:id='l2h-3531' class="method">fileno</tt></b>(</nobr></td>
213 <td><var></var>)</td></tr></table></dt>
214<dd>
215Return the file descriptor of the socket object used internally.
216</dl>
217
218<P>
219<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
220 <td><nobr><b><tt id='l2h-3532' xml:id='l2h-3532' class="method">write</tt></b>(</nobr></td>
221 <td><var>buffer</var>)</td></tr></table></dt>
222<dd>
223Write a string to the socket, doubling any IAC characters.
224This can block if the connection is blocked. May raise
225<tt class="exception">socket.error</tt> if the connection is closed.
226</dl>
227
228<P>
229<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
230 <td><nobr><b><tt id='l2h-3533' xml:id='l2h-3533' class="method">interact</tt></b>(</nobr></td>
231 <td><var></var>)</td></tr></table></dt>
232<dd>
233Interaction function, emulates a very dumb Telnet client.
234</dl>
235
236<P>
237<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
238 <td><nobr><b><tt id='l2h-3534' xml:id='l2h-3534' class="method">mt_interact</tt></b>(</nobr></td>
239 <td><var></var>)</td></tr></table></dt>
240<dd>
241Multithreaded version of <tt class="method">interact()</tt>.
242</dl>
243
244<P>
245<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
246 <td><nobr><b><tt id='l2h-3535' xml:id='l2h-3535' class="method">expect</tt></b>(</nobr></td>
247 <td><var>list</var><big>[</big><var>, timeout</var><big>]</big><var></var>)</td></tr></table></dt>
248<dd>
249Read until one from a list of a regular expressions matches.
250
251<P>
252The first argument is a list of regular expressions, either
253compiled (<tt class="class">re.RegexObject</tt> instances) or uncompiled (strings).
254The optional second argument is a timeout, in seconds; the default
255is to block indefinitely.
256
257<P>
258Return a tuple of three items: the index in the list of the
259first regular expression that matches; the match object
260returned; and the text read up till and including the match.
261
262<P>
263If end of file is found and no text was read, raise
264<tt class="exception">EOFError</tt>. Otherwise, when nothing matches, return
265<code>(-1, None, <var>text</var>)</code> where <var>text</var> is the text received so
266far (may be the empty string if a timeout happened).
267
268<P>
269If a regular expression ends with a greedy match (such as <tt class="regexp">.*</tt>)
270or if more than one expression can match the same input, the
271results are indeterministic, and may depend on the I/O timing.
272</dl>
273
274<P>
275<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
276 <td><nobr><b><tt id='l2h-3536' xml:id='l2h-3536' class="method">set_option_negotiation_callback</tt></b>(</nobr></td>
277 <td><var>callback</var>)</td></tr></table></dt>
278<dd>
279Each time a telnet option is read on the input flow, this
280<var>callback</var> (if set) is called with the following parameters :
281callback(telnet socket, command (DO/DONT/WILL/WONT), option). No other
282action is done afterwards by telnetlib.
283</dl>
284
285<P>
286
287<DIV CLASS="navigation">
288<div class='online-navigation'>
289<p></p><hr />
290<table align="center" width="100%" cellpadding="0" cellspacing="2">
291<tr>
292<td class='online-navigation'><a rel="prev" title="11.14 telnetlib "
293 href="module-telnetlib.html"><img src='../icons/previous.png'
294 border='0' height='32' alt='Previous Page' width='32' /></A></td>
295<td class='online-navigation'><a rel="parent" title="11.14 telnetlib "
296 href="module-telnetlib.html"><img src='../icons/up.png'
297 border='0' height='32' alt='Up One Level' width='32' /></A></td>
298<td class='online-navigation'><a rel="next" title="11.14.2 Telnet Example"
299 href="telnet-example.html"><img src='../icons/next.png'
300 border='0' height='32' alt='Next Page' width='32' /></A></td>
301<td align="center" width="100%">Python Library Reference</td>
302<td class='online-navigation'><a rel="contents" title="Table of Contents"
303 href="contents.html"><img src='../icons/contents.png'
304 border='0' height='32' alt='Contents' width='32' /></A></td>
305<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
306 border='0' height='32' alt='Module Index' width='32' /></a></td>
307<td class='online-navigation'><a rel="index" title="Index"
308 href="genindex.html"><img src='../icons/index.png'
309 border='0' height='32' alt='Index' width='32' /></A></td>
310</tr></table>
311<div class='online-navigation'>
312<b class="navlabel">Previous:</b>
313<a class="sectref" rel="prev" href="module-telnetlib.html">11.14 telnetlib </A>
314<b class="navlabel">Up:</b>
315<a class="sectref" rel="parent" href="module-telnetlib.html">11.14 telnetlib </A>
316<b class="navlabel">Next:</b>
317<a class="sectref" rel="next" href="telnet-example.html">11.14.2 Telnet Example</A>
318</div>
319</div>
320<hr />
321<span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span>
322</DIV>
323<!--End of Navigation Panel-->
324<ADDRESS>
325See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
326</ADDRESS>
327</BODY>
328</HTML>