Sophie

Sophie

distrib > Mandriva > 10.1 > i586 > by-pkgid > ccf83290023404568bb21aa0163b385f > files > 954

python-docs-2.3.4-6.2.101mdk.i586.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="lib.css" type='text/css' />
<link rel="SHORTCUT ICON" href="../icons/pyfav.gif" />
<link rel='start' href='../index.html' title='Python Documentation Index' />
<link rel="first" href="lib.html" title='Python Library Reference' />
<link rel='contents' href='contents.html' title="Contents" />
<link rel='index' href='genindex.html' title='Index' />
<link rel='last' href='about.html' title='About this document...' />
<link rel='help' href='about.html' title='About this document...' />
<LINK rel="next" href="telnet-example.html">
<LINK rel="prev" href="module-telnetlib.html">
<LINK rel="parent" href="module-telnetlib.html">
<LINK rel="next" href="telnet-example.html">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name='aesop' content='information' />
<META name="description" content="Telnet Objects ">
<META name="keywords" content="lib">
<META name="resource-type" content="document">
<META name="distribution" content="global">
<title>11.13.1 Telnet Objects </title>
</head>
<body>
<DIV CLASS="navigation">
<div id='top-navigation-panel'>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="11.13 telnetlib  " 
  href="module-telnetlib.html"><img src='../icons/previous.png'
  border='0' height='32'  alt='Previous Page' width='32' /></A></td>
<td class='online-navigation'><a rel="parent" title="11.13 telnetlib  " 
  href="module-telnetlib.html"><img src='../icons/up.png'
  border='0' height='32'  alt='Up One Level' width='32' /></A></td>
<td class='online-navigation'><a rel="next" title="11.13.2 Telnet Example" 
  href="telnet-example.html"><img src='../icons/next.png'
  border='0' height='32'  alt='Next Page' width='32' /></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents" 
  href="contents.html"><img src='../icons/contents.png'
  border='0' height='32'  alt='Contents' width='32' /></A></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
  border='0' height='32'  alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index" 
  href="genindex.html"><img src='../icons/index.png'
  border='0' height='32'  alt='Index' width='32' /></A></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="module-telnetlib.html">11.13 telnetlib  </A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="module-telnetlib.html">11.13 telnetlib  </A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="telnet-example.html">11.13.2 Telnet Example</A>
</div>
<hr /></div>
</DIV>
<!--End of Navigation Panel-->

<H2><A NAME="SECTION00131310000000000000000"><!--x--></A><A NAME="telnet-objects"><!--z--></A>
<BR>
11.13.1 Telnet Objects 
</H2>

<P>
<tt class="class">Telnet</tt> instances have the following methods:

<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3295' class="method">read_until</tt></b>(</nobr></td>
  <td><var>expected</var><big>[</big><var>, timeout</var><big>]</big>)</td></tr></table></dt>
<dd>
Read until a given string, <var>expected</var>, is encountered or until
<var>timeout</var> seconds have passed.

<P>
When no match is found, return whatever is available instead,
possibly the empty string.  Raise <tt class="exception">EOFError</tt> if the connection
is closed and no cooked data is available.
</dl>

<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3296' class="method">read_all</tt></b>(</nobr></td>
  <td>)</td></tr></table></dt>
<dd>
Read all data until EOF; block until connection closed.
</dl>

<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3297' class="method">read_some</tt></b>(</nobr></td>
  <td>)</td></tr></table></dt>
<dd>
Read at least one byte of cooked data unless EOF is hit.
Return <code>''</code> if EOF is hit.  Block if no data is immediately
available.
</dl>

<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3298' class="method">read_very_eager</tt></b>(</nobr></td>
  <td>)</td></tr></table></dt>
<dd>
Read everything that can be without blocking in I/O (eager).

<P>
Raise <tt class="exception">EOFError</tt> if connection closed and no cooked data
available.  Return <code>''</code> if no cooked data available otherwise.
Do not block unless in the midst of an IAC sequence.
</dl>

<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3299' class="method">read_eager</tt></b>(</nobr></td>
  <td>)</td></tr></table></dt>
<dd>
Read readily available data.

<P>
Raise <tt class="exception">EOFError</tt> if connection closed and no cooked data
available.  Return <code>''</code> if no cooked data available otherwise.
Do not block unless in the midst of an IAC sequence.
</dl>

<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3300' class="method">read_lazy</tt></b>(</nobr></td>
  <td>)</td></tr></table></dt>
<dd>
Process and return data already in the queues (lazy).

<P>
Raise <tt class="exception">EOFError</tt> if connection closed and no data available.
Return <code>''</code> if no cooked data available otherwise.  Do not block
unless in the midst of an IAC sequence.
</dl>

<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3301' class="method">read_very_lazy</tt></b>(</nobr></td>
  <td>)</td></tr></table></dt>
<dd>
Return any data available in the cooked queue (very lazy).

<P>
Raise <tt class="exception">EOFError</tt> if connection closed and no data available.
Return <code>''</code> if no cooked data available otherwise.  This method
never blocks.
</dl>

<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3302' class="method">read_sb_data</tt></b>(</nobr></td>
  <td>)</td></tr></table></dt>
<dd>
Return the data collected between a SB/SE pair (suboption begin/end).
The callback should access these data when it was invoked with a
<code>SE</code> command. This method never blocks.

<P>

<span class="versionnote">New in version 2.3.</span>

</dl>

<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3303' class="method">open</tt></b>(</nobr></td>
  <td><var>host</var><big>[</big><var>, port</var><big>]</big>)</td></tr></table></dt>
<dd>
Connect to a host.
The optional second argument is the port number, which
defaults to the standard Telnet port (23).

<P>
Do not try to reopen an already connected instance.
</dl>

<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3304' class="method">msg</tt></b>(</nobr></td>
  <td><var>msg</var><big>[</big><var>, *args</var><big>]</big>)</td></tr></table></dt>
<dd>
Print a debug message when the debug level is <code>&gt;</code> 0.
If extra arguments are present, they are substituted in the
message using the standard string formatting operator.
</dl>

<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3305' class="method">set_debuglevel</tt></b>(</nobr></td>
  <td><var>debuglevel</var>)</td></tr></table></dt>
<dd>
Set the debug level.  The higher the value of <var>debuglevel</var>, the
more debug output you get (on <code>sys.stdout</code>).
</dl>

<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3306' class="method">close</tt></b>(</nobr></td>
  <td>)</td></tr></table></dt>
<dd>
Close the connection.
</dl>

<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3307' class="method">get_socket</tt></b>(</nobr></td>
  <td>)</td></tr></table></dt>
<dd>
Return the socket object used internally.
</dl>

<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3308' class="method">fileno</tt></b>(</nobr></td>
  <td>)</td></tr></table></dt>
<dd>
Return the file descriptor of the socket object used internally.
</dl>

<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3309' class="method">write</tt></b>(</nobr></td>
  <td><var>buffer</var>)</td></tr></table></dt>
<dd>
Write a string to the socket, doubling any IAC characters.
This can block if the connection is blocked.  May raise
<tt class="exception">socket.error</tt> if the connection is closed.
</dl>

<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3310' class="method">interact</tt></b>(</nobr></td>
  <td>)</td></tr></table></dt>
<dd>
Interaction function, emulates a very dumb Telnet client.
</dl>

<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3311' class="method">mt_interact</tt></b>(</nobr></td>
  <td>)</td></tr></table></dt>
<dd>
Multithreaded version of <tt class="method">interact()</tt>.
</dl>

<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3312' class="method">expect</tt></b>(</nobr></td>
  <td><var>list</var><big>[</big><var>, timeout</var><big>]</big>)</td></tr></table></dt>
<dd>
Read until one from a list of a regular expressions matches.

<P>
The first argument is a list of regular expressions, either
compiled (<tt class="class">re.RegexObject</tt> instances) or uncompiled (strings).
The optional second argument is a timeout, in seconds; the default
is to block indefinitely.

<P>
Return a tuple of three items: the index in the list of the
first regular expression that matches; the match object
returned; and the text read up till and including the match.

<P>
If end of file is found and no text was read, raise
<tt class="exception">EOFError</tt>.  Otherwise, when nothing matches, return
<code>(-1, None, <var>text</var>)</code> where <var>text</var> is the text received so
far (may be the empty string if a timeout happened).

<P>
If a regular expression ends with a greedy match (such as <tt class="regexp">.*</tt>)
or if more than one expression can match the same input, the
results are indeterministic, and may depend on the I/O timing.
</dl>

<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3313' class="method">set_option_negotiation_callback</tt></b>(</nobr></td>
  <td><var>callback</var>)</td></tr></table></dt>
<dd>
Each time a telnet option is read on the input flow, this
<var>callback</var> (if set) is called with the following parameters :
callback(telnet socket, command (DO/DONT/WILL/WONT), option).  No other
action is done afterwards by telnetlib.
</dl>

<P>

<DIV CLASS="navigation">
<div class='online-navigation'><hr />
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="11.13 telnetlib  " 
  rel="prev" title="11.13 telnetlib  " 
  href="module-telnetlib.html"><img src='../icons/previous.png'
  border='0' height='32'  alt='Previous Page' width='32' /></A></td>
<td class='online-navigation'><a rel="parent" title="11.13 telnetlib  " 
  rel="parent" title="11.13 telnetlib  " 
  href="module-telnetlib.html"><img src='../icons/up.png'
  border='0' height='32'  alt='Up One Level' width='32' /></A></td>
<td class='online-navigation'><a rel="next" title="11.13.2 Telnet Example" 
  rel="next" title="11.13.2 Telnet Example" 
  href="telnet-example.html"><img src='../icons/next.png'
  border='0' height='32'  alt='Next Page' width='32' /></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents" 
  rel="contents" title="Table of Contents" 
  href="contents.html"><img src='../icons/contents.png'
  border='0' height='32'  alt='Contents' width='32' /></A></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
  border='0' height='32'  alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index" 
  rel="index" title="Index" 
  href="genindex.html"><img src='../icons/index.png'
  border='0' height='32'  alt='Index' width='32' /></A></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="module-telnetlib.html">11.13 telnetlib  </A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="module-telnetlib.html">11.13 telnetlib  </A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="telnet-example.html">11.13.2 Telnet Example</A>
</div>
</div>
<hr />
<span class="release-info">Release 2.3.4, documentation updated on May 20, 2004.</span>
</DIV>
<!--End of Navigation Panel-->
<ADDRESS>
See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
</ADDRESS>
</BODY>
</HTML>