[Python-modules-commits] r929 - in /packages/pexpect/branches/upstream/current: ./ doc/ examples/

rganesan at users.alioth.debian.org rganesan at users.alioth.debian.org
Mon Jun 19 10:53:26 UTC 2006


Author: rganesan
Date: Mon Jun 19 10:53:24 2006
New Revision: 929

URL: http://svn.debian.org/wsvn/python-modules/?sc=1&rev=929
Log:
Load /tmp/tmp.WcTUvG4247/pexpect-2.1 into
packages/pexpect/branches/upstream/current.

Added:
    packages/pexpect/branches/upstream/current/INSTALL
    packages/pexpect/branches/upstream/current/LICENSE
    packages/pexpect/branches/upstream/current/doc/
    packages/pexpect/branches/upstream/current/doc/ANSI.html
    packages/pexpect/branches/upstream/current/doc/FSM.html
    packages/pexpect/branches/upstream/current/doc/clean.css
    packages/pexpect/branches/upstream/current/doc/email.png   (with props)
    packages/pexpect/branches/upstream/current/doc/examples.html
    packages/pexpect/branches/upstream/current/doc/fdpexpect.html
    packages/pexpect/branches/upstream/current/doc/index.html
    packages/pexpect/branches/upstream/current/doc/index.template.html
    packages/pexpect/branches/upstream/current/doc/pexpect.html
    packages/pexpect/branches/upstream/current/doc/pxssh.html
    packages/pexpect/branches/upstream/current/doc/screen.html
    packages/pexpect/branches/upstream/current/examples/
    packages/pexpect/branches/upstream/current/examples/README
    packages/pexpect/branches/upstream/current/examples/bd_client.py   (with props)
    packages/pexpect/branches/upstream/current/examples/bd_client_web.py   (with props)
    packages/pexpect/branches/upstream/current/examples/bd_serv.py   (with props)
    packages/pexpect/branches/upstream/current/examples/chess.py   (with props)
    packages/pexpect/branches/upstream/current/examples/chess2.py   (with props)
    packages/pexpect/branches/upstream/current/examples/chess3.py   (with props)
    packages/pexpect/branches/upstream/current/examples/df.py   (with props)
    packages/pexpect/branches/upstream/current/examples/fix_cvs_files.py   (with props)
    packages/pexpect/branches/upstream/current/examples/ftp.py   (with props)
    packages/pexpect/branches/upstream/current/examples/monitor.py   (with props)
    packages/pexpect/branches/upstream/current/examples/passmass.py   (with props)
    packages/pexpect/branches/upstream/current/examples/python.py   (with props)
    packages/pexpect/branches/upstream/current/examples/rippy.py   (with props)
    packages/pexpect/branches/upstream/current/examples/script.py   (with props)
    packages/pexpect/branches/upstream/current/examples/ssh_session.py   (with props)
    packages/pexpect/branches/upstream/current/examples/ssh_tunnel.py   (with props)
    packages/pexpect/branches/upstream/current/examples/sshls.py   (with props)
    packages/pexpect/branches/upstream/current/examples/uptime.py   (with props)
    packages/pexpect/branches/upstream/current/fdpexpect.py
Modified:
    packages/pexpect/branches/upstream/current/ANSI.py
    packages/pexpect/branches/upstream/current/FSM.py
    packages/pexpect/branches/upstream/current/PKG-INFO
    packages/pexpect/branches/upstream/current/README
    packages/pexpect/branches/upstream/current/pexpect.py
    packages/pexpect/branches/upstream/current/pxssh.py
    packages/pexpect/branches/upstream/current/screen.py
    packages/pexpect/branches/upstream/current/setup.py   (contents, props changed)

Modified: packages/pexpect/branches/upstream/current/ANSI.py
URL: http://svn.debian.org/wsvn/python-modules/packages/pexpect/branches/upstream/current/ANSI.py?rev=929&op=diff
==============================================================================
--- packages/pexpect/branches/upstream/current/ANSI.py (original)
+++ packages/pexpect/branches/upstream/current/ANSI.py Mon Jun 19 10:53:24 2006
@@ -1,6 +1,6 @@
 '''
-$Revision: 1.10 $
-$Date: 2003/02/06 23:53:30 $
+$Revision: 374 $
+$Date: 2006-03-06 18:47:28 -0800 (Mon, 06 Mar 2006) $
 
 '''
 # references:
@@ -19,7 +19,7 @@
 
 def Emit (fsm):
         screen = fsm.something[0]
-        screen.write(fsm.input_symbol)
+        screen.write_ch(fsm.input_symbol)
 def StartNumber (fsm):
         fsm.something.append (fsm.input_symbol)
 def BuildNumber (fsm):
@@ -202,30 +202,23 @@
     def process (self, c):
         self.state.process(c)
     def process_list (self, l):
-        for c in l:
-            self.process (c)
-
-    def test (self):
-        import sys
-        dump = file('dump').read()
-        for c in dump:
-                self.state.process(c)
-                sys.stdout.write (c)
-                sys.stdout.flush()
-        print str(self)
-
-
-    def write (self, ch):
+        self.write(l)
+    def write (self, s):
+        for c in s:
+            self.process(c)
+    def flush (self):
+        pass
+    def write_ch (self, ch):
         '''Puts a character at the current cursor position.
         cursor position if moved forward with wrap-around, but
         no scrolling is done if the cursor hits the lower-right corner
         of the screen.
-        \r and \n both produce a call to crlf().
         '''
+        #\r and \n both produce a call to crlf().
         ch = ch[0]
 
         if ch == '\r':
-            self.crlf()
+        #    self.crlf()
             return
         if ch == '\n':
             self.crlf()
@@ -239,7 +232,6 @@
             fout = open ('log', 'a')
             fout.write ('Nonprint: ' + str(ord(ch)))
             fout.close()
-
             return
         self.put_abs(self.cur_r, self.cur_c, ch)
         old_r = self.cur_r
@@ -253,6 +245,37 @@
                 self.scroll_up ()
                 self.cursor_home (self.cur_r, 1)
                 self.erase_line()
+
+    def test (self):
+        import sys
+        write_text = 'I\'ve got a ferret sticking up my nose.\n' + \
+        '(He\'s got a ferret sticking up his nose.)\n' + \
+        'How it got there I can\'t tell\n' + \
+        'But now it\'s there it hurts like hell\n' + \
+        'And what is more it radically affects my sense of smell.\n' + \
+        '(His sense of smell.)\n' + \
+        'I can see a bare-bottomed mandril.\n' + \
+        '(Slyly eyeing his other nostril.)\n' + \
+        'If it jumps inside there too I really don\'t know what to do\n' + \
+        'I\'ll be the proud posessor of a kind of nasal zoo.\n' + \
+        '(A nasal zoo.)\n' + \
+        'I\'ve got a ferret sticking up my nose.\n' + \
+        '(And what is worst of all it constantly explodes.)\n' + \
+        '"Ferrets don\'t explode," you say\n' + \
+        'But it happened nine times yesterday\n' + \
+        'And I should know for each time I was standing in the way.\n' + \
+        'I\'ve got a ferret sticking up my nose.\n' + \
+        '(He\'s got a ferret sticking up his nose.)\n' + \
+        'How it got there I can\'t tell\n' + \
+        'But now it\'s there it hurts like hell\n' + \
+        'And what is more it radically affects my sense of smell.\n' + \
+        '(His sense of smell.)'
+        self.fill('.')
+        self.cursor_home()
+        for c in write_text:
+            self.write_ch (c)
+        print str(self)
+
 if __name__ == '__main__':
-    t = ANSI()
+    t = ANSI(6,65)
     t.test()

Modified: packages/pexpect/branches/upstream/current/FSM.py
URL: http://svn.debian.org/wsvn/python-modules/packages/pexpect/branches/upstream/current/FSM.py?rev=929&op=diff
==============================================================================
--- packages/pexpect/branches/upstream/current/FSM.py (original)
+++ packages/pexpect/branches/upstream/current/FSM.py Mon Jun 19 10:53:24 2006
@@ -60,8 +60,8 @@
 
 Noah Spurrier
 
-$Revision: 1.2 $
-$Date: 2002/08/28 19:07:03 $
+$Revision: 33 $
+$Date: 2002-08-28 12:07:03 -0700 (Wed, 28 Aug 2002) $
 
 '''
 

Added: packages/pexpect/branches/upstream/current/INSTALL
URL: http://svn.debian.org/wsvn/python-modules/packages/pexpect/branches/upstream/current/INSTALL?rev=929&op=file
==============================================================================
--- packages/pexpect/branches/upstream/current/INSTALL (added)
+++ packages/pexpect/branches/upstream/current/INSTALL Mon Jun 19 10:53:24 2006
@@ -1,0 +1,31 @@
+Installation
+------------
+This is a standard Python Distutil distribution. To install simply run:
+
+    python setup.py install
+
+This makes Pexpect available to any script on the machine. You need
+root access to install it this way. If you do not have root access or
+if you do not wish to install Pexpect so that is available to any script
+then you can just copy the pexpect.py file to same directory as your script.
+
+Trouble on Debian and Ubuntu
+----------------------------
+For some stupid reason Debian Linux does not include the distutils module
+in the standard 'python' package. Instead, the distutils module is packaged
+separately in the 'python-dev' package. So to add distutils back
+into Python, simply use aptitude or apt-get to install 'python-dev'.
+As root, run this command:
+    apt-get install python-dev
+Why they do this is mysterious because:
+    - It breaks the Python model of "batteries included".
+    'distutils' isn't an extra or optional module --
+    it's parts of the Standard Python Library.
+    - The Debian 'python-dev' package is a microscopic 50K installed.
+    So what are they saving?
+    - Distutils is not only interesting to developers. Many non-development
+    oriented Python packages use 'distutils' to install applications.
+    - As far as I can tell, the package maintainers must go through
+    more trouble to remove 'distutils' from the standard Python
+    distribution than it would take just to leave it in.
+

Added: packages/pexpect/branches/upstream/current/LICENSE
URL: http://svn.debian.org/wsvn/python-modules/packages/pexpect/branches/upstream/current/LICENSE?rev=929&op=file
==============================================================================
--- packages/pexpect/branches/upstream/current/LICENSE (added)
+++ packages/pexpect/branches/upstream/current/LICENSE Mon Jun 19 10:53:24 2006
@@ -1,0 +1,21 @@
+Free, open source, and all that good stuff.
+Pexpect Copyright (c) 2006 Noah Spurrier
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+USE OR OTHER DEALINGS IN THE SOFTWARE.
+

Modified: packages/pexpect/branches/upstream/current/PKG-INFO
URL: http://svn.debian.org/wsvn/python-modules/packages/pexpect/branches/upstream/current/PKG-INFO?rev=929&op=diff
==============================================================================
--- packages/pexpect/branches/upstream/current/PKG-INFO (original)
+++ packages/pexpect/branches/upstream/current/PKG-INFO Mon Jun 19 10:53:24 2006
@@ -1,10 +1,10 @@
 Metadata-Version: 1.0
 Name: pexpect
-Version: 2.0
+Version: 2.1
 Summary: Pexpect is a pure Python Expect. It allows easy control of other applications.
 Home-page: http://pexpect.sourceforge.net/
 Author: Noah Spurrier
 Author-email: noah at noah.org
-License: Python Software Foundation License
+License: MIT license
 Description: UNKNOWN
 Platform: UNIX

Modified: packages/pexpect/branches/upstream/current/README
URL: http://svn.debian.org/wsvn/python-modules/packages/pexpect/branches/upstream/current/README?rev=929&op=diff
==============================================================================
--- packages/pexpect/branches/upstream/current/README (original)
+++ packages/pexpect/branches/upstream/current/README Mon Jun 19 10:53:24 2006
@@ -16,7 +16,26 @@
 extensions to be compiled. It should work on any platform that supports the
 standard Python pty module. The Pexpect interface was designed to be easy to use.
 
-License: Python Software Foundation License
+Free, open source, and all that good stuff.
+Pexpect Copyright (c) 2006 Noah Spurrier
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 Noah Spurrier
 http://pexpect.sourceforge.net/

Added: packages/pexpect/branches/upstream/current/doc/ANSI.html
URL: http://svn.debian.org/wsvn/python-modules/packages/pexpect/branches/upstream/current/doc/ANSI.html?rev=929&op=file
==============================================================================
--- packages/pexpect/branches/upstream/current/doc/ANSI.html (added)
+++ packages/pexpect/branches/upstream/current/doc/ANSI.html Mon Jun 19 10:53:24 2006
@@ -1,0 +1,311 @@
+
+<!doctype html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html><head><title>Python: module ANSI</title>
+</head><body bgcolor="#f0f0f8">
+
+<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
+<tr bgcolor="#7799ee">
+<td valign=bottom>&nbsp;<br>
+<font color="#ffffff" face="helvetica, arial">&nbsp;<br><big><big><strong>ANSI</strong></big></big></font></td
+><td align=right valign=bottom
+><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/noah/documents/export/engineering/source/python/pexpect/trunk/pexpect/ANSI.py">/home/noah/documents/export/engineering/source/python/pexpect/trunk/pexpect/ANSI.py</a></font></td></tr></table>
+    <p><tt>$Revision:&nbsp;374&nbsp;$<br>
+$Date:&nbsp;2006-03-06&nbsp;18:47:28&nbsp;-0800&nbsp;(Mon,&nbsp;06&nbsp;Mar&nbsp;2006)&nbsp;$</tt></p>
+<p>
+<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
+<tr bgcolor="#aa55cc">
+<td colspan=3 valign=bottom>&nbsp;<br>
+<font color="#fffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
+    
+<tr><td bgcolor="#aa55cc"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
+<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="FSM.html">FSM</a><br>
+</td><td width="25%" valign=top><a href="copy.html">copy</a><br>
+</td><td width="25%" valign=top><a href="screen.html">screen</a><br>
+</td><td width="25%" valign=top><a href="string.html">string</a><br>
+</td></tr></table></td></tr></table><p>
+<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
+<tr bgcolor="#ee77aa">
+<td colspan=3 valign=bottom>&nbsp;<br>
+<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
+    
+<tr><td bgcolor="#ee77aa"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
+<td width="100%"><dl>
+<dt><font face="helvetica, arial"><a href="screen.html#screen">screen.screen</a>
+</font></dt><dd>
+<dl>
+<dt><font face="helvetica, arial"><a href="ANSI.html#term">term</a>
+</font></dt><dd>
+<dl>
+<dt><font face="helvetica, arial"><a href="ANSI.html#ANSI">ANSI</a>
+</font></dt></dl>
+</dd>
+</dl>
+</dd>
+</dl>
+ <p>
+<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
+<tr bgcolor="#ffc8d8">
+<td colspan=3 valign=bottom>&nbsp;<br>
+<font color="#000000" face="helvetica, arial"><a name="ANSI">class <strong>ANSI</strong></a>(<a href="ANSI.html#term">term</a>)</font></td></tr>
+    
+<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
+<td colspan=2><tt>This&nbsp;class&nbsp;encapsulates&nbsp;a&nbsp;generic&nbsp;terminal.<br>
+It&nbsp;filters&nbsp;a&nbsp;stream&nbsp;and&nbsp;maintains&nbsp;the&nbsp;state&nbsp;of<br>
+a&nbsp;<a href="screen.html#screen">screen</a>&nbsp;object.<br>&nbsp;</tt></td></tr>
+<tr><td>&nbsp;</td>
+<td width="100%"><dl><dt>Method resolution order:</dt>
+<dd><a href="ANSI.html#ANSI">ANSI</a></dd>
+<dd><a href="ANSI.html#term">term</a></dd>
+<dd><a href="screen.html#screen">screen.screen</a></dd>
+</dl>
+<hr>
+Methods defined here:<br>
+<dl><dt><a name="ANSI-__init__"><strong>__init__</strong></a>(self, r<font color="#909090">=24</font>, c<font color="#909090">=80</font>)</dt></dl>
+
+<dl><dt><a name="ANSI-flush"><strong>flush</strong></a>(self)</dt></dl>
+
+<dl><dt><a name="ANSI-process"><strong>process</strong></a>(self, c)</dt></dl>
+
+<dl><dt><a name="ANSI-process_list"><strong>process_list</strong></a>(self, l)</dt></dl>
+
+<dl><dt><a name="ANSI-test"><strong>test</strong></a>(self)</dt></dl>
+
+<dl><dt><a name="ANSI-write"><strong>write</strong></a>(self, s)</dt></dl>
+
+<dl><dt><a name="ANSI-write_ch"><strong>write_ch</strong></a>(self, ch)</dt><dd><tt>Puts&nbsp;a&nbsp;character&nbsp;at&nbsp;the&nbsp;current&nbsp;cursor&nbsp;position.<br>
+cursor&nbsp;position&nbsp;if&nbsp;moved&nbsp;forward&nbsp;with&nbsp;wrap-around,&nbsp;but<br>
+no&nbsp;scrolling&nbsp;is&nbsp;done&nbsp;if&nbsp;the&nbsp;cursor&nbsp;hits&nbsp;the&nbsp;lower-right&nbsp;corner<br>
+of&nbsp;the&nbsp;<a href="screen.html#screen">screen</a>.</tt></dd></dl>
+
+<hr>
+Methods inherited from <a href="screen.html#screen">screen.screen</a>:<br>
+<dl><dt><a name="ANSI-__str__"><strong>__str__</strong></a>(self)</dt></dl>
+
+<dl><dt><a name="ANSI-clear_all_tabs"><strong>clear_all_tabs</strong></a>(self)</dt><dd><tt>Clears&nbsp;all&nbsp;tabs.</tt></dd></dl>
+
+<dl><dt><a name="ANSI-clear_tab"><strong>clear_tab</strong></a>(self)</dt><dd><tt>Clears&nbsp;tab&nbsp;at&nbsp;the&nbsp;current&nbsp;position.</tt></dd></dl>
+
+<dl><dt><a name="ANSI-cr"><strong>cr</strong></a>(self)</dt><dd><tt>This&nbsp;moves&nbsp;the&nbsp;cursor&nbsp;to&nbsp;the&nbsp;beginning&nbsp;(col&nbsp;1)&nbsp;of&nbsp;the&nbsp;current&nbsp;row.</tt></dd></dl>
+
+<dl><dt><a name="ANSI-crlf"><strong>crlf</strong></a>(self)</dt><dd><tt>This&nbsp;advances&nbsp;the&nbsp;cursor&nbsp;with&nbsp;CRLF&nbsp;properties.<br>
+The&nbsp;cursor&nbsp;will&nbsp;line&nbsp;wrap&nbsp;and&nbsp;the&nbsp;<a href="screen.html#screen">screen</a>&nbsp;may&nbsp;scroll.</tt></dd></dl>
+
+<dl><dt><a name="ANSI-cursor_back"><strong>cursor_back</strong></a>(self, count<font color="#909090">=1</font>)</dt></dl>
+
+<dl><dt><a name="ANSI-cursor_constrain"><strong>cursor_constrain</strong></a>(self)</dt><dd><tt>This&nbsp;keeps&nbsp;the&nbsp;cursor&nbsp;within&nbsp;the&nbsp;<a href="screen.html#screen">screen</a>&nbsp;area.</tt></dd></dl>
+
+<dl><dt><a name="ANSI-cursor_down"><strong>cursor_down</strong></a>(self, count<font color="#909090">=1</font>)</dt></dl>
+
+<dl><dt><a name="ANSI-cursor_force_position"><strong>cursor_force_position</strong></a>(self, r, c)</dt><dd><tt>Identical&nbsp;to&nbsp;Cursor&nbsp;Home.</tt></dd></dl>
+
+<dl><dt><a name="ANSI-cursor_forward"><strong>cursor_forward</strong></a>(self, count<font color="#909090">=1</font>)</dt></dl>
+
+<dl><dt><a name="ANSI-cursor_home"><strong>cursor_home</strong></a>(self, r<font color="#909090">=1</font>, c<font color="#909090">=1</font>)</dt></dl>
+
+<dl><dt><a name="ANSI-cursor_restore_attrs"><strong>cursor_restore_attrs</strong></a>(self)</dt><dd><tt>Restores&nbsp;cursor&nbsp;position&nbsp;after&nbsp;a&nbsp;Save&nbsp;Cursor.</tt></dd></dl>
+
+<dl><dt><a name="ANSI-cursor_save"><strong>cursor_save</strong></a>(self)</dt><dd><tt>Save&nbsp;current&nbsp;cursor&nbsp;position.</tt></dd></dl>
+
+<dl><dt><a name="ANSI-cursor_save_attrs"><strong>cursor_save_attrs</strong></a>(self)</dt><dd><tt>Save&nbsp;current&nbsp;cursor&nbsp;position.</tt></dd></dl>
+
+<dl><dt><a name="ANSI-cursor_unsave"><strong>cursor_unsave</strong></a>(self)</dt><dd><tt>Restores&nbsp;cursor&nbsp;position&nbsp;after&nbsp;a&nbsp;Save&nbsp;Cursor.</tt></dd></dl>
+
+<dl><dt><a name="ANSI-cursor_up"><strong>cursor_up</strong></a>(self, count<font color="#909090">=1</font>)</dt></dl>
+
+<dl><dt><a name="ANSI-cursor_up_reverse"><strong>cursor_up_reverse</strong></a>(self)</dt></dl>
+
+<dl><dt><a name="ANSI-dump"><strong>dump</strong></a>(self)</dt><dd><tt>This&nbsp;returns&nbsp;a&nbsp;copy&nbsp;of&nbsp;the&nbsp;<a href="screen.html#screen">screen</a>&nbsp;as&nbsp;a&nbsp;string.<br>
+This&nbsp;is&nbsp;similar&nbsp;to&nbsp;__str__&nbsp;except&nbsp;that&nbsp;lines<br>
+are&nbsp;not&nbsp;terminated&nbsp;with&nbsp;line&nbsp;feeds.</tt></dd></dl>
+
+<dl><dt><a name="ANSI-erase_down"><strong>erase_down</strong></a>(self)</dt><dd><tt>Erases&nbsp;the&nbsp;<a href="screen.html#screen">screen</a>&nbsp;from&nbsp;the&nbsp;current&nbsp;line&nbsp;down&nbsp;to<br>
+the&nbsp;bottom&nbsp;of&nbsp;the&nbsp;<a href="screen.html#screen">screen</a>.</tt></dd></dl>
+
+<dl><dt><a name="ANSI-erase_end_of_line"><strong>erase_end_of_line</strong></a>(self)</dt><dd><tt>Erases&nbsp;from&nbsp;the&nbsp;current&nbsp;cursor&nbsp;position&nbsp;to<br>
+the&nbsp;end&nbsp;of&nbsp;the&nbsp;current&nbsp;line.</tt></dd></dl>
+
+<dl><dt><a name="ANSI-erase_line"><strong>erase_line</strong></a>(self)</dt><dd><tt>Erases&nbsp;the&nbsp;entire&nbsp;current&nbsp;line.</tt></dd></dl>
+
+<dl><dt><a name="ANSI-erase_screen"><strong>erase_screen</strong></a>(self)</dt><dd><tt>Erases&nbsp;the&nbsp;<a href="screen.html#screen">screen</a>&nbsp;with&nbsp;the&nbsp;background&nbsp;color.</tt></dd></dl>
+
+<dl><dt><a name="ANSI-erase_start_of_line"><strong>erase_start_of_line</strong></a>(self)</dt><dd><tt>Erases&nbsp;from&nbsp;the&nbsp;current&nbsp;cursor&nbsp;position&nbsp;to<br>
+the&nbsp;start&nbsp;of&nbsp;the&nbsp;current&nbsp;line.</tt></dd></dl>
+
+<dl><dt><a name="ANSI-erase_up"><strong>erase_up</strong></a>(self)</dt><dd><tt>Erases&nbsp;the&nbsp;<a href="screen.html#screen">screen</a>&nbsp;from&nbsp;the&nbsp;current&nbsp;line&nbsp;up&nbsp;to<br>
+the&nbsp;top&nbsp;of&nbsp;the&nbsp;<a href="screen.html#screen">screen</a>.</tt></dd></dl>
+
+<dl><dt><a name="ANSI-fill"><strong>fill</strong></a>(self, ch<font color="#909090">=' '</font>)</dt></dl>
+
+<dl><dt><a name="ANSI-fill_region"><strong>fill_region</strong></a>(self, rs, cs, re, ce, ch<font color="#909090">=' '</font>)</dt></dl>
+
+<dl><dt><a name="ANSI-get"><strong>get</strong></a>(self)</dt></dl>
+
+<dl><dt><a name="ANSI-get_abs"><strong>get_abs</strong></a>(self, r, c)</dt></dl>
+
+<dl><dt><a name="ANSI-get_region"><strong>get_region</strong></a>(self, rs, cs, re, ce)</dt><dd><tt>This&nbsp;returns&nbsp;a&nbsp;list&nbsp;of&nbsp;lines&nbsp;representing&nbsp;the&nbsp;region.</tt></dd></dl>
+
+<dl><dt><a name="ANSI-insert"><strong>insert</strong></a>(self, ch)</dt></dl>
+
+<dl><dt><a name="ANSI-insert_abs"><strong>insert_abs</strong></a>(self, r, c, ch)</dt><dd><tt>This&nbsp;inserts&nbsp;a&nbsp;character&nbsp;at&nbsp;(r,c).&nbsp;Everything&nbsp;under<br>
+and&nbsp;to&nbsp;the&nbsp;right&nbsp;is&nbsp;shifted&nbsp;right&nbsp;one&nbsp;character.<br>
+The&nbsp;last&nbsp;character&nbsp;of&nbsp;the&nbsp;line&nbsp;is&nbsp;lost.</tt></dd></dl>
+
+<dl><dt><a name="ANSI-lf"><strong>lf</strong></a>(self)</dt><dd><tt>This&nbsp;moves&nbsp;the&nbsp;cursor&nbsp;down&nbsp;with&nbsp;scrolling.</tt></dd></dl>
+
+<dl><dt><a name="ANSI-newline"><strong>newline</strong></a>(self)</dt><dd><tt>This&nbsp;is&nbsp;an&nbsp;alias&nbsp;for&nbsp;<a href="#ANSI-crlf">crlf</a>().</tt></dd></dl>
+
+<dl><dt><a name="ANSI-put"><strong>put</strong></a>(self, ch)</dt><dd><tt>This&nbsp;puts&nbsp;a&nbsp;characters&nbsp;at&nbsp;the&nbsp;current&nbsp;cursor&nbsp;position.</tt></dd></dl>
+
+<dl><dt><a name="ANSI-put_abs"><strong>put_abs</strong></a>(self, r, c, ch)</dt><dd><tt>Screen&nbsp;array&nbsp;starts&nbsp;at&nbsp;1&nbsp;index.</tt></dd></dl>
+
+<dl><dt><a name="ANSI-scroll_constrain"><strong>scroll_constrain</strong></a>(self)</dt><dd><tt>This&nbsp;keeps&nbsp;the&nbsp;scroll&nbsp;region&nbsp;within&nbsp;the&nbsp;<a href="screen.html#screen">screen</a>&nbsp;region.</tt></dd></dl>
+
+<dl><dt><a name="ANSI-scroll_down"><strong>scroll_down</strong></a>(self)</dt><dd><tt>Scroll&nbsp;display&nbsp;down&nbsp;one&nbsp;line.</tt></dd></dl>
+
+<dl><dt><a name="ANSI-scroll_screen"><strong>scroll_screen</strong></a>(self)</dt><dd><tt>Enable&nbsp;scrolling&nbsp;for&nbsp;entire&nbsp;display.</tt></dd></dl>
+
+<dl><dt><a name="ANSI-scroll_screen_rows"><strong>scroll_screen_rows</strong></a>(self, rs, re)</dt><dd><tt>Enable&nbsp;scrolling&nbsp;from&nbsp;row&nbsp;{start}&nbsp;to&nbsp;row&nbsp;{end}.</tt></dd></dl>
+
+<dl><dt><a name="ANSI-scroll_up"><strong>scroll_up</strong></a>(self)</dt><dd><tt>Scroll&nbsp;display&nbsp;up&nbsp;one&nbsp;line.</tt></dd></dl>
+
+<dl><dt><a name="ANSI-set_tab"><strong>set_tab</strong></a>(self)</dt><dd><tt>Sets&nbsp;a&nbsp;tab&nbsp;at&nbsp;the&nbsp;current&nbsp;position.</tt></dd></dl>
+
+</td></tr></table> <p>
+<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
+<tr bgcolor="#ffc8d8">
+<td colspan=3 valign=bottom>&nbsp;<br>
+<font color="#000000" face="helvetica, arial"><a name="term">class <strong>term</strong></a>(<a href="screen.html#screen">screen.screen</a>)</font></td></tr>
+    
+<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
+<td colspan=2><tt>This&nbsp;is&nbsp;a&nbsp;placeholder.&nbsp;<br>
+In&nbsp;theory&nbsp;I&nbsp;might&nbsp;want&nbsp;to&nbsp;add&nbsp;other&nbsp;terminal&nbsp;types.<br>&nbsp;</tt></td></tr>
+<tr><td>&nbsp;</td>
+<td width="100%">Methods defined here:<br>
+<dl><dt><a name="term-__init__"><strong>__init__</strong></a>(self, r<font color="#909090">=24</font>, c<font color="#909090">=80</font>)</dt></dl>
+
+<hr>
+Methods inherited from <a href="screen.html#screen">screen.screen</a>:<br>
+<dl><dt><a name="term-__str__"><strong>__str__</strong></a>(self)</dt></dl>
+
+<dl><dt><a name="term-clear_all_tabs"><strong>clear_all_tabs</strong></a>(self)</dt><dd><tt>Clears&nbsp;all&nbsp;tabs.</tt></dd></dl>
+
+<dl><dt><a name="term-clear_tab"><strong>clear_tab</strong></a>(self)</dt><dd><tt>Clears&nbsp;tab&nbsp;at&nbsp;the&nbsp;current&nbsp;position.</tt></dd></dl>
+
+<dl><dt><a name="term-cr"><strong>cr</strong></a>(self)</dt><dd><tt>This&nbsp;moves&nbsp;the&nbsp;cursor&nbsp;to&nbsp;the&nbsp;beginning&nbsp;(col&nbsp;1)&nbsp;of&nbsp;the&nbsp;current&nbsp;row.</tt></dd></dl>
+
+<dl><dt><a name="term-crlf"><strong>crlf</strong></a>(self)</dt><dd><tt>This&nbsp;advances&nbsp;the&nbsp;cursor&nbsp;with&nbsp;CRLF&nbsp;properties.<br>
+The&nbsp;cursor&nbsp;will&nbsp;line&nbsp;wrap&nbsp;and&nbsp;the&nbsp;<a href="screen.html#screen">screen</a>&nbsp;may&nbsp;scroll.</tt></dd></dl>
+
+<dl><dt><a name="term-cursor_back"><strong>cursor_back</strong></a>(self, count<font color="#909090">=1</font>)</dt></dl>
+
+<dl><dt><a name="term-cursor_constrain"><strong>cursor_constrain</strong></a>(self)</dt><dd><tt>This&nbsp;keeps&nbsp;the&nbsp;cursor&nbsp;within&nbsp;the&nbsp;<a href="screen.html#screen">screen</a>&nbsp;area.</tt></dd></dl>
+
+<dl><dt><a name="term-cursor_down"><strong>cursor_down</strong></a>(self, count<font color="#909090">=1</font>)</dt></dl>
+
+<dl><dt><a name="term-cursor_force_position"><strong>cursor_force_position</strong></a>(self, r, c)</dt><dd><tt>Identical&nbsp;to&nbsp;Cursor&nbsp;Home.</tt></dd></dl>
+
+<dl><dt><a name="term-cursor_forward"><strong>cursor_forward</strong></a>(self, count<font color="#909090">=1</font>)</dt></dl>
+
+<dl><dt><a name="term-cursor_home"><strong>cursor_home</strong></a>(self, r<font color="#909090">=1</font>, c<font color="#909090">=1</font>)</dt></dl>
+
+<dl><dt><a name="term-cursor_restore_attrs"><strong>cursor_restore_attrs</strong></a>(self)</dt><dd><tt>Restores&nbsp;cursor&nbsp;position&nbsp;after&nbsp;a&nbsp;Save&nbsp;Cursor.</tt></dd></dl>
+
+<dl><dt><a name="term-cursor_save"><strong>cursor_save</strong></a>(self)</dt><dd><tt>Save&nbsp;current&nbsp;cursor&nbsp;position.</tt></dd></dl>
+
+<dl><dt><a name="term-cursor_save_attrs"><strong>cursor_save_attrs</strong></a>(self)</dt><dd><tt>Save&nbsp;current&nbsp;cursor&nbsp;position.</tt></dd></dl>
+
+<dl><dt><a name="term-cursor_unsave"><strong>cursor_unsave</strong></a>(self)</dt><dd><tt>Restores&nbsp;cursor&nbsp;position&nbsp;after&nbsp;a&nbsp;Save&nbsp;Cursor.</tt></dd></dl>
+
+<dl><dt><a name="term-cursor_up"><strong>cursor_up</strong></a>(self, count<font color="#909090">=1</font>)</dt></dl>
+
+<dl><dt><a name="term-cursor_up_reverse"><strong>cursor_up_reverse</strong></a>(self)</dt></dl>
+
+<dl><dt><a name="term-dump"><strong>dump</strong></a>(self)</dt><dd><tt>This&nbsp;returns&nbsp;a&nbsp;copy&nbsp;of&nbsp;the&nbsp;<a href="screen.html#screen">screen</a>&nbsp;as&nbsp;a&nbsp;string.<br>
+This&nbsp;is&nbsp;similar&nbsp;to&nbsp;__str__&nbsp;except&nbsp;that&nbsp;lines<br>
+are&nbsp;not&nbsp;terminated&nbsp;with&nbsp;line&nbsp;feeds.</tt></dd></dl>
+
+<dl><dt><a name="term-erase_down"><strong>erase_down</strong></a>(self)</dt><dd><tt>Erases&nbsp;the&nbsp;<a href="screen.html#screen">screen</a>&nbsp;from&nbsp;the&nbsp;current&nbsp;line&nbsp;down&nbsp;to<br>
+the&nbsp;bottom&nbsp;of&nbsp;the&nbsp;<a href="screen.html#screen">screen</a>.</tt></dd></dl>
+
+<dl><dt><a name="term-erase_end_of_line"><strong>erase_end_of_line</strong></a>(self)</dt><dd><tt>Erases&nbsp;from&nbsp;the&nbsp;current&nbsp;cursor&nbsp;position&nbsp;to<br>
+the&nbsp;end&nbsp;of&nbsp;the&nbsp;current&nbsp;line.</tt></dd></dl>
+
+<dl><dt><a name="term-erase_line"><strong>erase_line</strong></a>(self)</dt><dd><tt>Erases&nbsp;the&nbsp;entire&nbsp;current&nbsp;line.</tt></dd></dl>
+
+<dl><dt><a name="term-erase_screen"><strong>erase_screen</strong></a>(self)</dt><dd><tt>Erases&nbsp;the&nbsp;<a href="screen.html#screen">screen</a>&nbsp;with&nbsp;the&nbsp;background&nbsp;color.</tt></dd></dl>
+
+<dl><dt><a name="term-erase_start_of_line"><strong>erase_start_of_line</strong></a>(self)</dt><dd><tt>Erases&nbsp;from&nbsp;the&nbsp;current&nbsp;cursor&nbsp;position&nbsp;to<br>
+the&nbsp;start&nbsp;of&nbsp;the&nbsp;current&nbsp;line.</tt></dd></dl>
+
+<dl><dt><a name="term-erase_up"><strong>erase_up</strong></a>(self)</dt><dd><tt>Erases&nbsp;the&nbsp;<a href="screen.html#screen">screen</a>&nbsp;from&nbsp;the&nbsp;current&nbsp;line&nbsp;up&nbsp;to<br>
+the&nbsp;top&nbsp;of&nbsp;the&nbsp;<a href="screen.html#screen">screen</a>.</tt></dd></dl>
+
+<dl><dt><a name="term-fill"><strong>fill</strong></a>(self, ch<font color="#909090">=' '</font>)</dt></dl>
+
+<dl><dt><a name="term-fill_region"><strong>fill_region</strong></a>(self, rs, cs, re, ce, ch<font color="#909090">=' '</font>)</dt></dl>
+
+<dl><dt><a name="term-get"><strong>get</strong></a>(self)</dt></dl>
+
+<dl><dt><a name="term-get_abs"><strong>get_abs</strong></a>(self, r, c)</dt></dl>
+
+<dl><dt><a name="term-get_region"><strong>get_region</strong></a>(self, rs, cs, re, ce)</dt><dd><tt>This&nbsp;returns&nbsp;a&nbsp;list&nbsp;of&nbsp;lines&nbsp;representing&nbsp;the&nbsp;region.</tt></dd></dl>
+
+<dl><dt><a name="term-insert"><strong>insert</strong></a>(self, ch)</dt></dl>
+
+<dl><dt><a name="term-insert_abs"><strong>insert_abs</strong></a>(self, r, c, ch)</dt><dd><tt>This&nbsp;inserts&nbsp;a&nbsp;character&nbsp;at&nbsp;(r,c).&nbsp;Everything&nbsp;under<br>
+and&nbsp;to&nbsp;the&nbsp;right&nbsp;is&nbsp;shifted&nbsp;right&nbsp;one&nbsp;character.<br>
+The&nbsp;last&nbsp;character&nbsp;of&nbsp;the&nbsp;line&nbsp;is&nbsp;lost.</tt></dd></dl>
+
+<dl><dt><a name="term-lf"><strong>lf</strong></a>(self)</dt><dd><tt>This&nbsp;moves&nbsp;the&nbsp;cursor&nbsp;down&nbsp;with&nbsp;scrolling.</tt></dd></dl>
+
+<dl><dt><a name="term-newline"><strong>newline</strong></a>(self)</dt><dd><tt>This&nbsp;is&nbsp;an&nbsp;alias&nbsp;for&nbsp;<a href="#term-crlf">crlf</a>().</tt></dd></dl>
+
+<dl><dt><a name="term-put"><strong>put</strong></a>(self, ch)</dt><dd><tt>This&nbsp;puts&nbsp;a&nbsp;characters&nbsp;at&nbsp;the&nbsp;current&nbsp;cursor&nbsp;position.</tt></dd></dl>
+
+<dl><dt><a name="term-put_abs"><strong>put_abs</strong></a>(self, r, c, ch)</dt><dd><tt>Screen&nbsp;array&nbsp;starts&nbsp;at&nbsp;1&nbsp;index.</tt></dd></dl>
+
+<dl><dt><a name="term-scroll_constrain"><strong>scroll_constrain</strong></a>(self)</dt><dd><tt>This&nbsp;keeps&nbsp;the&nbsp;scroll&nbsp;region&nbsp;within&nbsp;the&nbsp;<a href="screen.html#screen">screen</a>&nbsp;region.</tt></dd></dl>
+
+<dl><dt><a name="term-scroll_down"><strong>scroll_down</strong></a>(self)</dt><dd><tt>Scroll&nbsp;display&nbsp;down&nbsp;one&nbsp;line.</tt></dd></dl>
+
+<dl><dt><a name="term-scroll_screen"><strong>scroll_screen</strong></a>(self)</dt><dd><tt>Enable&nbsp;scrolling&nbsp;for&nbsp;entire&nbsp;display.</tt></dd></dl>
+
+<dl><dt><a name="term-scroll_screen_rows"><strong>scroll_screen_rows</strong></a>(self, rs, re)</dt><dd><tt>Enable&nbsp;scrolling&nbsp;from&nbsp;row&nbsp;{start}&nbsp;to&nbsp;row&nbsp;{end}.</tt></dd></dl>
+
+<dl><dt><a name="term-scroll_up"><strong>scroll_up</strong></a>(self)</dt><dd><tt>Scroll&nbsp;display&nbsp;up&nbsp;one&nbsp;line.</tt></dd></dl>
+
+<dl><dt><a name="term-set_tab"><strong>set_tab</strong></a>(self)</dt><dd><tt>Sets&nbsp;a&nbsp;tab&nbsp;at&nbsp;the&nbsp;current&nbsp;position.</tt></dd></dl>
+
+</td></tr></table></td></tr></table><p>
+<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
+<tr bgcolor="#eeaa77">
+<td colspan=3 valign=bottom>&nbsp;<br>
+<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
+    
+<tr><td bgcolor="#eeaa77"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
+<td width="100%"><dl><dt><a name="-BuildNumber"><strong>BuildNumber</strong></a>(fsm)</dt></dl>
+ <dl><dt><a name="-DoBack"><strong>DoBack</strong></a>(fsm)</dt></dl>
+ <dl><dt><a name="-DoBackOne"><strong>DoBackOne</strong></a>(fsm)</dt></dl>
+ <dl><dt><a name="-DoCursorRestore"><strong>DoCursorRestore</strong></a>(fsm)</dt></dl>
+ <dl><dt><a name="-DoCursorSave"><strong>DoCursorSave</strong></a>(fsm)</dt></dl>
+ <dl><dt><a name="-DoDown"><strong>DoDown</strong></a>(fsm)</dt></dl>
+ <dl><dt><a name="-DoDownOne"><strong>DoDownOne</strong></a>(fsm)</dt></dl>
+ <dl><dt><a name="-DoEnableScroll"><strong>DoEnableScroll</strong></a>(fsm)</dt></dl>
+ <dl><dt><a name="-DoErase"><strong>DoErase</strong></a>(fsm)</dt></dl>
+ <dl><dt><a name="-DoEraseDown"><strong>DoEraseDown</strong></a>(fsm)</dt></dl>
+ <dl><dt><a name="-DoEraseEndOfLine"><strong>DoEraseEndOfLine</strong></a>(fsm)</dt></dl>
+ <dl><dt><a name="-DoEraseLine"><strong>DoEraseLine</strong></a>(fsm)</dt></dl>
+ <dl><dt><a name="-DoForward"><strong>DoForward</strong></a>(fsm)</dt></dl>
+ <dl><dt><a name="-DoForwardOne"><strong>DoForwardOne</strong></a>(fsm)</dt></dl>
+ <dl><dt><a name="-DoHome"><strong>DoHome</strong></a>(fsm)</dt></dl>
+ <dl><dt><a name="-DoHomeOrigin"><strong>DoHomeOrigin</strong></a>(fsm)</dt></dl>
+ <dl><dt><a name="-DoMode"><strong>DoMode</strong></a>(fsm)</dt></dl>
+ <dl><dt><a name="-DoScrollRegion"><strong>DoScrollRegion</strong></a>(fsm)</dt></dl>
+ <dl><dt><a name="-DoUp"><strong>DoUp</strong></a>(fsm)</dt></dl>
+ <dl><dt><a name="-DoUpOne"><strong>DoUpOne</strong></a>(fsm)</dt></dl>
+ <dl><dt><a name="-DoUpReverse"><strong>DoUpReverse</strong></a>(fsm)</dt></dl>
+ <dl><dt><a name="-Emit"><strong>Emit</strong></a>(fsm)</dt></dl>
+ <dl><dt><a name="-Log"><strong>Log</strong></a>(fsm)</dt></dl>
+ <dl><dt><a name="-StartNumber"><strong>StartNumber</strong></a>(fsm)</dt></dl>
+</td></tr></table>
+</body></html>

Added: packages/pexpect/branches/upstream/current/doc/FSM.html
URL: http://svn.debian.org/wsvn/python-modules/packages/pexpect/branches/upstream/current/doc/FSM.html?rev=929&op=file
==============================================================================
--- packages/pexpect/branches/upstream/current/doc/FSM.html (added)
+++ packages/pexpect/branches/upstream/current/doc/FSM.html Mon Jun 19 10:53:24 2006
@@ -1,0 +1,210 @@
+
+<!doctype html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html><head><title>Python: module FSM</title>
+</head><body bgcolor="#f0f0f8">
+
+<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
+<tr bgcolor="#7799ee">
+<td valign=bottom>&nbsp;<br>
+<font color="#ffffff" face="helvetica, arial">&nbsp;<br><big><big><strong>FSM</strong></big></big></font></td
+><td align=right valign=bottom
+><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/noah/documents/export/engineering/source/python/pexpect/trunk/pexpect/FSM.py">/home/noah/documents/export/engineering/source/python/pexpect/trunk/pexpect/FSM.py</a></font></td></tr></table>
+    <p><tt>This&nbsp;module&nbsp;implements&nbsp;a&nbsp;Finite&nbsp;State&nbsp;Machine&nbsp;(<a href="#FSM">FSM</a>).<br>
+In&nbsp;addition&nbsp;to&nbsp;state&nbsp;this&nbsp;<a href="#FSM">FSM</a>&nbsp;also&nbsp;maintains&nbsp;a&nbsp;user&nbsp;defined&nbsp;"something".<br>
+This&nbsp;"something"&nbsp;is&nbsp;effectively&nbsp;memory,&nbsp;so&nbsp;this&nbsp;<a href="#FSM">FSM</a>&nbsp;could&nbsp;be&nbsp;considered<br>
+a&nbsp;Push-down&nbsp;Automata&nbsp;(PDA)&nbsp;since&nbsp;a&nbsp;PDA&nbsp;is&nbsp;a&nbsp;<a href="#FSM">FSM</a>&nbsp;+&nbsp;memory.<br>
+&nbsp;<br>
+The&nbsp;following&nbsp;describes&nbsp;how&nbsp;the&nbsp;<a href="#FSM">FSM</a>&nbsp;works,&nbsp;but&nbsp;you&nbsp;will&nbsp;probably&nbsp;also&nbsp;need<br>
+to&nbsp;see&nbsp;the&nbsp;example&nbsp;function&nbsp;to&nbsp;understand&nbsp;how&nbsp;the&nbsp;<a href="#FSM">FSM</a>&nbsp;is&nbsp;used&nbsp;in&nbsp;practice.<br>
+&nbsp;<br>
+You&nbsp;define&nbsp;an&nbsp;<a href="#FSM">FSM</a>&nbsp;by&nbsp;building&nbsp;tables&nbsp;of&nbsp;transitions.<br>
+For&nbsp;a&nbsp;given&nbsp;input&nbsp;symbol&nbsp;the&nbsp;process()&nbsp;method&nbsp;uses&nbsp;these&nbsp;tables&nbsp;<br>
+to&nbsp;decide&nbsp;what&nbsp;action&nbsp;to&nbsp;call&nbsp;and&nbsp;what&nbsp;the&nbsp;next&nbsp;state&nbsp;will&nbsp;be.&nbsp;<br>
+The&nbsp;<a href="#FSM">FSM</a>&nbsp;has&nbsp;a&nbsp;table&nbsp;of&nbsp;transitions&nbsp;that&nbsp;associate:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(input_symbol,&nbsp;current_state)&nbsp;--&gt;&nbsp;(action,&nbsp;next_state)<br>
+where&nbsp;"action"&nbsp;is&nbsp;a&nbsp;function&nbsp;you&nbsp;define.&nbsp;The&nbsp;symbols&nbsp;and&nbsp;states&nbsp;<br>
+can&nbsp;be&nbsp;any&nbsp;objects.&nbsp;You&nbsp;use&nbsp;the&nbsp;add_transition()&nbsp;and&nbsp;add_transition_list()&nbsp;<br>
+methods&nbsp;to&nbsp;add&nbsp;to&nbsp;the&nbsp;transition&nbsp;table.&nbsp;The&nbsp;<a href="#FSM">FSM</a>&nbsp;also&nbsp;has&nbsp;a&nbsp;table<br>
+of&nbsp;transitions&nbsp;that&nbsp;associate:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(current_state)&nbsp;--&gt;&nbsp;(action,&nbsp;next_state)<br>
+You&nbsp;use&nbsp;the&nbsp;add_transition_any()&nbsp;method&nbsp;to&nbsp;add&nbsp;to&nbsp;this&nbsp;transition&nbsp;table.<br>
+The&nbsp;<a href="#FSM">FSM</a>&nbsp;also&nbsp;has&nbsp;one&nbsp;default&nbsp;transition&nbsp;that&nbsp;is&nbsp;not&nbsp;associated<br>
+with&nbsp;any&nbsp;specific&nbsp;input_symbol&nbsp;or&nbsp;state.&nbsp;You&nbsp;use&nbsp;the&nbsp;<br>
+set_default_transition()&nbsp;method&nbsp;to&nbsp;set&nbsp;the&nbsp;default&nbsp;transition.<br>
+&nbsp;<br>
+When&nbsp;an&nbsp;action&nbsp;function&nbsp;is&nbsp;called&nbsp;it&nbsp;is&nbsp;passed&nbsp;a&nbsp;reference&nbsp;to&nbsp;the&nbsp;<a href="#FSM">FSM</a>.<br>
+The&nbsp;action&nbsp;function&nbsp;may&nbsp;then&nbsp;access&nbsp;attributes&nbsp;of&nbsp;the&nbsp;<a href="#FSM">FSM</a>&nbsp;such&nbsp;as<br>
+input_symbol,&nbsp;current_state,&nbsp;or&nbsp;"something".&nbsp;The&nbsp;"something"&nbsp;attribute&nbsp;<br>
+can&nbsp;be&nbsp;any&nbsp;object&nbsp;that&nbsp;you&nbsp;want&nbsp;to&nbsp;pass&nbsp;along&nbsp;to&nbsp;the&nbsp;action&nbsp;functions.<br>
+It&nbsp;is&nbsp;not&nbsp;used&nbsp;by&nbsp;the&nbsp;<a href="#FSM">FSM</a>.&nbsp;For&nbsp;parsing&nbsp;you&nbsp;would&nbsp;typically&nbsp;pass&nbsp;a&nbsp;list&nbsp;<br>
+to&nbsp;be&nbsp;used&nbsp;as&nbsp;a&nbsp;stack.<br>
+&nbsp;<br>
+The&nbsp;processing&nbsp;sequence&nbsp;is&nbsp;as&nbsp;follows.<br>
+The&nbsp;process()&nbsp;method&nbsp;is&nbsp;given&nbsp;an&nbsp;input_symbol&nbsp;to&nbsp;process.<br>
+The&nbsp;<a href="#FSM">FSM</a>&nbsp;will&nbsp;search&nbsp;the&nbsp;table&nbsp;of&nbsp;transitions&nbsp;that&nbsp;associate:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(input_symbol,&nbsp;current_state)&nbsp;--&gt;&nbsp;(action,&nbsp;next_state)&nbsp;<br>
+If&nbsp;the&nbsp;pair&nbsp;(input_symbol,&nbsp;current_state)&nbsp;is&nbsp;found&nbsp;then&nbsp;<br>
+process()&nbsp;will&nbsp;call&nbsp;the&nbsp;associated&nbsp;action&nbsp;function&nbsp;and&nbsp;then&nbsp;set&nbsp;the&nbsp;<br>
+current&nbsp;state&nbsp;to&nbsp;the&nbsp;next_state.<br>
+&nbsp;<br>
+If&nbsp;the&nbsp;<a href="#FSM">FSM</a>&nbsp;cannot&nbsp;find&nbsp;a&nbsp;match&nbsp;for&nbsp;(input_symbol,&nbsp;current_state)<br>
+it&nbsp;will&nbsp;then&nbsp;search&nbsp;the&nbsp;table&nbsp;of&nbsp;transitions&nbsp;that&nbsp;associate:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(current_state)&nbsp;--&gt;&nbsp;(action,&nbsp;next_state)<br>
+If&nbsp;the&nbsp;current_state&nbsp;is&nbsp;found&nbsp;then&nbsp;the&nbsp;process()&nbsp;method&nbsp;will&nbsp;call&nbsp;<br>
+the&nbsp;associated&nbsp;action&nbsp;function&nbsp;and&nbsp;then&nbsp;set&nbsp;the&nbsp;current&nbsp;state&nbsp;to&nbsp;<br>
+the&nbsp;next_state.&nbsp;Notice&nbsp;that&nbsp;this&nbsp;table&nbsp;lacks&nbsp;an&nbsp;input_symbol.&nbsp;<br>
+It&nbsp;lets&nbsp;you&nbsp;define&nbsp;transitions&nbsp;for&nbsp;a&nbsp;current_state&nbsp;and&nbsp;ANY&nbsp;input_symbol.<br>
+Hence,&nbsp;it&nbsp;is&nbsp;called&nbsp;the&nbsp;"any"&nbsp;table.&nbsp;Remember,&nbsp;it&nbsp;is&nbsp;always&nbsp;checked<br>
+after&nbsp;first&nbsp;searching&nbsp;the&nbsp;table&nbsp;for&nbsp;a&nbsp;specific&nbsp;(input_symbol,&nbsp;current_state).<br>
+&nbsp;<br>
+For&nbsp;the&nbsp;case&nbsp;where&nbsp;the&nbsp;<a href="#FSM">FSM</a>&nbsp;did&nbsp;not&nbsp;match&nbsp;either&nbsp;of&nbsp;the&nbsp;previous&nbsp;two&nbsp;cases<br>
+the&nbsp;<a href="#FSM">FSM</a>&nbsp;will&nbsp;try&nbsp;to&nbsp;use&nbsp;the&nbsp;default&nbsp;transition.&nbsp;If&nbsp;the&nbsp;default&nbsp;transition<br>
+is&nbsp;defined&nbsp;then&nbsp;the&nbsp;process()&nbsp;method&nbsp;will&nbsp;call&nbsp;the&nbsp;associated&nbsp;action&nbsp;function<br>
+and&nbsp;then&nbsp;set&nbsp;the&nbsp;current&nbsp;state&nbsp;to&nbsp;the&nbsp;next_state.&nbsp;This&nbsp;lets&nbsp;you&nbsp;define&nbsp;<br>
+a&nbsp;default&nbsp;transition&nbsp;as&nbsp;a&nbsp;catch-all&nbsp;case.&nbsp;You&nbsp;can&nbsp;think&nbsp;of&nbsp;it&nbsp;as&nbsp;an&nbsp;<br>
+exception&nbsp;handler.&nbsp;There&nbsp;can&nbsp;be&nbsp;only&nbsp;one&nbsp;default&nbsp;transition.<br>
+&nbsp;<br>
+Finally,&nbsp;if&nbsp;none&nbsp;of&nbsp;the&nbsp;previous&nbsp;cases&nbsp;are&nbsp;defined&nbsp;for&nbsp;an&nbsp;input_symbol&nbsp;<br>
+and&nbsp;current_state&nbsp;then&nbsp;the&nbsp;<a href="#FSM">FSM</a>&nbsp;will&nbsp;raise&nbsp;an&nbsp;exception.&nbsp;<br>
+This&nbsp;may&nbsp;be&nbsp;desirable,&nbsp;but&nbsp;you&nbsp;can&nbsp;always&nbsp;prevent&nbsp;this&nbsp;just&nbsp;by&nbsp;<br>
+defining&nbsp;a&nbsp;default&nbsp;transition.<br>
+&nbsp;<br>
+Noah&nbsp;Spurrier<br>
+&nbsp;<br>
+$Revision:&nbsp;33&nbsp;$<br>
+$Date:&nbsp;2002-08-28&nbsp;12:07:03&nbsp;-0700&nbsp;(Wed,&nbsp;28&nbsp;Aug&nbsp;2002)&nbsp;$</tt></p>
+<p>
+<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
+<tr bgcolor="#aa55cc">
+<td colspan=3 valign=bottom>&nbsp;<br>
+<font color="#fffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
+    
+<tr><td bgcolor="#aa55cc"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
+<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="string.html">string</a><br>
+</td><td width="25%" valign=top></td><td width="25%" valign=top></td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
+<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
+<tr bgcolor="#ee77aa">
+<td colspan=3 valign=bottom>&nbsp;<br>
+<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
+    
+<tr><td bgcolor="#ee77aa"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
+<td width="100%"><dl>
+<dt><font face="helvetica, arial"><a href="FSM.html#FSM">FSM</a>
+</font></dt><dt><font face="helvetica, arial"><a href="exceptions.html#Exception">exceptions.Exception</a>
+</font></dt><dd>
+<dl>
+<dt><font face="helvetica, arial"><a href="FSM.html#ExceptionFSM">ExceptionFSM</a>
+</font></dt></dl>
+</dd>
+</dl>
+ <p>
+<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
+<tr bgcolor="#ffc8d8">
+<td colspan=3 valign=bottom>&nbsp;<br>
+<font color="#000000" face="helvetica, arial"><a name="ExceptionFSM">class <strong>ExceptionFSM</strong></a>(<a href="exceptions.html#Exception">exceptions.Exception</a>)</font></td></tr>
+    
+<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
+<td colspan=2><tt>This&nbsp;is&nbsp;the&nbsp;<a href="#FSM">FSM</a>&nbsp;<a href="exceptions.html#Exception">Exception</a>&nbsp;class.<br>&nbsp;</tt></td></tr>
+<tr><td>&nbsp;</td>
+<td width="100%">Methods defined here:<br>
+<dl><dt><a name="ExceptionFSM-__init__"><strong>__init__</strong></a>(self, value)</dt></dl>
+
+<dl><dt><a name="ExceptionFSM-__str__"><strong>__str__</strong></a>(self)</dt></dl>
+
+<hr>
+Methods inherited from <a href="exceptions.html#Exception">exceptions.Exception</a>:<br>
+<dl><dt><a name="ExceptionFSM-__getitem__"><strong>__getitem__</strong></a>(...)</dt></dl>
+
+</td></tr></table> <p>
+<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
+<tr bgcolor="#ffc8d8">
+<td colspan=3 valign=bottom>&nbsp;<br>
+<font color="#000000" face="helvetica, arial"><a name="FSM">class <strong>FSM</strong></a></font></td></tr>
+    
+<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
+<td colspan=2><tt>This&nbsp;is&nbsp;a&nbsp;Finite&nbsp;State&nbsp;Machine&nbsp;(<a href="#FSM">FSM</a>).<br>&nbsp;</tt></td></tr>
+<tr><td>&nbsp;</td>
+<td width="100%">Methods defined here:<br>
+<dl><dt><a name="FSM-__init__"><strong>__init__</strong></a>(self, initial_state, something)</dt><dd><tt>This&nbsp;creates&nbsp;the&nbsp;<a href="#FSM">FSM</a>.&nbsp;<br>
+You&nbsp;set&nbsp;the&nbsp;initial&nbsp;state&nbsp;here.&nbsp;The&nbsp;"something"&nbsp;attribute&nbsp;is&nbsp;any<br>
+object&nbsp;that&nbsp;you&nbsp;want&nbsp;to&nbsp;pass&nbsp;along&nbsp;to&nbsp;the&nbsp;action&nbsp;functions.<br>
+It&nbsp;is&nbsp;not&nbsp;used&nbsp;by&nbsp;the&nbsp;<a href="#FSM">FSM</a>.&nbsp;For&nbsp;parsing&nbsp;you&nbsp;would&nbsp;typically&nbsp;pass&nbsp;<br>
+a&nbsp;list&nbsp;to&nbsp;be&nbsp;used&nbsp;as&nbsp;a&nbsp;stack.</tt></dd></dl>
+
+<dl><dt><a name="FSM-add_transition"><strong>add_transition</strong></a>(self, input_symbol, state, action, next_state)</dt><dd><tt>This&nbsp;adds&nbsp;a&nbsp;transition&nbsp;that&nbsp;associates<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(input_symbol,&nbsp;current_state)&nbsp;--&gt;&nbsp;(action,&nbsp;next_state)<br>
+The&nbsp;action&nbsp;may&nbsp;be&nbsp;set&nbsp;to&nbsp;None&nbsp;in&nbsp;which&nbsp;case&nbsp;the&nbsp;<a href="#FSM-process">process</a>()&nbsp;method&nbsp;<br>
+will&nbsp;ignore&nbsp;the&nbsp;action&nbsp;and&nbsp;only&nbsp;set&nbsp;the&nbsp;next_state.<br>
+&nbsp;&nbsp;&nbsp;<br>
+You&nbsp;can&nbsp;also&nbsp;set&nbsp;transitions&nbsp;for&nbsp;a&nbsp;list&nbsp;of&nbsp;symbols&nbsp;by&nbsp;using<br>
+<a href="#FSM-add_transition_list">add_transition_list</a>().</tt></dd></dl>
+
+<dl><dt><a name="FSM-add_transition_any"><strong>add_transition_any</strong></a>(self, state, action, next_state)</dt><dd><tt>This&nbsp;adds&nbsp;a&nbsp;transition&nbsp;that&nbsp;associates<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(current_state)&nbsp;--&gt;&nbsp;(action,&nbsp;next_state)<br>
+The&nbsp;<a href="#FSM-process">process</a>()&nbsp;method&nbsp;checks&nbsp;these&nbsp;associations&nbsp;if&nbsp;it&nbsp;cannot<br>
+first&nbsp;find&nbsp;a&nbsp;match&nbsp;of&nbsp;an&nbsp;(input_symbol,&nbsp;current_state).</tt></dd></dl>
+
+<dl><dt><a name="FSM-add_transition_list"><strong>add_transition_list</strong></a>(self, list_input_symbols, state, action, next_state)</dt><dd><tt>This&nbsp;adds&nbsp;the&nbsp;same&nbsp;transition&nbsp;for&nbsp;lots&nbsp;of&nbsp;different&nbsp;input&nbsp;symbols.<br>
+You&nbsp;can&nbsp;pass&nbsp;a&nbsp;list&nbsp;or&nbsp;a&nbsp;string.&nbsp;Note&nbsp;that&nbsp;it&nbsp;is&nbsp;handy&nbsp;to&nbsp;use<br>
+string.digits,&nbsp;string.whitespace,&nbsp;string.letters,&nbsp;etc.&nbsp;to&nbsp;add<br>
+transitions&nbsp;that&nbsp;match&nbsp;character&nbsp;classes.</tt></dd></dl>
+
+<dl><dt><a name="FSM-get_transition"><strong>get_transition</strong></a>(self, input_symbol, state)</dt><dd><tt>This&nbsp;returns&nbsp;(action,&nbsp;next&nbsp;state)&nbsp;given&nbsp;an&nbsp;input_symbol&nbsp;and&nbsp;state.<br>
+This&nbsp;leaves&nbsp;the&nbsp;<a href="#FSM">FSM</a>&nbsp;unchanged.&nbsp;This&nbsp;does&nbsp;not&nbsp;update&nbsp;the&nbsp;current&nbsp;state&nbsp;<br>
+nor&nbsp;does&nbsp;it&nbsp;trigger&nbsp;the&nbsp;output&nbsp;action.&nbsp;Normally&nbsp;you&nbsp;do&nbsp;not&nbsp;call&nbsp;<br>
+this&nbsp;method.&nbsp;It&nbsp;is&nbsp;called&nbsp;by&nbsp;<a href="#FSM-process">process</a>().<br>
+&nbsp;<br>
+The&nbsp;sequence&nbsp;of&nbsp;steps&nbsp;to&nbsp;check&nbsp;for&nbsp;a&nbsp;defined&nbsp;transition&nbsp;goes&nbsp;from&nbsp;<br>
+the&nbsp;most&nbsp;specific&nbsp;to&nbsp;the&nbsp;least&nbsp;specific.&nbsp;<br>
+1.&nbsp;Check&nbsp;state_transitions[]&nbsp;that&nbsp;match&nbsp;(input_symbol,&nbsp;state)<br>
+2.&nbsp;Check&nbsp;state_transitions_any[]&nbsp;that&nbsp;match&nbsp;(state)<br>
+&nbsp;&nbsp;&nbsp;In&nbsp;other&nbsp;words,&nbsp;match&nbsp;a&nbsp;specific&nbsp;state&nbsp;and&nbsp;ANY&nbsp;input_symbol.<br>
+3.&nbsp;Check&nbsp;if&nbsp;the&nbsp;default_transition&nbsp;is&nbsp;defined.<br>
+&nbsp;&nbsp;&nbsp;This&nbsp;catches&nbsp;any&nbsp;input_symbol&nbsp;and&nbsp;any&nbsp;state.<br>
+&nbsp;&nbsp;&nbsp;This&nbsp;is&nbsp;a&nbsp;handler&nbsp;for&nbsp;errors,&nbsp;undefined&nbsp;states,&nbsp;or&nbsp;defaults.<br>
+4.&nbsp;No&nbsp;transition&nbsp;was&nbsp;defined.&nbsp;If&nbsp;we&nbsp;get&nbsp;here&nbsp;then&nbsp;raise&nbsp;an&nbsp;exception.</tt></dd></dl>
+
+<dl><dt><a name="FSM-process"><strong>process</strong></a>(self, input_symbol)</dt><dd><tt>This&nbsp;is&nbsp;the&nbsp;main&nbsp;method&nbsp;that&nbsp;you&nbsp;call&nbsp;to&nbsp;process&nbsp;input.<br>
+This&nbsp;may&nbsp;cause&nbsp;the&nbsp;<a href="#FSM">FSM</a>&nbsp;to&nbsp;change&nbsp;state&nbsp;and&nbsp;call&nbsp;an&nbsp;action.<br>
+This&nbsp;method&nbsp;calls&nbsp;<a href="#FSM-get_transition">get_transition</a>()&nbsp;to&nbsp;find&nbsp;the&nbsp;action&nbsp;and&nbsp;next_state<br>
+associated&nbsp;with&nbsp;the&nbsp;input_symbol&nbsp;and&nbsp;current_state.<br>
+If&nbsp;the&nbsp;action&nbsp;is&nbsp;None&nbsp;then&nbsp;the&nbsp;action&nbsp;is&nbsp;not&nbsp;called&nbsp;and<br>
+only&nbsp;the&nbsp;current&nbsp;state&nbsp;is&nbsp;changed.<br>
+This&nbsp;method&nbsp;processes&nbsp;one&nbsp;input&nbsp;symbol.&nbsp;You&nbsp;can&nbsp;process&nbsp;a&nbsp;list&nbsp;of<br>
+symbols&nbsp;(or&nbsp;a&nbsp;string)&nbsp;by&nbsp;calling&nbsp;<a href="#FSM-process_list">process_list</a>().</tt></dd></dl>
+
+<dl><dt><a name="FSM-process_list"><strong>process_list</strong></a>(self, s)</dt><dd><tt>This&nbsp;takes&nbsp;a&nbsp;list&nbsp;and&nbsp;sends&nbsp;each&nbsp;element&nbsp;to&nbsp;<a href="#FSM-process">process</a>().<br>
+The&nbsp;list&nbsp;may&nbsp;be&nbsp;a&nbsp;string.</tt></dd></dl>
+
+<dl><dt><a name="FSM-reset"><strong>reset</strong></a>(self)</dt><dd><tt>This&nbsp;sets&nbsp;the&nbsp;current_state&nbsp;to&nbsp;the&nbsp;initial_state&nbsp;and<br>
+sets&nbsp;input_symbol&nbsp;to&nbsp;None.<br>
+The&nbsp;initial&nbsp;state&nbsp;was&nbsp;set&nbsp;by&nbsp;the&nbsp;constructor&nbsp;<a href="#FSM-__init__">__init__</a>().</tt></dd></dl>
+
+<dl><dt><a name="FSM-set_default_transition"><strong>set_default_transition</strong></a>(self, action, next_state)</dt><dd><tt>This&nbsp;sets&nbsp;the&nbsp;default&nbsp;transition.&nbsp;<br>
+This&nbsp;defines&nbsp;an&nbsp;action&nbsp;and&nbsp;next_state&nbsp;if&nbsp;the&nbsp;<a href="#FSM">FSM</a>&nbsp;cannot&nbsp;find&nbsp;the<br>
+input&nbsp;symbol&nbsp;and&nbsp;the&nbsp;current&nbsp;state&nbsp;in&nbsp;the&nbsp;transition&nbsp;list&nbsp;and&nbsp;<br>
+if&nbsp;the&nbsp;<a href="#FSM">FSM</a>&nbsp;cannot&nbsp;find&nbsp;the&nbsp;current_state&nbsp;in&nbsp;the&nbsp;transition_any&nbsp;list.<br>
+This&nbsp;is&nbsp;useful&nbsp;for&nbsp;catching&nbsp;errors&nbsp;and&nbsp;undefined&nbsp;states.&nbsp;<br>
+&nbsp;<br>
+The&nbsp;default&nbsp;transition&nbsp;can&nbsp;be&nbsp;removed&nbsp;by&nbsp;setting&nbsp;the&nbsp;attribute<br>
+default_transition&nbsp;to&nbsp;None.</tt></dd></dl>
+
+</td></tr></table></td></tr></table><p>
+<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
+<tr bgcolor="#eeaa77">
+<td colspan=3 valign=bottom>&nbsp;<br>
+<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
+    
+<tr><td bgcolor="#eeaa77"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
+<td width="100%"><dl><dt><a name="-BeginBuildNumber"><strong>BeginBuildNumber</strong></a>(fsm)</dt><dd><tt>#&nbsp;These&nbsp;define&nbsp;the&nbsp;actions.&nbsp;<br>
+#&nbsp;Note&nbsp;that&nbsp;"something"&nbsp;is&nbsp;a&nbsp;list&nbsp;being&nbsp;used&nbsp;as&nbsp;a&nbsp;stack.</tt></dd></dl>
+ <dl><dt><a name="-BuildNumber"><strong>BuildNumber</strong></a>(fsm)</dt></dl>
+ <dl><dt><a name="-DoEqual"><strong>DoEqual</strong></a>(fsm)</dt></dl>
+ <dl><dt><a name="-DoOperator"><strong>DoOperator</strong></a>(fsm)</dt></dl>
+ <dl><dt><a name="-EndBuildNumber"><strong>EndBuildNumber</strong></a>(fsm)</dt></dl>
+ <dl><dt><a name="-Error"><strong>Error</strong></a>(fsm)</dt></dl>
+ <dl><dt><a name="-example"><strong>example</strong></a>()</dt><dd><tt>#&nbsp;This&nbsp;is&nbsp;where&nbsp;the&nbsp;example&nbsp;starts&nbsp;and&nbsp;the&nbsp;<a href="#FSM">FSM</a>&nbsp;state&nbsp;transitions&nbsp;are&nbsp;defined.<br>
+#&nbsp;Note&nbsp;that&nbsp;states&nbsp;(such&nbsp;as&nbsp;'INIT')&nbsp;are&nbsp;strings.&nbsp;This&nbsp;is&nbsp;not&nbsp;necessary,&nbsp;but<br>
+#&nbsp;it&nbsp;makes&nbsp;the&nbsp;example&nbsp;easier&nbsp;to&nbsp;read.</tt></dd></dl>
+</td></tr></table>
+</body></html>

Added: packages/pexpect/branches/upstream/current/doc/clean.css
URL: http://svn.debian.org/wsvn/python-modules/packages/pexpect/branches/upstream/current/doc/clean.css?rev=929&op=file
==============================================================================
--- packages/pexpect/branches/upstream/current/doc/clean.css (added)
+++ packages/pexpect/branches/upstream/current/doc/clean.css Mon Jun 19 10:53:24 2006
@@ -1,0 +1,103 @@
+
+body {
+	margin:0px;
+	padding:0px;
+	font-family:verdana, arial, helvetica, sans-serif; 
+	color:#333;
+	background-color:white;
+	}
+pre {
+  background: #eeeeee;
+  border: 1px solid #888888;
+  color: black;
+  padding: 1em;
+  white-space: pre;
+}
+h1 {
+	margin:5px 0px 5px 0px;
+	padding:0px;
+	font-size:20px;
+	line-height:28px;
+	font-weight:900;
+	color:#44f;
+	}
+h2 {
+	margin:5px 0px 5px 0px;
+	padding:0px;
+	font-size:17px;
+	line-height:28px;
+	font-weight:900;
+	color:#226;
+	}
+h3 {
+	margin:5px 0px 5px 0px;
+	padding:0px;
+	font-size:15px;
+	line-height:28px;
+	font-weight:900;
+	}
+p
+{
+	margin:0px 0px 16px 0px;
+	font:11px/20px verdana, arial, helvetica, sans-serif;
+	padding:0px;
+}
+table 
+{
+    font-size: 10pt; 
+	color: #000000;
+}
+td{border:1px solid #999;}
+
+table.pymenu {color: #000000; background-color: #99ccff}
+th.pymenu {color: #ffffff; background-color: #003366}
+
+.code 
+{
+	font-family: "Lucida Console", monospace; font-weight: bold;
+	color: #007700; background-color: #eeeeee
+}
+
+#Content>p {margin:0px;}
+#Content>p+p {text-indent:30px;}
+
+a {
+	text-decoration:none;
+	font-weight:600;
+	font-family:verdana, arial, helvetica, sans-serif;
+	color: #900;
+}
+//a:link {color:#09c;}
+//a x:visited {color:#07a;}
+a:hover {background-color:#ee0;}
+
+#Header {
+	margin:10px 0px 10px 0px;
+	padding:10px 0px 10px 20px;
+	/* For IE5/Win's benefit height = [correct height] + [top padding] + [top and bottom border widths] */
+	height:33px; /* 14px + 17px + 2px = 33px */
+	border-style:solid;
+	border-color:black;
+	border-width:1px 0px; /* top and bottom borders: 1px; left and right borders: 0px */
+	line-height:33px;
+	background-color:#eee;
+	height:66px; /* the correct height */
+	}
+
+#Content {
+	margin:0px 210px 50px 10px;
+	padding:10px;
+	}
+
+#Menu {
+	position:absolute;
+	top:100px;
+	right:20px;
+	width:172px;
+	padding:10px;
+	background-color:#eee;
+	border:1px solid #999; // dashed #999;
+	line-height:17px;
+	width:150px;
+	font-size:11px;
+	}

Added: packages/pexpect/branches/upstream/current/doc/email.png
URL: http://svn.debian.org/wsvn/python-modules/packages/pexpect/branches/upstream/current/doc/email.png?rev=929&op=file
==============================================================================
Binary file - no diff available.

Propchange: packages/pexpect/branches/upstream/current/doc/email.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: packages/pexpect/branches/upstream/current/doc/examples.html
URL: http://svn.debian.org/wsvn/python-modules/packages/pexpect/branches/upstream/current/doc/examples.html?rev=929&op=file
==============================================================================
--- packages/pexpect/branches/upstream/current/doc/examples.html (added)
+++ packages/pexpect/branches/upstream/current/doc/examples.html Mon Jun 19 10:53:24 2006
@@ -1,0 +1,121 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<title>Pexpect - Examples</title>
+<link rel="stylesheet" href="clean.css" type="text/css">
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<meta name="Author" content="Noah Spurrier">
+<meta name="Keywords"
+ content="pexpect, Noah Spurrier, pypect, Python, Libes, TCL, Expect, pipe, popen, pyExpect, expectpy, expect-like, expect-alike, expect like">
+<meta name="Description"
+ content="Examples for using Pexpect.">
+</head>
+<body bgcolor="#ffffff" text="#000000">
+<div id="Header">
+<h1>Pexpect Examples</h1>
+</div>
+<div id="Content">
+<p><span class="code">script.py</span></p>
+<p><blockquote>
+ This implements a command similar to the classic BSD
+"script" command.
+ This will start a subshell and log all input and
+output to a file.
+ This demonstrates the interact() method of Pexpect.
+</p></blockquote>
+
+<p><span class="code">fix_cvs_files.py</span></p>
+<p><blockquote>
+ This is for cleaning up binary files improperly
+added to CVS.
+ This script scans the given path to find binary
+files;
+ checks with CVS to see if the sticky options are set
+to -kb;
+ finally if sticky options are not -kb then uses 'cvs
+admin' to
+ set the -kb option.
+</p></blockquote>
+
+<p><span class="code">ftp.py</span></p>
+<p><blockquote>
+ This demonstrates an FTP "bookmark".
+ This connects to an ftp site; does a few ftp stuff;
+and then gives the user
+ interactive control over the session. In this case
+the "bookmark" is to a
+ directory on the OpenBSD ftp server. It puts you in
+the i386 packages
+ directory. You can easily modify this for other
+sites.
+ This demonstrates the interact() method of Pexpect.
+</p></blockquote>
+
+<p><span class="code">monitor.py</span></p>
+<p><blockquote>
+ This runs a sequence of commands on a remote host
+using SSH.
+ It runs a simple system checks such as uptime and
+free to monitor
+ the state of the remote host.
+</p></blockquote>
+
+<p><span class="code">passmass.py</span></p>
+<p><blockquote>
+ This will login to each given server and change the
+password of the
+ given user. This demonstrates scripting logins and
+passwords.
+</p></blockquote>
+
+<p><span class="code">python.py</span></p>
+<p><blockquote>
+ This starts the python interpreter and prints the
+greeting message backwards.
+ It then gives the user iteractive control of Python.
+It's pretty useless!
+</p></blockquote>
+
+<p><span class="code">rippy.py</span></p>
+<p><blockquote>
+ This is a wizard for mencoder. It greatly simplifies
+the process of
+ ripping a DVD to Divx (mpeg4) format. It can
+transcode from any
+ video file to another. It has options for resampling
+the audio stream;
+ removing interlace artifacts, fitting to a target
+file size, etc.
+ There are lots of options, but the process is simple
+and easy to use.
+</p></blockquote>
+
+<p><span class="code">sshls.py</span></p>
+<p><blockquote>
+ This lists a directory on a remote machine.
+</p></blockquote>
+<p><span class="code">ssh_tunnel.py</span></p>
+<p><blockquote>
+ This starts an SSH tunnel to a remote machine. It
+monitors the connection
+ and restarts the tunnel if it goes down.
+</p></blockquote>
+<p><span class="code">uptime.py</span></p>
+<p><blockquote>
+ This will run the uptime command and parse the
+output into variables.
+ This demonstrates using a single regular expression
+to match the output
+ of a command and capturing different variable in
+match groups.
+ The grouping regular expression handles a wide variety of different
+uptime formats.
+  </blockquote>
+<p>
+<a href="http://sourceforge.net/projects/pexpect/"
+ title="The Pexpect project page on SourceForge.net"> <img
+ src="http://sourceforge.net/sflogo.php?group_id=59762&amp;type=5"
+ alt="The Pexpect project page on SourceForge.net" border="0"
+ height="31" width="105"> </a> </div>
+</body>
+</html>

Added: packages/pexpect/branches/upstream/current/doc/fdpexpect.html
URL: http://svn.debian.org/wsvn/python-modules/packages/pexpect/branches/upstream/current/doc/fdpexpect.html?rev=929&op=file
==============================================================================
--- packages/pexpect/branches/upstream/current/doc/fdpexpect.html (added)
+++ packages/pexpect/branches/upstream/current/doc/fdpexpect.html Mon Jun 19 10:53:24 2006
@@ -1,0 +1,336 @@
+
+<!doctype html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html><head><title>Python: module fdpexpect</title>
+</head><body bgcolor="#f0f0f8">
+
+<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
+<tr bgcolor="#7799ee">
+<td valign=bottom>&nbsp;<br>
+<font color="#ffffff" face="helvetica, arial">&nbsp;<br><big><big><strong>fdpexpect</strong></big></big> (version 2.1)</font></td
+><td align=right valign=bottom
+><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/noah/documents/export/engineering/source/python/pexpect/trunk/pexpect/fdpexpect.py">/home/noah/documents/export/engineering/source/python/pexpect/trunk/pexpect/fdpexpect.py</a></font></td></tr></table>
+    <p><tt>TODO:&nbsp;This&nbsp;is&nbsp;BETA.&nbsp;When&nbsp;it&nbsp;gets&nbsp;stable&nbsp;I&nbsp;will&nbsp;move&nbsp;it&nbsp;into&nbsp;the&nbsp;pexpect.py&nbsp;file.</tt></p>
+<p>
+<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
+<tr bgcolor="#aa55cc">
+<td colspan=3 valign=bottom>&nbsp;<br>
+<font color="#fffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
+    
+<tr><td bgcolor="#aa55cc"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
+<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="os.html">os</a><br>
+</td><td width="25%" valign=top></td><td width="25%" valign=top></td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
+<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
+<tr bgcolor="#ee77aa">
+<td colspan=3 valign=bottom>&nbsp;<br>
+<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
+    
+<tr><td bgcolor="#ee77aa"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
+<td width="100%"><dl>
+<dt><font face="helvetica, arial"><a href="pexpect.html#spawn">pexpect.spawn</a>(<a href="__builtin__.html#object">__builtin__.object</a>)
+</font></dt><dd>
+<dl>
+<dt><font face="helvetica, arial"><a href="fdpexpect.html#fdspawn">fdspawn</a>
+</font></dt></dl>
+</dd>
+</dl>
+ <p>
+<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
+<tr bgcolor="#ffc8d8">
+<td colspan=3 valign=bottom>&nbsp;<br>
+<font color="#000000" face="helvetica, arial"><a name="fdspawn">class <strong>fdspawn</strong></a>(<a href="pexpect.html#spawn">pexpect.spawn</a>)</font></td></tr>
+    
+<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
+<td colspan=2><tt>This&nbsp;is&nbsp;like&nbsp;pexpect.<a href="pexpect.html#spawn">spawn</a>&nbsp;but&nbsp;allows&nbsp;you&nbsp;to&nbsp;supply&nbsp;your&nbsp;own,<br>
+already&nbsp;open&nbsp;file&nbsp;descriptor.&nbsp;For&nbsp;example,&nbsp;you&nbsp;could&nbsp;use&nbsp;it&nbsp;to<br>
+read&nbsp;through&nbsp;a&nbsp;file&nbsp;looking&nbsp;for&nbsp;patterns,&nbsp;or&nbsp;to&nbsp;control&nbsp;a&nbsp;modem&nbsp;or<br>
+serial&nbsp;device.<br>&nbsp;</tt></td></tr>
+<tr><td>&nbsp;</td>
+<td width="100%"><dl><dt>Method resolution order:</dt>
+<dd><a href="fdpexpect.html#fdspawn">fdspawn</a></dd>
+<dd><a href="pexpect.html#spawn">pexpect.spawn</a></dd>
+<dd><a href="__builtin__.html#object">__builtin__.object</a></dd>
+</dl>
+<hr>
+Methods defined here:<br>
+<dl><dt><a name="fdspawn-__del__"><strong>__del__</strong></a>(self)</dt></dl>
+
+<dl><dt><a name="fdspawn-__init__"><strong>__init__</strong></a>(self, fd, args<font color="#909090">=[]</font>, timeout<font color="#909090">=30</font>, maxread<font color="#909090">=2000</font>, searchwindowsize<font color="#909090">=None</font>, logfile<font color="#909090">=None</font>)</dt><dd><tt>This&nbsp;takes&nbsp;a&nbsp;file&nbsp;descriptor&nbsp;(an&nbsp;int)&nbsp;or&nbsp;an&nbsp;object&nbsp;that&nbsp;support&nbsp;the&nbsp;<a href="#fdspawn-fileno">fileno</a>()&nbsp;method<br>
+(returning&nbsp;an&nbsp;int).&nbsp;All&nbsp;Python&nbsp;file-like&nbsp;objects&nbsp;support&nbsp;<a href="#fdspawn-fileno">fileno</a>().</tt></dd></dl>
+
+<dl><dt><a name="fdspawn-close"><strong>close</strong></a>(self)</dt></dl>
+
+<dl><dt><a name="fdspawn-isalive"><strong>isalive</strong></a>(self)</dt><dd><tt>This&nbsp;checks&nbsp;if&nbsp;the&nbsp;file&nbsp;descriptor&nbsp;is&nbsp;still&nbsp;valid.<br>
+If&nbsp;os.fstat()&nbsp;does&nbsp;not&nbsp;raise&nbsp;an&nbsp;exception&nbsp;then&nbsp;we&nbsp;assume&nbsp;it&nbsp;is&nbsp;alive.</tt></dd></dl>
+
+<dl><dt><a name="fdspawn-kill"><strong>kill</strong></a>(self, sig)</dt></dl>
+
+<dl><dt><a name="fdspawn-terminate"><strong>terminate</strong></a>(self, force<font color="#909090">=False</font>)</dt></dl>
+
+<hr>
+Methods inherited from <a href="pexpect.html#spawn">pexpect.spawn</a>:<br>
+<dl><dt><a name="fdspawn-__iter__"><strong>__iter__</strong></a>(self)</dt><dd><tt>This&nbsp;is&nbsp;to&nbsp;support&nbsp;iterators&nbsp;over&nbsp;a&nbsp;file-like&nbsp;object.</tt></dd></dl>
+
+<dl><dt><a name="fdspawn-__str__"><strong>__str__</strong></a>(self)</dt><dd><tt>This&nbsp;returns&nbsp;the&nbsp;current&nbsp;state&nbsp;of&nbsp;the&nbsp;pexpect&nbsp;object&nbsp;as&nbsp;a&nbsp;string.</tt></dd></dl>
+
+<dl><dt><a name="fdspawn-compile_pattern_list"><strong>compile_pattern_list</strong></a>(self, patterns)</dt><dd><tt>This&nbsp;compiles&nbsp;a&nbsp;pattern-string&nbsp;or&nbsp;a&nbsp;list&nbsp;of&nbsp;pattern-strings.<br>
+Patterns&nbsp;must&nbsp;be&nbsp;a&nbsp;StringType,&nbsp;EOF,&nbsp;TIMEOUT,&nbsp;SRE_Pattern,&nbsp;or&nbsp;<br>
+a&nbsp;list&nbsp;of&nbsp;those.&nbsp;Patterns&nbsp;may&nbsp;also&nbsp;be&nbsp;None&nbsp;which&nbsp;results&nbsp;in<br>
+an&nbsp;empty&nbsp;list.<br>
+&nbsp;<br>
+This&nbsp;is&nbsp;used&nbsp;by&nbsp;<a href="#fdspawn-expect">expect</a>()&nbsp;when&nbsp;calling&nbsp;<a href="#fdspawn-expect_list">expect_list</a>().<br>
+Thus&nbsp;<a href="#fdspawn-expect">expect</a>()&nbsp;is&nbsp;nothing&nbsp;more&nbsp;than::<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cpl&nbsp;=&nbsp;<a href="#fdspawn-compile_pattern_list">compile_pattern_list</a>(pl)<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;<a href="#fdspawn-expect_list">expect_list</a>(clp,&nbsp;timeout)<br>
+&nbsp;<br>
+If&nbsp;you&nbsp;are&nbsp;using&nbsp;<a href="#fdspawn-expect">expect</a>()&nbsp;within&nbsp;a&nbsp;loop&nbsp;it&nbsp;may&nbsp;be&nbsp;more<br>
+efficient&nbsp;to&nbsp;compile&nbsp;the&nbsp;patterns&nbsp;first&nbsp;and&nbsp;then&nbsp;call&nbsp;<a href="#fdspawn-expect_list">expect_list</a>().<br>
+This&nbsp;avoid&nbsp;calls&nbsp;in&nbsp;a&nbsp;loop&nbsp;to&nbsp;<a href="#fdspawn-compile_pattern_list">compile_pattern_list</a>():<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cpl&nbsp;=&nbsp;<a href="#fdspawn-compile_pattern_list">compile_pattern_list</a>(my_pattern)<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;while&nbsp;some_condition:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;...<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;i&nbsp;=&nbsp;<a href="#fdspawn-expect_list">expect_list</a>(clp,&nbsp;timeout)<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;...</tt></dd></dl>
+
+<dl><dt><a name="fdspawn-eof"><strong>eof</strong></a>(self)</dt><dd><tt>This&nbsp;returns&nbsp;True&nbsp;if&nbsp;the&nbsp;EOF&nbsp;exception&nbsp;was&nbsp;ever&nbsp;raised.</tt></dd></dl>
+
+<dl><dt><a name="fdspawn-expect"><strong>expect</strong></a>(self, pattern, timeout<font color="#909090">=-1</font>, searchwindowsize<font color="#909090">=None</font>)</dt><dd><tt>This&nbsp;seeks&nbsp;through&nbsp;the&nbsp;stream&nbsp;until&nbsp;a&nbsp;pattern&nbsp;is&nbsp;matched.<br>
+The&nbsp;pattern&nbsp;is&nbsp;overloaded&nbsp;and&nbsp;may&nbsp;take&nbsp;several&nbsp;types&nbsp;including&nbsp;a&nbsp;list.<br>
+The&nbsp;pattern&nbsp;can&nbsp;be&nbsp;a&nbsp;StringType,&nbsp;EOF,&nbsp;a&nbsp;compiled&nbsp;re,&nbsp;or&nbsp;a&nbsp;list&nbsp;of<br>
+those&nbsp;types.&nbsp;Strings&nbsp;will&nbsp;be&nbsp;compiled&nbsp;to&nbsp;re&nbsp;types.&nbsp;This&nbsp;returns&nbsp;the<br>
+index&nbsp;into&nbsp;the&nbsp;pattern&nbsp;list.&nbsp;If&nbsp;the&nbsp;pattern&nbsp;was&nbsp;not&nbsp;a&nbsp;list&nbsp;this<br>
+returns&nbsp;index&nbsp;0&nbsp;on&nbsp;a&nbsp;successful&nbsp;match.&nbsp;This&nbsp;may&nbsp;raise&nbsp;exceptions&nbsp;for<br>
+EOF&nbsp;or&nbsp;TIMEOUT.&nbsp;To&nbsp;avoid&nbsp;the&nbsp;EOF&nbsp;or&nbsp;TIMEOUT&nbsp;exceptions&nbsp;add<br>
+EOF&nbsp;or&nbsp;TIMEOUT&nbsp;to&nbsp;the&nbsp;pattern&nbsp;list.<br>
+&nbsp;<br>
+After&nbsp;a&nbsp;match&nbsp;is&nbsp;found&nbsp;the&nbsp;instance&nbsp;attributes<br>
+'before',&nbsp;'after'&nbsp;and&nbsp;'match'&nbsp;will&nbsp;be&nbsp;set.<br>
+You&nbsp;can&nbsp;see&nbsp;all&nbsp;the&nbsp;data&nbsp;read&nbsp;before&nbsp;the&nbsp;match&nbsp;in&nbsp;'before'.<br>
+You&nbsp;can&nbsp;see&nbsp;the&nbsp;data&nbsp;that&nbsp;was&nbsp;matched&nbsp;in&nbsp;'after'.<br>
+The&nbsp;re.MatchObject&nbsp;used&nbsp;in&nbsp;the&nbsp;re&nbsp;match&nbsp;will&nbsp;be&nbsp;in&nbsp;'match'.<br>
+If&nbsp;an&nbsp;error&nbsp;occured&nbsp;then&nbsp;'before'&nbsp;will&nbsp;be&nbsp;set&nbsp;to&nbsp;all&nbsp;the<br>
+data&nbsp;read&nbsp;so&nbsp;far&nbsp;and&nbsp;'after'&nbsp;and&nbsp;'match'&nbsp;will&nbsp;be&nbsp;None.<br>
+&nbsp;<br>
+If&nbsp;timeout&nbsp;is&nbsp;-1&nbsp;then&nbsp;timeout&nbsp;will&nbsp;be&nbsp;set&nbsp;to&nbsp;the&nbsp;self.<strong>timeout</strong>&nbsp;value.<br>
+&nbsp;<br>
+Note:&nbsp;A&nbsp;list&nbsp;entry&nbsp;may&nbsp;be&nbsp;EOF&nbsp;or&nbsp;TIMEOUT&nbsp;instead&nbsp;of&nbsp;a&nbsp;string.<br>
+This&nbsp;will&nbsp;catch&nbsp;these&nbsp;exceptions&nbsp;and&nbsp;return&nbsp;the&nbsp;index<br>
+of&nbsp;the&nbsp;list&nbsp;entry&nbsp;instead&nbsp;of&nbsp;raising&nbsp;the&nbsp;exception.<br>
+The&nbsp;attribute&nbsp;'after'&nbsp;will&nbsp;be&nbsp;set&nbsp;to&nbsp;the&nbsp;exception&nbsp;type.<br>
+The&nbsp;attribute&nbsp;'match'&nbsp;will&nbsp;be&nbsp;None.<br>
+This&nbsp;allows&nbsp;you&nbsp;to&nbsp;write&nbsp;code&nbsp;like&nbsp;this:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;index&nbsp;=&nbsp;p.expect&nbsp;(['good',&nbsp;'bad',&nbsp;pexpect.EOF,&nbsp;pexpect.TIMEOUT])<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;index&nbsp;==&nbsp;0:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;do_something()<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;elif&nbsp;index&nbsp;==&nbsp;1:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;do_something_else()<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;elif&nbsp;index&nbsp;==&nbsp;2:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;do_some_other_thing()<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;elif&nbsp;index&nbsp;==&nbsp;3:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;do_something_completely_different()<br>
+instead&nbsp;of&nbsp;code&nbsp;like&nbsp;this:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;index&nbsp;=&nbsp;p.expect&nbsp;(['good',&nbsp;'bad'])<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;index&nbsp;==&nbsp;0:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;do_something()<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;elif&nbsp;index&nbsp;==&nbsp;1:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;do_something_else()<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;except&nbsp;EOF:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;do_some_other_thing()<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;except&nbsp;TIMEOUT:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;do_something_completely_different()<br>
+These&nbsp;two&nbsp;forms&nbsp;are&nbsp;equivalent.&nbsp;It&nbsp;all&nbsp;depends&nbsp;on&nbsp;what&nbsp;you&nbsp;want.<br>
+You&nbsp;can&nbsp;also&nbsp;just&nbsp;expect&nbsp;the&nbsp;EOF&nbsp;if&nbsp;you&nbsp;are&nbsp;waiting&nbsp;for&nbsp;all&nbsp;output<br>
+of&nbsp;a&nbsp;child&nbsp;to&nbsp;finish.&nbsp;For&nbsp;example:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p&nbsp;=&nbsp;pexpect.<a href="pexpect.html#spawn">spawn</a>('/bin/ls')<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p.expect&nbsp;(pexpect.EOF)<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print&nbsp;p.before<br>
+&nbsp;<br>
+If&nbsp;you&nbsp;are&nbsp;trying&nbsp;to&nbsp;optimize&nbsp;for&nbsp;speed&nbsp;then&nbsp;see&nbsp;<a href="#fdspawn-expect_list">expect_list</a>().</tt></dd></dl>
+
+<dl><dt><a name="fdspawn-expect_exact"><strong>expect_exact</strong></a>(self, pattern_list, timeout<font color="#909090">=-1</font>)</dt><dd><tt>This&nbsp;method&nbsp;is&nbsp;no&nbsp;longer&nbsp;supported&nbsp;or&nbsp;allowed.<br>
+It&nbsp;was&nbsp;too&nbsp;hard&nbsp;to&nbsp;maintain&nbsp;and&nbsp;keep&nbsp;it&nbsp;up&nbsp;to&nbsp;date&nbsp;with&nbsp;expect_list.<br>
+Few&nbsp;people&nbsp;used&nbsp;this&nbsp;method.&nbsp;Most&nbsp;people&nbsp;favored&nbsp;reliability&nbsp;over&nbsp;speed.<br>
+The&nbsp;implementation&nbsp;is&nbsp;left&nbsp;in&nbsp;comments&nbsp;in&nbsp;case&nbsp;anyone&nbsp;needs&nbsp;to&nbsp;hack&nbsp;this<br>
+feature&nbsp;back&nbsp;into&nbsp;their&nbsp;copy.<br>
+If&nbsp;someone&nbsp;wants&nbsp;to&nbsp;diff&nbsp;this&nbsp;with&nbsp;expect_list&nbsp;and&nbsp;make&nbsp;them&nbsp;work<br>
+nearly&nbsp;the&nbsp;same&nbsp;then&nbsp;I&nbsp;will&nbsp;consider&nbsp;adding&nbsp;this&nbsp;make&nbsp;in.</tt></dd></dl>
+
+<dl><dt><a name="fdspawn-expect_list"><strong>expect_list</strong></a>(self, pattern_list, timeout<font color="#909090">=-1</font>, searchwindowsize<font color="#909090">=-1</font>)</dt><dd><tt>This&nbsp;takes&nbsp;a&nbsp;list&nbsp;of&nbsp;compiled&nbsp;regular&nbsp;expressions&nbsp;and&nbsp;returns&nbsp;<br>
+the&nbsp;index&nbsp;into&nbsp;the&nbsp;pattern_list&nbsp;that&nbsp;matched&nbsp;the&nbsp;child&nbsp;output.<br>
+The&nbsp;list&nbsp;may&nbsp;also&nbsp;contain&nbsp;EOF&nbsp;or&nbsp;TIMEOUT&nbsp;(which&nbsp;are&nbsp;not<br>
+compiled&nbsp;regular&nbsp;expressions).&nbsp;This&nbsp;method&nbsp;is&nbsp;similar&nbsp;to<br>
+the&nbsp;<a href="#fdspawn-expect">expect</a>()&nbsp;method&nbsp;except&nbsp;that&nbsp;<a href="#fdspawn-expect_list">expect_list</a>()&nbsp;does&nbsp;not<br>
+recompile&nbsp;the&nbsp;pattern&nbsp;list&nbsp;on&nbsp;every&nbsp;call.<br>
+This&nbsp;may&nbsp;help&nbsp;if&nbsp;you&nbsp;are&nbsp;trying&nbsp;to&nbsp;optimize&nbsp;for&nbsp;speed,&nbsp;otherwise<br>
+just&nbsp;use&nbsp;the&nbsp;<a href="#fdspawn-expect">expect</a>()&nbsp;method.&nbsp;&nbsp;This&nbsp;is&nbsp;called&nbsp;by&nbsp;<a href="#fdspawn-expect">expect</a>().<br>
+If&nbsp;timeout==-1&nbsp;then&nbsp;the&nbsp;self.<strong>timeout</strong>&nbsp;value&nbsp;is&nbsp;used.<br>
+If&nbsp;searchwindowsize==-1&nbsp;then&nbsp;the&nbsp;self.<strong>searchwindowsize</strong>&nbsp;value&nbsp;is&nbsp;used.</tt></dd></dl>
+
+<dl><dt><a name="fdspawn-fileno"><strong>fileno</strong></a>(self)</dt><dd><tt>This&nbsp;returns&nbsp;the&nbsp;file&nbsp;descriptor&nbsp;of&nbsp;the&nbsp;pty&nbsp;for&nbsp;the&nbsp;child.</tt></dd></dl>
+
+<dl><dt><a name="fdspawn-flush"><strong>flush</strong></a>(self)</dt><dd><tt>This&nbsp;does&nbsp;nothing.&nbsp;It&nbsp;is&nbsp;here&nbsp;to&nbsp;support&nbsp;the&nbsp;interface&nbsp;for&nbsp;a&nbsp;File-like&nbsp;object.</tt></dd></dl>
+
+<dl><dt><a name="fdspawn-getwinsize"><strong>getwinsize</strong></a>(self)</dt><dd><tt>This&nbsp;returns&nbsp;the&nbsp;terminal&nbsp;window&nbsp;size&nbsp;of&nbsp;the&nbsp;child&nbsp;tty.<br>
+The&nbsp;return&nbsp;value&nbsp;is&nbsp;a&nbsp;tuple&nbsp;of&nbsp;(rows,&nbsp;cols).</tt></dd></dl>
+
+<dl><dt><a name="fdspawn-interact"><strong>interact</strong></a>(self, escape_character<font color="#909090">='<font color="#c040c0">\x1d</font>'</font>, input_filter<font color="#909090">=None</font>, output_filter<font color="#909090">=None</font>)</dt><dd><tt>This&nbsp;gives&nbsp;control&nbsp;of&nbsp;the&nbsp;child&nbsp;process&nbsp;to&nbsp;the&nbsp;interactive&nbsp;user<br>
+(the&nbsp;human&nbsp;at&nbsp;the&nbsp;keyboard).<br>
+Keystrokes&nbsp;are&nbsp;sent&nbsp;to&nbsp;the&nbsp;child&nbsp;process,&nbsp;and&nbsp;the&nbsp;stdout&nbsp;and&nbsp;stderr<br>
+output&nbsp;of&nbsp;the&nbsp;child&nbsp;process&nbsp;is&nbsp;printed.<br>
+This&nbsp;simply&nbsp;echos&nbsp;the&nbsp;child&nbsp;stdout&nbsp;and&nbsp;child&nbsp;stderr&nbsp;to&nbsp;the&nbsp;real<br>
+stdout&nbsp;and&nbsp;it&nbsp;echos&nbsp;the&nbsp;real&nbsp;stdin&nbsp;to&nbsp;the&nbsp;child&nbsp;stdin.<br>
+When&nbsp;the&nbsp;user&nbsp;types&nbsp;the&nbsp;escape_character&nbsp;this&nbsp;method&nbsp;will&nbsp;stop.<br>
+The&nbsp;default&nbsp;for&nbsp;escape_character&nbsp;is&nbsp;^].&nbsp;This&nbsp;should&nbsp;not&nbsp;be&nbsp;confused<br>
+with&nbsp;ASCII&nbsp;27&nbsp;--&nbsp;the&nbsp;ESC&nbsp;character.&nbsp;ASCII&nbsp;29&nbsp;was&nbsp;chosen<br>
+for&nbsp;historical&nbsp;merit&nbsp;because&nbsp;this&nbsp;is&nbsp;the&nbsp;character&nbsp;used<br>
+by&nbsp;'telnet'&nbsp;as&nbsp;the&nbsp;escape&nbsp;character.&nbsp;The&nbsp;escape_character&nbsp;will<br>
+not&nbsp;be&nbsp;sent&nbsp;to&nbsp;the&nbsp;child&nbsp;process.<br>
+&nbsp;<br>
+You&nbsp;may&nbsp;pass&nbsp;in&nbsp;optional&nbsp;input&nbsp;and&nbsp;output&nbsp;filter&nbsp;functions.<br>
+These&nbsp;functions&nbsp;should&nbsp;take&nbsp;a&nbsp;string&nbsp;and&nbsp;return&nbsp;a&nbsp;string.<br>
+The&nbsp;output_filter&nbsp;will&nbsp;be&nbsp;passed&nbsp;all&nbsp;the&nbsp;output&nbsp;from&nbsp;the&nbsp;child&nbsp;process.<br>
+The&nbsp;input_filter&nbsp;will&nbsp;be&nbsp;passed&nbsp;all&nbsp;the&nbsp;keyboard&nbsp;input&nbsp;from&nbsp;the&nbsp;user.<br>
+The&nbsp;input_filter&nbsp;is&nbsp;run&nbsp;BEFORE&nbsp;the&nbsp;check&nbsp;for&nbsp;the&nbsp;escape_character.<br>
+&nbsp;<br>
+Note&nbsp;that&nbsp;if&nbsp;you&nbsp;change&nbsp;the&nbsp;window&nbsp;size&nbsp;of&nbsp;the&nbsp;parent<br>
+the&nbsp;SIGWINCH&nbsp;signal&nbsp;will&nbsp;not&nbsp;be&nbsp;passed&nbsp;through&nbsp;to&nbsp;the&nbsp;child.<br>
+If&nbsp;you&nbsp;want&nbsp;the&nbsp;child&nbsp;window&nbsp;size&nbsp;to&nbsp;change&nbsp;when&nbsp;the&nbsp;parent's<br>
+window&nbsp;size&nbsp;changes&nbsp;then&nbsp;do&nbsp;something&nbsp;like&nbsp;the&nbsp;following&nbsp;example:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;import&nbsp;pexpect,&nbsp;struct,&nbsp;fcntl,&nbsp;termios,&nbsp;signal,&nbsp;sys<br>
+&nbsp;&nbsp;&nbsp;&nbsp;def&nbsp;sigwinch_passthrough&nbsp;(sig,&nbsp;data):<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;s&nbsp;=&nbsp;struct.pack("HHHH",&nbsp;0,&nbsp;0,&nbsp;0,&nbsp;0)<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a&nbsp;=&nbsp;struct.unpack('hhhh',&nbsp;fcntl.ioctl(sys.stdout.<a href="#fdspawn-fileno">fileno</a>(),&nbsp;termios.TIOCGWINSZ&nbsp;,&nbsp;s))<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;global&nbsp;p<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p.<a href="#fdspawn-setwinsize">setwinsize</a>(a[0],a[1])<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p&nbsp;=&nbsp;pexpect.<a href="pexpect.html#spawn">spawn</a>('/bin/bash')&nbsp;#&nbsp;Note&nbsp;this&nbsp;is&nbsp;global&nbsp;and&nbsp;used&nbsp;in&nbsp;sigwinch_passthrough.<br>
+&nbsp;&nbsp;&nbsp;&nbsp;signal.signal(signal.SIGWINCH,&nbsp;sigwinch_passthrough)<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p.<a href="#fdspawn-interact">interact</a>()</tt></dd></dl>
+
+<dl><dt><a name="fdspawn-isatty"><strong>isatty</strong></a>(self)</dt><dd><tt>This&nbsp;returns&nbsp;True&nbsp;if&nbsp;the&nbsp;file&nbsp;descriptor&nbsp;is&nbsp;open&nbsp;and&nbsp;connected&nbsp;to&nbsp;a&nbsp;tty(-like)&nbsp;device,&nbsp;else&nbsp;False.</tt></dd></dl>
+
+<dl><dt><a name="fdspawn-next"><strong>next</strong></a>(self)</dt><dd><tt>This&nbsp;is&nbsp;to&nbsp;support&nbsp;iterators&nbsp;over&nbsp;a&nbsp;file-like&nbsp;object.</tt></dd></dl>
+
+<dl><dt><a name="fdspawn-read"><strong>read</strong></a>(self, size<font color="#909090">=-1</font>)</dt><dd><tt>This&nbsp;reads&nbsp;at&nbsp;most&nbsp;"size"&nbsp;bytes&nbsp;from&nbsp;the&nbsp;file&nbsp;<br>
+(less&nbsp;if&nbsp;the&nbsp;read&nbsp;hits&nbsp;EOF&nbsp;before&nbsp;obtaining&nbsp;size&nbsp;bytes).&nbsp;<br>
+If&nbsp;the&nbsp;size&nbsp;argument&nbsp;is&nbsp;negative&nbsp;or&nbsp;omitted,&nbsp;<br>
+read&nbsp;all&nbsp;data&nbsp;until&nbsp;EOF&nbsp;is&nbsp;reached.&nbsp;<br>
+The&nbsp;bytes&nbsp;are&nbsp;returned&nbsp;as&nbsp;a&nbsp;string&nbsp;object.&nbsp;<br>
+An&nbsp;empty&nbsp;string&nbsp;is&nbsp;returned&nbsp;when&nbsp;EOF&nbsp;is&nbsp;encountered&nbsp;immediately.</tt></dd></dl>
+
+<dl><dt><a name="fdspawn-read_nonblocking"><strong>read_nonblocking</strong></a>(self, size<font color="#909090">=1</font>, timeout<font color="#909090">=-1</font>)</dt><dd><tt>This&nbsp;reads&nbsp;at&nbsp;most&nbsp;size&nbsp;characters&nbsp;from&nbsp;the&nbsp;child&nbsp;application.<br>
+It&nbsp;includes&nbsp;a&nbsp;timeout.&nbsp;If&nbsp;the&nbsp;read&nbsp;does&nbsp;not&nbsp;complete&nbsp;within&nbsp;the<br>
+timeout&nbsp;period&nbsp;then&nbsp;a&nbsp;TIMEOUT&nbsp;exception&nbsp;is&nbsp;raised.<br>
+If&nbsp;the&nbsp;end&nbsp;of&nbsp;file&nbsp;is&nbsp;read&nbsp;then&nbsp;an&nbsp;EOF&nbsp;exception&nbsp;will&nbsp;be&nbsp;raised.<br>
+If&nbsp;a&nbsp;log&nbsp;file&nbsp;was&nbsp;set&nbsp;using&nbsp;<a href="#fdspawn-setlog">setlog</a>()&nbsp;then&nbsp;all&nbsp;data&nbsp;will<br>
+also&nbsp;be&nbsp;written&nbsp;to&nbsp;the&nbsp;log&nbsp;file.<br>
+&nbsp;<br>
+If&nbsp;timeout==None&nbsp;then&nbsp;the&nbsp;read&nbsp;may&nbsp;block&nbsp;indefinitely.<br>
+If&nbsp;timeout==-1&nbsp;then&nbsp;the&nbsp;self.<strong>timeout</strong>&nbsp;value&nbsp;is&nbsp;used.<br>
+If&nbsp;timeout==0&nbsp;then&nbsp;the&nbsp;child&nbsp;is&nbsp;polled&nbsp;and&nbsp;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;there&nbsp;was&nbsp;no&nbsp;data&nbsp;immediately&nbsp;ready&nbsp;then&nbsp;this&nbsp;will&nbsp;raise&nbsp;a&nbsp;TIMEOUT&nbsp;exception.<br>
+&nbsp;<br>
+The&nbsp;"timeout"&nbsp;refers&nbsp;only&nbsp;to&nbsp;the&nbsp;amount&nbsp;of&nbsp;time&nbsp;to&nbsp;read&nbsp;at&nbsp;least&nbsp;one&nbsp;character.<br>
+This&nbsp;is&nbsp;not&nbsp;effected&nbsp;by&nbsp;the&nbsp;'size'&nbsp;parameter,&nbsp;so&nbsp;if&nbsp;you&nbsp;call<br>
+<a href="#fdspawn-read_nonblocking">read_nonblocking</a>(size=100,&nbsp;timeout=30)&nbsp;and&nbsp;only&nbsp;one&nbsp;character&nbsp;is<br>
+available&nbsp;right&nbsp;away&nbsp;then&nbsp;one&nbsp;character&nbsp;will&nbsp;be&nbsp;returned&nbsp;immediately.&nbsp;<br>
+It&nbsp;will&nbsp;not&nbsp;wait&nbsp;for&nbsp;30&nbsp;seconds&nbsp;for&nbsp;another&nbsp;99&nbsp;characters&nbsp;to&nbsp;come&nbsp;in.<br>
+&nbsp;<br>
+This&nbsp;is&nbsp;a&nbsp;wrapper&nbsp;around&nbsp;os.<a href="#fdspawn-read">read</a>().<br>
+It&nbsp;uses&nbsp;select.select()&nbsp;to&nbsp;implement&nbsp;a&nbsp;timeout.</tt></dd></dl>
+
+<dl><dt><a name="fdspawn-readline"><strong>readline</strong></a>(self, size<font color="#909090">=-1</font>)</dt><dd><tt>This&nbsp;reads&nbsp;and&nbsp;returns&nbsp;one&nbsp;entire&nbsp;line.&nbsp;A&nbsp;trailing&nbsp;newline&nbsp;is&nbsp;kept&nbsp;in<br>
+the&nbsp;string,&nbsp;but&nbsp;may&nbsp;be&nbsp;absent&nbsp;when&nbsp;a&nbsp;file&nbsp;ends&nbsp;with&nbsp;an&nbsp;incomplete&nbsp;line.&nbsp;<br>
+Note:&nbsp;This&nbsp;<a href="#fdspawn-readline">readline</a>()&nbsp;looks&nbsp;for&nbsp;a&nbsp;\r\n&nbsp;pair&nbsp;even&nbsp;on&nbsp;UNIX&nbsp;because<br>
+this&nbsp;is&nbsp;what&nbsp;the&nbsp;pseudo&nbsp;tty&nbsp;device&nbsp;returns.&nbsp;So&nbsp;contrary&nbsp;to&nbsp;what&nbsp;you<br>
+may&nbsp;expect&nbsp;you&nbsp;will&nbsp;receive&nbsp;the&nbsp;newline&nbsp;as&nbsp;\r\n.<br>
+An&nbsp;empty&nbsp;string&nbsp;is&nbsp;returned&nbsp;when&nbsp;EOF&nbsp;is&nbsp;hit&nbsp;immediately.<br>
+Currently,&nbsp;the&nbsp;size&nbsp;agument&nbsp;is&nbsp;mostly&nbsp;ignored,&nbsp;so&nbsp;this&nbsp;behavior&nbsp;is&nbsp;not<br>
+standard&nbsp;for&nbsp;a&nbsp;file-like&nbsp;object.&nbsp;If&nbsp;size&nbsp;is&nbsp;0&nbsp;then&nbsp;an&nbsp;empty&nbsp;string<br>
+is&nbsp;returned.</tt></dd></dl>
+
+<dl><dt><a name="fdspawn-readlines"><strong>readlines</strong></a>(self, sizehint<font color="#909090">=-1</font>)</dt><dd><tt>This&nbsp;reads&nbsp;until&nbsp;EOF&nbsp;using&nbsp;<a href="#fdspawn-readline">readline</a>()&nbsp;and&nbsp;returns&nbsp;a&nbsp;list&nbsp;containing&nbsp;<br>
+the&nbsp;lines&nbsp;thus&nbsp;read.&nbsp;The&nbsp;optional&nbsp;"sizehint"&nbsp;argument&nbsp;is&nbsp;ignored.</tt></dd></dl>
+
+<dl><dt><a name="fdspawn-send"><strong>send</strong></a>(self, str)</dt><dd><tt>This&nbsp;sends&nbsp;a&nbsp;string&nbsp;to&nbsp;the&nbsp;child&nbsp;process.<br>
+This&nbsp;returns&nbsp;the&nbsp;number&nbsp;of&nbsp;bytes&nbsp;written.<br>
+If&nbsp;a&nbsp;log&nbsp;file&nbsp;was&nbsp;set&nbsp;then&nbsp;the&nbsp;data&nbsp;is&nbsp;also&nbsp;written&nbsp;to&nbsp;the&nbsp;log.</tt></dd></dl>
+
+<dl><dt><a name="fdspawn-sendeof"><strong>sendeof</strong></a>(self)</dt><dd><tt>This&nbsp;sends&nbsp;an&nbsp;EOF&nbsp;to&nbsp;the&nbsp;child.<br>
+This&nbsp;sends&nbsp;a&nbsp;character&nbsp;which&nbsp;causes&nbsp;the&nbsp;pending&nbsp;parent&nbsp;output<br>
+buffer&nbsp;to&nbsp;be&nbsp;sent&nbsp;to&nbsp;the&nbsp;waiting&nbsp;child&nbsp;program&nbsp;without<br>
+waiting&nbsp;for&nbsp;end-of-line.&nbsp;If&nbsp;it&nbsp;is&nbsp;the&nbsp;first&nbsp;character&nbsp;of&nbsp;the<br>
+line,&nbsp;the&nbsp;<a href="#fdspawn-read">read</a>()&nbsp;in&nbsp;the&nbsp;user&nbsp;program&nbsp;returns&nbsp;0,&nbsp;which<br>
+signifies&nbsp;end-of-file.&nbsp;This&nbsp;means&nbsp;to&nbsp;work&nbsp;as&nbsp;expected&nbsp;<br>
+a&nbsp;<a href="#fdspawn-sendeof">sendeof</a>()&nbsp;has&nbsp;to&nbsp;be&nbsp;called&nbsp;at&nbsp;the&nbsp;begining&nbsp;of&nbsp;a&nbsp;line.&nbsp;<br>
+This&nbsp;method&nbsp;does&nbsp;not&nbsp;send&nbsp;a&nbsp;newline.&nbsp;It&nbsp;is&nbsp;the&nbsp;responsibility<br>
+of&nbsp;the&nbsp;caller&nbsp;to&nbsp;ensure&nbsp;the&nbsp;eof&nbsp;is&nbsp;sent&nbsp;at&nbsp;the&nbsp;beginning&nbsp;of&nbsp;a&nbsp;line.</tt></dd></dl>
+
+<dl><dt><a name="fdspawn-sendline"><strong>sendline</strong></a>(self, str<font color="#909090">=''</font>)</dt><dd><tt>This&nbsp;is&nbsp;like&nbsp;<a href="#fdspawn-send">send</a>(),&nbsp;but&nbsp;it&nbsp;adds&nbsp;a&nbsp;line&nbsp;feed&nbsp;(os.linesep).<br>
+This&nbsp;returns&nbsp;the&nbsp;number&nbsp;of&nbsp;bytes&nbsp;written.</tt></dd></dl>
+
+<dl><dt><a name="fdspawn-setecho"><strong>setecho</strong></a>(self, state)</dt><dd><tt>This&nbsp;sets&nbsp;the&nbsp;terminal&nbsp;echo&nbsp;mode&nbsp;on&nbsp;or&nbsp;off.<br>
+Note&nbsp;that&nbsp;anything&nbsp;the&nbsp;child&nbsp;sent&nbsp;before&nbsp;the&nbsp;echo&nbsp;will&nbsp;be&nbsp;lost,&nbsp;so<br>
+you&nbsp;should&nbsp;be&nbsp;sure&nbsp;that&nbsp;your&nbsp;input&nbsp;buffer&nbsp;is&nbsp;empty&nbsp;before&nbsp;you&nbsp;setecho.<br>
+For&nbsp;example,&nbsp;the&nbsp;following&nbsp;will&nbsp;work&nbsp;as&nbsp;expected.<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p&nbsp;=&nbsp;pexpect.<a href="pexpect.html#spawn">spawn</a>('cat')<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p.sendline&nbsp;('1234')&nbsp;#&nbsp;We&nbsp;will&nbsp;see&nbsp;this&nbsp;twice&nbsp;(once&nbsp;from&nbsp;tty&nbsp;echo&nbsp;and&nbsp;again&nbsp;from&nbsp;cat).<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p.expect&nbsp;(['1234'])<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p.expect&nbsp;(['1234'])<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p.<a href="#fdspawn-setecho">setecho</a>(False)&nbsp;#&nbsp;Turn&nbsp;off&nbsp;tty&nbsp;echo<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p.sendline&nbsp;('abcd')&nbsp;#&nbsp;We&nbsp;will&nbsp;set&nbsp;this&nbsp;only&nbsp;once&nbsp;(echoed&nbsp;by&nbsp;cat).<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p.sendline&nbsp;('wxyz')&nbsp;#&nbsp;We&nbsp;will&nbsp;set&nbsp;this&nbsp;only&nbsp;once&nbsp;(echoed&nbsp;by&nbsp;cat)<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p.expect&nbsp;(['abcd'])<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p.expect&nbsp;(['wxyz'])<br>
+The&nbsp;following&nbsp;WILL&nbsp;NOT&nbsp;WORK&nbsp;because&nbsp;the&nbsp;lines&nbsp;sent&nbsp;before&nbsp;the&nbsp;setecho<br>
+will&nbsp;be&nbsp;lost:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p&nbsp;=&nbsp;pexpect.<a href="pexpect.html#spawn">spawn</a>('cat')<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p.sendline&nbsp;('1234')&nbsp;#&nbsp;We&nbsp;will&nbsp;see&nbsp;this&nbsp;twice&nbsp;(once&nbsp;from&nbsp;tty&nbsp;echo&nbsp;and&nbsp;again&nbsp;from&nbsp;cat).<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p.<a href="#fdspawn-setecho">setecho</a>(False)&nbsp;#&nbsp;Turn&nbsp;off&nbsp;tty&nbsp;echo<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p.sendline&nbsp;('abcd')&nbsp;#&nbsp;We&nbsp;will&nbsp;set&nbsp;this&nbsp;only&nbsp;once&nbsp;(echoed&nbsp;by&nbsp;cat).<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p.sendline&nbsp;('wxyz')&nbsp;#&nbsp;We&nbsp;will&nbsp;set&nbsp;this&nbsp;only&nbsp;once&nbsp;(echoed&nbsp;by&nbsp;cat)<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p.expect&nbsp;(['1234'])<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p.expect&nbsp;(['1234'])<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p.expect&nbsp;(['abcd'])<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p.expect&nbsp;(['wxyz'])</tt></dd></dl>
+
+<dl><dt><a name="fdspawn-setlog"><strong>setlog</strong></a>(self, fileobject)</dt><dd><tt>This&nbsp;method&nbsp;is&nbsp;no&nbsp;longer&nbsp;supported&nbsp;or&nbsp;allowed.</tt></dd></dl>
+
+<dl><dt><a name="fdspawn-setmaxread"><strong>setmaxread</strong></a>(self, maxread)</dt><dd><tt>This&nbsp;method&nbsp;is&nbsp;no&nbsp;longer&nbsp;supported&nbsp;or&nbsp;allowed.<br>
+I&nbsp;don't&nbsp;like&nbsp;getters&nbsp;and&nbsp;setters&nbsp;without&nbsp;a&nbsp;good&nbsp;reason.</tt></dd></dl>
+
+<dl><dt><a name="fdspawn-setwinsize"><strong>setwinsize</strong></a>(self, r, c)</dt><dd><tt>This&nbsp;sets&nbsp;the&nbsp;terminal&nbsp;window&nbsp;size&nbsp;of&nbsp;the&nbsp;child&nbsp;tty.<br>
+This&nbsp;will&nbsp;cause&nbsp;a&nbsp;SIGWINCH&nbsp;signal&nbsp;to&nbsp;be&nbsp;sent&nbsp;to&nbsp;the&nbsp;child.<br>
+This&nbsp;does&nbsp;not&nbsp;change&nbsp;the&nbsp;physical&nbsp;window&nbsp;size.<br>
+It&nbsp;changes&nbsp;the&nbsp;size&nbsp;reported&nbsp;to&nbsp;TTY-aware&nbsp;applications&nbsp;like<br>
+vi&nbsp;or&nbsp;curses&nbsp;--&nbsp;applications&nbsp;that&nbsp;respond&nbsp;to&nbsp;the&nbsp;SIGWINCH&nbsp;signal.</tt></dd></dl>
+
+<dl><dt><a name="fdspawn-wait"><strong>wait</strong></a>(self)</dt><dd><tt>This&nbsp;waits&nbsp;until&nbsp;the&nbsp;child&nbsp;exits.&nbsp;This&nbsp;is&nbsp;a&nbsp;blocking&nbsp;call.<br>
+This&nbsp;will&nbsp;not&nbsp;read&nbsp;any&nbsp;data&nbsp;from&nbsp;the&nbsp;child,&nbsp;so&nbsp;this&nbsp;will&nbsp;block&nbsp;forever<br>
+if&nbsp;the&nbsp;child&nbsp;has&nbsp;unread&nbsp;output&nbsp;and&nbsp;has&nbsp;terminated.&nbsp;In&nbsp;other&nbsp;words,&nbsp;the&nbsp;child<br>
+may&nbsp;have&nbsp;printed&nbsp;output&nbsp;then&nbsp;called&nbsp;exit();&nbsp;but,&nbsp;technically,&nbsp;the&nbsp;child&nbsp;is<br>
+still&nbsp;alive&nbsp;until&nbsp;its&nbsp;output&nbsp;is&nbsp;read.</tt></dd></dl>
+
+<dl><dt><a name="fdspawn-write"><strong>write</strong></a>(self, str)</dt><dd><tt>This&nbsp;is&nbsp;similar&nbsp;to&nbsp;<a href="#fdspawn-send">send</a>()&nbsp;except&nbsp;that&nbsp;there&nbsp;is&nbsp;no&nbsp;return&nbsp;value.</tt></dd></dl>
+
+<dl><dt><a name="fdspawn-writelines"><strong>writelines</strong></a>(self, sequence)</dt><dd><tt>This&nbsp;calls&nbsp;<a href="#fdspawn-write">write</a>()&nbsp;for&nbsp;each&nbsp;element&nbsp;in&nbsp;the&nbsp;sequence.<br>
+The&nbsp;sequence&nbsp;can&nbsp;be&nbsp;any&nbsp;iterable&nbsp;object&nbsp;producing&nbsp;strings,&nbsp;<br>
+typically&nbsp;a&nbsp;list&nbsp;of&nbsp;strings.&nbsp;This&nbsp;does&nbsp;not&nbsp;add&nbsp;line&nbsp;separators<br>
+There&nbsp;is&nbsp;no&nbsp;return&nbsp;value.</tt></dd></dl>
+
+<hr>
+Data and other attributes inherited from <a href="pexpect.html#spawn">pexpect.spawn</a>:<br>
+<dl><dt><strong>__dict__</strong> = &lt;dictproxy object&gt;<dd><tt>dictionary&nbsp;for&nbsp;instance&nbsp;variables&nbsp;(if&nbsp;defined)</tt></dl>
+
+<dl><dt><strong>__weakref__</strong> = &lt;attribute '__weakref__' of 'spawn' objects&gt;<dd><tt>list&nbsp;of&nbsp;weak&nbsp;references&nbsp;to&nbsp;the&nbsp;object&nbsp;(if&nbsp;defined)</tt></dl>
+
+</td></tr></table></td></tr></table><p>
+<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
+<tr bgcolor="#55aa55">
+<td colspan=3 valign=bottom>&nbsp;<br>
+<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
+    
+<tr><td bgcolor="#55aa55"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
+<td width="100%"><strong>__all__</strong> = ['fdspawn']<br>
+<strong>__revision__</strong> = '$Revision: 395 $'<br>
+<strong>__version__</strong> = '2.1'</td></tr></table>
+</body></html>

Added: packages/pexpect/branches/upstream/current/doc/index.html
URL: http://svn.debian.org/wsvn/python-modules/packages/pexpect/branches/upstream/current/doc/index.html?rev=929&op=file
==============================================================================
--- packages/pexpect/branches/upstream/current/doc/index.html (added)
+++ packages/pexpect/branches/upstream/current/doc/index.html Mon Jun 19 10:53:24 2006
@@ -1,0 +1,835 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<title>Pexpect - a Pure Python Expect-like module</title>
+<link rel="stylesheet" href="clean.css" type="text/css">
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<meta name="Author" content="Noah Spurrier">
+<meta name="Keywords"
+ content="pexpect, Noah Spurrier, pypect, Python, Libes, TCL, Expect, pipe, popen, pyExpect, expectpy, expect-like, expect-alike, expect like">
+<meta name="Description"
+ content="Pexpect is a pure Python Expect-like module. Pexpect makes Python a better tool for controlling other applications.">
+</head>
+<body bgcolor="#ffffff" text="#000000">
+<div id="Header">
+<h1>Pexpect version 2.1<br>
+a Pure Python Expect-like module
+</h1>
+</div>
+<div id="Content">
+<p>Pexpect makes Python a better tool for controlling other
+applications.</p>
+<p>Pexpect is a pure Python module for spawning child applications;
+controlling them; and responding to expected patterns in their output.
+Pexpect works like Don Libes' Expect. Pexpect allows your script to
+spawn a child application and control it as if a human were typing
+commands.</p>
+<p>Pexpect can be used for automating interactive applications such as
+ssh, ftp, passwd, telnet, etc. It can be used to a automate setup
+scripts for duplicating software package installations on different
+servers. It can be used for automated software testing. Pexpect is in
+the spirit of Don Libes' Expect, but Pexpect is pure Python. Unlike
+other Expect-like modules for Python, Pexpect does not require TCL or
+Expect nor does it require C extensions to be compiled. It should work
+on any platform that supports the standard Python pty module. The
+Pexpect interface was designed to be easy to use.</p>
+<table border="0">
+  <tbody>
+    <tr>
+      <td align="right" valign="top">Send questions to:</td>
+      <td align="left"><a href="http://www.noah.org/email/"><img
+ src="email.png" alt="Click to send email." border="0" height="16"
+ width="100"></a></td>
+    </tr>
+  </tbody>
+</table>
+<hr noshade="noshade" size="1">
+<h1><a name="license"></a>License: MIT style</h1>
+<p>
+Free, open source, and all that good stuff.<br>
+<br>
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:<br>
+<br>
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.<br>
+<br>
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+USE OR OTHER DEALINGS IN THE SOFTWARE.<br>
+<br>
+Pexpect Copyright (c) 2006 Noah Spurrier<br>
+http://pexpect.sourceforge.net/
+</p>
+
+<hr noshade="noshade" size="1">
+<h1><a name="download"></a><a
+ href="http://sourceforge.net/project/showfiles.php?group_id=59762">Download</a></h1>
+<p>Download the <a
+ href="http://sourceforge.net/project/showfiles.php?group_id=59762">
+current version here</a> from the SourceForge site. Grab the current Pexpect tarball.
+</p>
+<h2>Installing Pexpect</h2>
+<p>The Pexpect tarball is a standard Python Distutil distribution.</p>
+<ol>
+  <li>download <span class="code">pexpect-2.1.tar.gz</span></li>
+  <li><span class="code">tar zxf pexpect-2.1.tar.gz</span></li>
+  <li><span class="code">cd pexpect-2.1</span></li>
+  <li><span class="code">python setup.py install</span> <i>do this as root</i></li>
+</ol>
+<h2>Examples</h2>
+<p>
+Under the <span class="code">pexpect-2.1</span> directory you should find
+the <span class="code">examples</span> directory.
+This is the best way to learn to use Pexpect.
+See the descriptions of <a href="examples.html">Pexpect Examples</a>.
+</p>
+<h2><a name="doc"></a>API Documentation</h2>
+<p>
+<blockquote>
+<a href="pexpect.html">pexpect</a> This is the main module that you want.<br>
+<a href="pxssh.html">pxssh</a> Pexpect SSH is an extension of 'pexpect.spawn' that specializes in SSH.<br>
+</blockquote>
+the following are experimental extensions to Pexpect<br>
+<blockquote>
+<a href="fdpexpect.html">fdpexpect</a> fdpexpect extension of 'pexpect.spawn' that uses an open file descriptor.<br>
+<a href="screen.html">SCREEN</a> This represents a virtual 'screen'.<br>
+<a href="ANSI.html">ANSI</a> This parses ANSI/VT-100 terminal escape codes.<br>
+<a href="FSM.html">FSM</a> This is a finite state machine used by ANSI.<br>
+</blockquote>
+</p>
+<hr noshade="noshade" size="1">
+<h1><a name="status"></a>Project Status</h1>
+<p>Automated pyunit tests reach over 80%
+code coverage on pexpect.py. I regularly test on Linux and BSD
+platforms. I try to test on Solaris and Irix. 
+</p>
+<hr noshade="noshade" size="1">
+<h1><a name="requirements"></a>Requirements for use of Pexpect</h1>
+<h2>Python</h2>
+<blockquote>
+  <p>Pexpect was written and tested with Python 2.4. It should work on
+earlier versions that have the <span class="code">pty</span> module. I
+sometimes even manually test it with Python 1.5.2, but I can't easily
+run the PyUnit test framework against Python 1.5.2, so I have less
+confidence in Pexpect on Python 1.5.2.</p>
+</blockquote>
+<h2>pty module</h2>
+<blockquote>
+  <p>Any POSIX system (UNIX) with a working <span class="code">pty</span>
+module should be able to run Pexpect. The <span class="code">pty</span>
+module is part of the Standard Python Library, so if you are running on
+a POSIX system you should have it. The <span class="code">pty</span>
+module does not run the same on all platforms. It should be solid on Linux
+and BSD systems. I have taken effort to try to smooth the wrinkles out of the different platforms. To learn more
+about the wrinkles see <a href="#bugs">Bugs</a> and <a href="#testing">Testing</a>.</p>
+</blockquote>
+<p>Pexpect does not currently work on the standard Windows Python (see
+the pty requirement); however, it seems to work fine using <a
+ href="http://www.cygwin.com/">Cygwin</a>. It is possible to build
+something like a pty for Windows, but it would have to use a different
+technique that I am still investigating. I know it's possible because
+Libes' Expect was ported to Windows. <i>If you have any ideas or
+skills to contribute in this area then I would really appreciate some
+tips on how to approach this problem.</i> </p>
+<hr noshade="noshade" size="1">
+<h1><a name="overview"></a>Overview</h1>
+<p>Pexpect can be used for automating interactive applications such as
+ssh, ftp, mencoder, passwd, etc. The Pexpect interface was designed to be
+easy to use. Here is an example of Pexpect in action:</p>
+<blockquote>
+  <pre class="code"># This connects to the openbsd ftp site and<br># downloads the recursive directory listing.<br>import pexpect<br>child = pexpect.spawn ('ftp ftp.openbsd.org')<br>child.expect ('Name .*: ')<br>child.sendline ('anonymous')<br>child.expect ('Password:')<br>child.sendline ('noah at example.com')<br>child.expect ('ftp&gt; ')<br>child.sendline ('cd pub')<br>child.expect('ftp&gt; ')<br>child.sendline ('get ls-lR.gz')<br>child.expect('ftp&gt; ')<br>child.sendline ('bye')<br></pre>
+</blockquote>
+<p> Obviously you could write an ftp client using Python's own <span
+ class="code">ftplib</span> module, but this is just a demonstration.
+You can use this technique with any application. This is especially
+handy if you are writing automated test tools.</p>
+
+<p>There are two important methods in Pexpect -- <span class="code"><b>expect()</b></span>
+and <span class="code"><b>send()</b></span> (or <span class="code">sendline()</span>
+which is like <span class="code">send()</span> with a linefeed). 
+The <span class="code">expect()</span> method waits for the child application
+to return a given strong. The string you specify is a regular expression, so
+you can match complicated patterns. The <span class="code"><b>send()</b></span> method
+writes a string to the child application. From the child's point of
+view it looks just like someone typed the text from a terminal. After
+each call to <span class="code"><b>expect()</b></span> the <span
+ class="code"><b>before</b></span> and <span class="code"><b>after</b></span>
+properties will be set to the text printed by child application. The <span
+ class="code"><b>before</b></span> property will contain all text up to
+the expected string pattern. The <span class="code"><b>after</b></span> string
+will contain the text that was matched by the expected pattern.
+The <span class="code">match</span> property is set to the <span class="code">re MatchObject</span>.
+</p>
+
+<p>An example of Pexpect in action may make things more clear. This example uses
+<span class="code">ftp</span> to login to the OpenBSD site; list files
+in a directory; and then pass interactive control of the ftp session to
+the human user.</p>
+<blockquote>
+  <pre class="code">import pexpect<br>child = pexpect.spawn ('ftp ftp.openbsd.org')<br>child.expect ('Name .*: ')<br>child.sendline ('anonymous')<br>child.expect ('Password:')<br>child.sendline ('noah at example.com')<br>child.expect ('ftp&gt; ')<br>child.sendline ('ls /pub/OpenBSD/')<br>child.expect ('ftp&gt; ')<br>print child.before   # Print the result of the ls command.<br>child.interact()     # Give control of the child to the user.<br></pre>
+</blockquote>
+<h2>Special EOF and TIMEOUT patterns</h2>
+<p>
+There are two special patterns to match the End Of File or a Timeout condition.
+You you can pass these patterns to <span class="code">expect()</span>.
+These patterns are not regular expressions. Use them like predefined constants.
+</p>
+<p>If the child has died and you have read all the child's output then ordinarily
+<span class="code">expect()</span> will raise an <span class="code">EOF</span>
+exception. You can read everything up to the EOF without generating an
+exception by using the EOF pattern <span class="code">expect(pexpect.EOF)</span>.
+In this case everything the child has output will be available in the <span
+ class="code">before</span> property.</p>
+<p>The pattern given to <span class="code">expect()</span> may be a
+regular expression or it may also be a <b>list</b> of regular expressions.
+This allows you to match multiple optional responses. The <span class="code">expect()</span>
+method returns the index of the pattern that was matched. For example,
+say you wanted to login to a server. After entering a password you
+could get various responses from the server -- your password could be
+rejected; or you could be allowed in and asked for your terminal type;
+or you could be let right in and given a command prompt. The following
+code fragment gives an example of this:</p>
+<blockquote>
+  <pre class="code">child.expect('password:')<br>child.sendline (my_secret_password)<br># We expect any of these three patterns...<br>i = child.expect (['Permission denied', 'Terminal type', '[#\$] '])<br>if i==0:<br>    print 'Permission denied on host. Can't login'<br>    child.kill(0)<br>elif i==2:<br>    print 'Login OK... need to send terminal type.'<br>    child.sendline('vt100')<br>    child.expect ('[#\$] ')<br>elif i==3:<br>    print 'Login OK.'<br>    print 'Shell command prompt', child.after</pre>
+</blockquote>
+<p>If nothing matches an expected pattern then expect will eventually
+raise a TIMEOUT exception. The default time is 30 seconds, but you can
+change this by passing a timeout argument to expect():</p>
+<blockquote>
+  <pre class="code"># Wait no more than 2 minutes (120 seconds) for password prompt.<br>child.expect('password:', timeout=120)</pre>
+</blockquote>
+<h2>Find the end of line -- CR/LF conventions<br>
+Matching at the end of a line can be tricky<br>
+$ regex pattern is useless.<br>
+</h2>
+<p>Pexpect matches regular expressions a little differently than what
+you might be used to.
+</p>
+<p><i><b>The $ pattern for end of line match is useless</b></i>.
+The $ matches the end of string, but Pexpect reads from the child
+one character at a time, so each character looks like the end of a line.
+Pexpect can't do a look-ahead into the child's output stream.
+In general you would have this situation when using regular expressions
+with any stream.<br>
+<i>Note, pexpect does have an internal buffer, so reads are faster
+than one character at a time, but from the user's perspective the regex
+patterns test happens one character at a time.</i></p>
+<p>The best way to match the end of a line is to look for the
+newline: "\r\n" (CR/LF). Yes, that does appear to be DOS-style.
+It may surprise some UNIX people to learn that terminal TTY device drivers
+(dumb, vt100, ANSI, xterm, etc.) all use the CR/LF combination to signify
+the end of line. Pexpect uses a Pseudo-TTY device to talk to the child application, so
+when the child app prints "\n" you actually see "\r\n".
+</p>
+<p><b>UNIX uses just linefeeds to end lines of text, but not when it
+comes to TTY devices!</b> TTY devices are more like the Windows world.
+Each line of text end with a CR/LF combination. When you intercept data
+from a UNIX command from a TTY device you will find that the TTY device
+outputs a CR/LF combination. A UNIX command may only write a linefeed
+(\n), but the TTY device driver converts it to CR/LF. This means that
+your terminal will see lines end with CR/LF (hex&nbsp;<span class="code">0D&nbsp;0A</span>).
+Since Pexpect emulates a terminal, to match ends of lines you have to
+expect the CR/LF combination.</p>
+<blockquote>
+  <p class="code">child.expect ('\r\n')</p>
+</blockquote>
+<p>If you just need to skip past a new line then <span class="code">expect
+('\n')</span> by itself will work, but if you are expecting a specific
+pattern before the end of line then you need to explicitly look for the
+\r. For example the following expects a word at the end of a line:</p>
+<blockquote>
+  <p class="code">child.expect ('\w+\r\n')</p>
+</blockquote>
+<p>But the following would both fail:</p>
+<blockquote>
+  <p class="code">child.expect ('\w+\n')</p>
+</blockquote>
+<p>And as explained before, trying to use '$' to match the end of line
+would not work either:</p>
+<blockquote>
+  <p class="code">child.expect ('\w+$')</p>
+</blockquote>
+<p>So if you need to explicitly look for the END OF LINE, you want to
+look for the CR/LF combination -- not just the LF and not the $ pattern.</p>
+<p>This problem is not limited to Pexpect. This problem happens any
+time you try to perform a regular expression match on a stream. Regular
+expressions need to look ahead. With a stream it is hard to look ahead
+because the process generating the stream may not be finished. There is no
+way to know if the process has paused momentarily or is finished and
+waiting for you. <font color="#cc0000">Pexpect must implicitly always
+do a NON greedy match (minimal) at the end of a input {### already said
+this}.</font> </p>
+<p>Pexpect compiles all regular expressions with the DOTALL flag. With
+the DOTALL flag a "." will match a newline. See the Python <a
+ href="http://www.python.org/doc/current/lib/node115.html#l2h-733">documentation</a></p>
+<h2>Beware of + and * at the end of input.</h2>
+<p>Remember that any time you try to match a pattern that needs
+look-ahead that you will always get a minimal match (non greedy). For
+example, the following will always return just one character:</p>
+<blockquote>
+  <p class="code">child.expect ('.+')</p>
+</blockquote>
+<p>This example will match successfully, but will always return no
+characters:</p>
+<blockquote>
+  <p class="code">child.expect ('.*')</p>
+</blockquote>
+<p>Generally any star * expression will match as little as possible</p>
+<p>One thing you can do is to try to force a non-ambiguous character at
+the end of your <span class="code">\d+</span> pattern. Expect that
+character to delimit the string. For example, you might try making thr
+end of your pattrn be <span class="code">\D+</span> instead of <span
+ class="code">\D*</span>. That means number digits alone would not
+satisfy the (<span class="code">\d+</span>) pattern. You would need
+some number(s) and at least one <span class="code">\D</span> at the
+end. </p>
+<h2>Matching groups</h2>
+<p>You can group regular expression using parenthesis. After a match,
+the <span class="code">match</span> parameter of the spawn object will
+contain the Python Match object. </p>
+<h2>Examples</h2>
+<p>Using "match" and groups...</p>
+<h2>Debugging</h2>
+<p>If you get the string value of a pexpect.spawn object you will get
+lots of useful debugging information. For debugging it's very useful to
+use the following pattern:</p>
+<p>try:<br>
+&nbsp;&nbsp;&nbsp; i = child.expect ([pattern1, pattern2, pattern3,
+etc])<br>
+except:<br>
+&nbsp;&nbsp;&nbsp; print "Exception was thrown"<br>
+&nbsp;&nbsp;&nbsp; print "debug information:"<br>
+&nbsp;&nbsp;&nbsp; print str(child)<br>
+</p>
+<p>It is also useful to log the child's input and out to a file or the
+screen. The following will turn on logging and send output to stdout
+(the screen).<br>
+</p>
+<p>&nbsp;&nbsp;&nbsp; child = pexpect.spawn (foo)<br>
+&nbsp;&nbsp;&nbsp; child.logfile = sys.stdout<br>
+<br>
+</p>
+<hr noshade="noshade" size="1">
+<h1>Exceptions</h1>
+<p><b>EOF</b></p>
+<p>Note that two flavors of EOF Exception may be thrown. They are
+virtually identical except for the message string. For practical
+purposes you should have no need to distinguish between them, but they
+do give a little extra information about what type of platform you are
+running. The two messages are:</p>
+<blockquote>
+  <p class="code">End Of File (EOF) in read(). Exception style platform.</p>
+  <p class="code">End Of File (EOF) in read(). Empty string style
+platform.</p>
+</blockquote>
+<p>Some UNIX platforms will throw an exception when you try to read
+from a file descriptor in the EOF state. Other UNIX platforms instead
+quietly return an empty string to indicate that the EOF state has been
+reached.</p>
+<p><b>Expecting EOF</b></p>
+<p>If you wish to read up to the end of the child's output without
+generating an <span class="code">EOF</span> exception then use the <span
+ class="code">expect(pexpect.EOF)</span> method.</p>
+<p><b>TIMEOUT</b></p>
+<p>The <span class="code">expect()</span> and <span class="code">read()</span>
+methods will also timeout if the child does not generate any output for
+a given amount of time. If this happens they will raise a <span
+ class="code">TIMEOUT</span> exception. You can have these method
+ignore a timeout and block indefinitely by passing None for the timeout
+parameter.</p>
+<blockquote>
+  <p class="code">child.expect(pexpect.EOF, timeout=None)</p>
+</blockquote>
+<hr noshade="noshade" size="1">
+<h1><a name="faq"></a>FAQ</h1>
+<p>This is not a real FAQ, since no one really asked me most of these
+questions. I just made them up. If anyone asks real questions then I
+will put them here.</p>
+<p><b>Q: Isn't there already a Python Expect?</b></p>
+<p>A: Yes, there are several of them. They usually require you to
+compile C. I wanted something that was pure Python and preferably a
+single module that was simple to install. I also wanted something that
+was easy to use. This pure Python expect only recently became possible
+with the introduction of the pty module in the standard Python library.
+Previously C extensions were required.</p>
+<p><strong>Q: The before and after properties sound weird.</strong></p>
+<p>Originally I was going to model Pexpect more after Expect, but then
+I found that I could never remember how to get the context of the stuff
+I was trying to parse. I hate having to read my own documentation. I
+decided that it was easier for me to remember what before and after
+was. It just so happens that this is how the -B and -A options in grep
+works, so that made it even easier for me to remember. Whatever makes
+my life easier is what's best.</p>
+<p><b>Q: Why not just use Expect?</b></p>
+<p>A: I love it. It's great. I has bailed me out of some real jams, but
+I wanted something that would do 90% of what I need from Expect; be 10%
+of the size; and allow me to write my code in Python instead of TCL.
+Pexpect is not nearly as big as Expect, but Pexpect does everything I
+have ever used Expect for.
+<!--:-P If I liked TCL then you wouldn't be reading this. My appologies to Don Libes -- Expect is cool, TK is cool, but TCL is only slightly better than Perl in my book. Hopefully after Expyct is done I will not need to use Expect anymore -- except for that lovely autoexpect tool. Damn, I wish I had that! --> </p>
+<p><b>Q: Why not just use a pipe (popen())?</b></p>
+<p>A: A pipe works fine for getting the output to non-interactive
+programs. If you just want to get the output from <span class="code">ls</span>,
+<span class="code">uname</span>, or <span class="code">ping</span>
+then this works. Pipes do not work very well for interactive programs
+and pipes will almost certainly fail for most applications that ask for
+passwords such as telnet, ftp, or ssh.</p>
+<p>There are two reasons for this. </p>
+<p>First an application may bypass stdout and print directly to its
+controlling TTY. Something like SSH will do this when it asks you for a
+password. This is why you cannot redirect the password prompt because
+it does not go through stdout or stderr.</p>
+<p>The second reason is because most applications are built using the C
+Standard IO Library (anything that uses <span class="code">#include
+&lt;stdio.h&gt;</span>). One of the features of the stdio library is
+that it buffers all input and output. Normally output is <b><i>line
+buffered</i></b> when a program is printing to a TTY (your terminal
+screen). Everytime the program prints a line-feed the currently
+buffered data will get printed to your screen. The problem comes when
+you connect a pipe. The stdio library is smart and can tell that it is
+printing to a pipe instead of a TTY. In that case it switches from line
+buffer mode to <i><b>block buffered</b></i>. In this mode the
+currently buffered data is flushed when the buffer is full. This causes
+most interactive programs to deadlock. Block buffering is more
+efficient when writing to disks and pipes. Take the situation where a
+program prints a message "Enter your user name:\n" and then waits for
+you type type something. In block buffered mode, the stdio library will
+not put the message into the pipe even though a linefeed is printed.
+The result is that you never receive the message, yet the child
+application will sit and wait for you to type a response. Don't confuse
+the stdio lib's buffer with the pipe's buffer. The pipe buffer is
+another area that can cause problems. You could flush the input side of
+a pipe, whereas you have no control over the stdio library buffer. </p>
+<p>More information: the Standard IO library has three states for a
+FILE *. These are: _IOFBF for block buffered; _IOLBF for line buffered;
+and _IONBF for unbuffered. The STDIO lib will use block buffering when
+talking to a block file descriptor such as a pipe. This is usually not
+helpful for interactive programs. Short of recompiling your program to
+include fflush() everywhere or recompiling a custom stdio library there
+is not much a controlling application can do about this if talking over
+a pipe.</p>
+<p> The program may have put data in its output that remains unflushed
+because the output buffer is not full; then the program will go and
+deadlock while waiting for input -- because you never send it any
+because you are still waiting for its output (still stuck in the
+STDIO's output buffer).</p>
+<p>The answer is to use a pseudo-tty. A TTY device will force <i><b>line</b></i>
+buffering (as opposed to block buffering). Line buffering means that
+you will get each line when the child program sends a line feed. This
+corresponds to the way most interactive programs operate -- send a line
+of output then wait for a line of input.</p>
+<p>I put "answer" in quotes because it's ugly solution and because
+there is no POSIX standard for pseudo-TTY devices (even though they
+have a TTY standard...). What would make more sense to me would be to
+have some way to set a mode on a file descriptor so that it will tell
+the STDIO to be line-buffered. I have investigated, and I don't think
+there is a way to set the buffered state of a child process. The STDIO
+Library does not maintain any external state in the kernel or whatnot,
+so I don't think there is any way for you to alter it. I'm not quite
+sure how this line-buffered/block-buffered state change happens
+internally in the STDIO library. I think the STDIO lib looks at the
+file descriptor and decides to change behavior based on whether it's a
+TTY or a block file (see isatty()).</p>
+<p>I hope that this qualifies as helpful.</p>
+<h1>Don't use a pipe to control another application...</h1>
+<p>Pexpect may seem similar to <span class="code">os.popen()</span> or
+<span class="code">commands</span> module. The main difference is that
+Pexpect (like Expect) uses a pseudo-TTY to talk to the child
+application. Most applications do no work well through the system()
+call or through pipes. And probably all applications that ask a user to
+type in a password will fail. These applications bypass the stdin and
+read directly from the TTY device. Many applications do not explicitly
+flush their output buffers. This causes deadlocks if you try to control
+an interactive application using a pipe. What happens is that most UNIX
+applications use the stdio (#include &lt;stdio.h&gt;) for input and
+output. The stdio library behaves differently depending on where the
+output is going. There is no way to control this behavior from the
+client end.<br>
+</p>
+<p><b>Q: Can I do screen scraping with this thing?</b></p>
+<p>A: That depends. If your application just does line-oriented output
+then this is easy. If it does screen-oriented output then it may work,
+but it could be hard. For example, trying to scrape data from the 'top'
+command would be hard. The top command repaints the text window. </p>
+<p>I am working on an ANSI / VT100 terminal emulator that will have
+methods to get characters from an arbitrary X,Y coordinate of the
+virtual screen. It works and you can play with it, but I have no
+working examples at this time.</p>
+<hr noshade="noshade" size="1">
+<h1><a name="bugs"></a>Bugs</h1>
+<h2>Threads</h2>
+<p>On Linux (RH 8) you cannot spawn a child from a different thread and
+pass the handle back to a worker thread. The child is successfully
+spawned but you can't interact with it. The only way to make it work is
+to spawn and interact with the child all in the same thread. [Adam
+Kerrison] </p>
+<h2><a name="echo_bug"></a>Timing issue with send() and sendline()</h2>
+<p>This problem has been addressed and should not effect most users.</p>
+<p>It is sometimes possible to read an echo of the string sent with <span
+ class="code">send()</span> and <span class="code">sendline()</span>.
+If you call <span class="code">sendline()</span> and then immediately
+call <span class="code">readline()</span> you may get part of your
+output echoed back. You may read back what you just wrote even if the
+child application does not explicitly echo it. Timing is critical. This
+could be a security issue when talking to an application that asks for
+a password; otherwise, this does not seem like a big deal. <i>But why
+do TTYs do this</i>?</p>
+<p>People usually report this when they are trying to control SSH or
+some other login. For example, if your code looks something like this: </p>
+<pre class="code">child.expect ('[pP]assword:')<br>child.sendline (my_password)</pre>
+<p><br>
+<blockquote>
+1. SSH prints "password:" prompt to the user.<br>
+2. SSH turns off echo on the TTY device.<br>
+3. SSH waits for user to enter a password.<br>
+</blockquote>
+When scripting with Pexpect what can happen is that Pexpect will response to the "password:" prompt
+before SSH has had time to turn off TTY echo. In other words, Pexpect sends the password between
+steps 1. and 2., so the password gets echoed back to the TTY. I would call this an SSH bug.
+</p>
+<p>
+Pexpect now automatically adds a short delay before sending data to a child process.
+This more closely mimics what happens in the usual human-to-app interaction.
+The delay can be tuned with the 'delaybeforesend' attribute of the spawn class.
+In general, this fixes the problem for everyone and so this should not be an issue
+for most users. For some applications you might with to turn it off.
+    child = pexpect.spawn ("ssh user at example.com")
+    child.delaybeforesend = 0
+</p>
+<p><br>
+</p>
+<p>Try changing it to look like the following. I know that this fix
+does not look correct, but it works. I have not figured out exactly
+what is happening. You would think that the sleep should be after the
+sendline(). The fact that the sleep helps when it's between the
+expect() and the sendline() must be a clue.</p>
+<pre class="code">child.expect ('[pP]assword:')<br>child.sendline (my_password)</pre>
+<h2>Timing issue with isalive()</h2>
+<p>Reading the state of isalive() immediately after a child exits may
+sometimes return 1. This is a race condition. The child has closed its
+file descriptor, but has not yet fully exited before Pexpect's
+isalive() executes. Addings a slight delay before the isalive() will
+help. In the following example <span class="code">isalive()</span>
+sometimes returns 1:</p>
+<blockquote>
+  <pre class="code">child = pexpect.spawn('ls')<br>child.expect(pexpect.EOF)<br>print child.isalive()</pre>
+</blockquote>
+<p>But if there is any delay before the call to <span class="code">isalive()</span>
+then it will always return 0 as expected.</p>
+<blockquote>
+  <pre class="code">child = pexpect.spawn('ls')<br>child.expect(pexpect.EOF)<br>time.sleep(0.1)<br>print child.isalive()</pre>
+</blockquote>
+<h2>Truncated output just before child exits</h2>
+<p><i>So far I have seen this only on older versions of <b>Apple's MacOS X</b>.</i>
+If the child application quits it may not flush its output buffer. This
+means that your Pexpect application will receive an EOF even though it
+should have received a little more data before the child died. This is
+not generally a problem when talking to interactive child applications.
+One example where it is a problem is when trying to read output from a
+program like '<span class="code">ls</span>'. You may receive most of
+the directory listing, but the last few lines will get lost before you
+receive an EOF. The reason for this is that '<span class="code">ls</span>'
+runs; completes its task; and then exits. The buffer is not flushed
+before exit so the last few lines are lost. The following example
+demonstrates the problem:</p>
+<p> </p>
+<blockquote>
+  <pre class="code">child = pexpect.spawn ('ls -l')<br>child.expect (pexpect.EOF)<br>print child.before <br>  </pre>
+</blockquote>
+<p></p>
+<h2>Controlling SSH on Solaris</h2>
+<p>Pexpect does not yet work perfectly on Solaris.
+One common problem is that SSH sometimes will not allow TTY password
+authentication. For example, you may expect SSH to ask you for a
+password using code like this:
+</p>
+<pre class="code">child = pexpect.spawn ('ssh user at example.com')<br>child.expect ('assword')<br>child.sendline ('mypassword')<br></pre>
+You may see the following error come back from a spawned
+child SSH:
+<p></p>
+<blockquote>Permission denied (publickey,keyboard-interactive). </blockquote>
+<p>
+This means that SSH thinks it can't access the TTY to ask you for your
+password.
+The only solution I have found is to use public key authentication with
+SSH.
+This bypasses the need for a password. I'm not happy with this
+solution.
+The problem is due to poor support for Solaris Pseudo TTYs in the
+Python
+Standard Library. </p>
+<hr noshade="noshade" size="1">
+<h1><a name="changes"></a>CHANGES</h1>
+<h2>Current Release</h2>
+<p>Fixed OSError exception when a pexpect object is cleaned up.
+Previously you might have seen this exception:</p>
+<blockquote>
+  <pre class="code">Exception exceptions.OSError: (10, 'No child processes') <br>in &lt;bound method spawn.__del__ of<br>&lt;pexpect.spawn instance at 0xd248c&gt;&gt; ignored</pre>
+</blockquote>
+<p>You should not see that anymore. Thanks to Michael Surette.</p>
+<p>Added support for buffering reads. This greatly improves speed when
+trying to match long output from a child process. When you create an
+instance of the spawn object you can then set a buffer size. For now
+you MUST do the following to turn on buffering -- it may be on by
+default in future version.</p>
+<blockquote>
+  <pre class="code">child = pexpect.spawn ('my_command')<br>child.maxread=1000 # Sets buffer to 1000 characters.</pre>
+</blockquote>
+<div>
+<p>I made a subtle change to the way TIMEOUT and EOF exceptions behave.
+Previously you could either expect these states in which case pexpect
+will not raise an exception, or you could just let pexpect raise an
+exception when these states were encountered. If you expected the
+states then the 'before' property was set to everything before the
+state was encountered, but if you let pexpect raise the exception then
+'before' was not set. Now the 'before' property will get set either way
+you choose to handle these states.</p>
+<h2><i>Older changes...</i></h2>
+<p>The spawn object now provides iterators for a <i>file-like interface</i>.
+This makes Pexpect a more complete file-like object. You can now write
+code like this:</p>
+<blockquote>
+  <pre class="code">child = pexpect.spawn ('ls -l')<br>for line in child:<br>    print line<br></pre>
+</blockquote>
+<p>I added the attribute <span class="code">exitstatus</span>. This
+will give the exit code returned by the child process. This will be set
+to <span class="code">None</span> while the child is still alive. When
+<span class="code">isalive()</span> returns 0 then <span class="code">exitstatus</span>
+will be set.</p>
+<p>I made a few more tweaks to <span class="code">isalive()</span> so
+that it will operate more consistently on different platforms. Solaris
+is the most difficult to support.</p>
+<p>&nbsp;</p>
+<p>You can now put <span class="code">TIMEOUT</span> in a list of
+expected patterns. This is just like putting <span class="code">EOF</span>
+in the pattern list. Expecting for a <span class="code">TIMEOUT</span>
+may not be used as often as <span class="code">EOF</span>, but this
+makes Pexpect more consitent.</p>
+<p>Thanks to a suggestion and sample code from Chad J. Schroeder I
+added the ability for Pexpect to operate on a file descriptor that is
+already open. This means that Pexpect can be used to control streams
+such as those from serial port devices. Now you just pass the integer
+file descriptor as the "command" when contsructing a spawn open. For
+example on a Linux box with a modem on ttyS1:</p>
+<blockquote>
+  <pre class="code">fd = os.open("/dev/ttyS1", os.O_RDWR|os.O_NONBLOCK|os.O_NOCTTY)<br>m = pexpect.spawn(fd) # Note integer fd is used instead of usual string.<br>m.send("+++") # Escape sequence<br>m.send("ATZ0\r") # Reset modem to profile 0<br>rval = m.expect(["OK", "ERROR"])</pre>
+</blockquote>
+<h3>Pexpect now tests itself on Compile Farm!</h3>
+<p>I wrote a nice script that uses ssh to connect to each machine on
+Source Forge's Compile Farm and then run the testall.py script for each
+platform. The result of the test is then recorded for each platform.
+Now it's easy to run regression tests across multiple platforms.</p>
+<h3>Pexpect is a file-like object</h3>
+<p>The spawn object now provides a <i>file-like interface</i>. It
+supports most of the methods and attributes defined for Python File
+Objects. </p>
+<p>I changed write and writelines() so that they no longer return a
+value. Use send() if you need that functionality. I did this to make
+the Spawn object more closely match a file-like object.</p>
+<p>read() was renamed to read_nonblocking(). I added a new read()
+method that matches file-like object interface. In general, you should
+not notice the difference except that read() no longer allows you to
+directly set the timeout value. I hope this will not effect any
+existing code. Switching to read_nonblocking() should fix existing code.</p>
+<p>I changed the name of <span class="code">set_echo()</span> to <span
+ class="code">setecho()</span>.</p>
+<p>I changed the name of <span class="code">send_eof()</span> to <span
+ class="code">sendeof()</span>.</p>
+<p>I modified <span class="code">kill()</span> so that it checks to
+make sure the pid isalive().</p>
+<p>I modified <span class="code">spawn()</span> (really called from <span
+ class="code">__spawn()</span>)so that it does not raise an expection
+if <span class="code">setwinsize()</span> fails. Some platforms such
+as Cygwin do not like setwinsize. This was a constant problem and since
+it is not a critical feature I decided to just silence the error.
+Normally I don't like to do that, but in this case I'm making an
+exception.</p>
+<p>Added a method <span class="code">close()</span> that does what you
+think. It closes the file descriptor of the child application. It makes
+no attempt to actually kill the child or wait for its status. </p>
+<p>Add variables <span class="code">__version__</span> and <span
+ class="code">__revision__</span> (from cvs) to the pexpect modules.
+This is mainly helpful to me so that I can make sure that I'm testing
+with the right version instead of one already installed.</p>
+<h3>Logging changes</h3>
+<blockquote>
+  <p><span class="code">log_open()</span> and <span class="code">log_close()</span>
+have been removed. Now use <span class="code">setlog()</span>. The <span
+ class="code">setlog()</span> method takes a file object. This is far
+more flexible than the previous log method. Each time data is written
+to the file object it will be flushed. To turn logging off simply call <span
+ class="code">setlog()</span> with None.</p>
+</blockquote>
+<h2>isalive changes</h2>
+<blockquote>
+  <p>I renamed the <span class="code">isAlive()</span> method to <span
+ class="code">isalive()</span> to match the more typical naming style
+in Python. Also the technique used to detect child process status has
+been drastically modified. Previously I did some funky stuff with
+signals which caused indigestion in other Python modules on some
+platforms. It's was a big headache. It still is, but I think it works
+better now.</p>
+</blockquote>
+<h3>attribute name changes</h3>
+<blockquote>
+  <p>The names of some attributes have been changed. This effects the
+names of the attributes that are set after called the <span
+ class="code">expect()</span> method.</p>
+  <table class="pymenu" border="0" cellpadding="5">
+    <tbody>
+      <tr>
+        <th class="pymenu">NEW NAME</th>
+        <th class="pymenu">OLD NAME</th>
+      </tr>
+      <tr>
+        <td><span class="code">before</span><br>
+        <i>Everything before the match.</i></td>
+        <td><span class="code">before</span></td>
+      </tr>
+      <tr>
+        <td><span class="code">after</span><br>
+        <i>Everything after and including the first character of the
+match</i></td>
+        <td><span class="code">matched</span></td>
+      </tr>
+      <tr>
+        <td><span class="code">match</span><br>
+        <i>This is the re MatchObject from the match.<br>
+You can get groups() from this.<br>
+See '<span class="code">uptime.py</span>' in the examples tar ball.</i></td>
+        <td><i>New -- Did not exist</i></td>
+      </tr>
+    </tbody>
+  </table>
+</blockquote>
+<h3>EOF changes</h3>
+<blockquote>
+  <p>The <span class="code">expect_eof()</span> method is gone. You
+can now simply use the <span class="code">expect()</span> method to
+look for EOF.</p>
+  <p>Was:</p>
+  <blockquote>
+    <p><span class="code">p.expect_eof ()</span></p>
+  </blockquote>
+  <p>Now:</p>
+  <blockquote>
+    <p><span class="code">p.expect (pexpect.EOF)</span></p>
+  </blockquote>
+</blockquote>
+<hr noshade="noshade" size="1">
+<h1><a name="testing"></a>TESTING</h1>
+<p>The following platforms have been tested:</p>
+<table class="pymenu" border="0" cellpadding="5">
+  <tbody>
+    <tr>
+      <th class="pymenu">PLATFORM</th>
+      <th class="pymenu">RESULTS</th>
+    </tr>
+    <tr>
+      <td>Linux 2.4.9-ac10-rmk2-np1-cerf2<br>
+armv4l</td>
+      <td><b><i>all tests passed</i></b></td>
+    </tr>
+    <tr>
+      <td>Linux 2.4.18 #2<br>
+sparc64</td>
+      <td><b><i>all tests passed</i></b></td>
+    </tr>
+    <tr>
+      <td>MacOS X Darwin Kernel Version 5.5<br>
+powerpc</td>
+      <td>
+      <p>failed more than one test.</p>
+      <p>Generally Pexpect works on OS X, but the nature of the quirks
+cause a many of the tests to fail. See <a href="#bugs">bugs</a>
+(Incomplete Child Output). The problem is more than minor, but Pexpect
+is still more than useful for most tasks. The problem is an edge case.</p>
+      </td>
+    </tr>
+    <tr>
+      <td>Linux 2.2.20<br>
+alpha<br>
+      </td>
+      <td><b><i>all tests passed</i></b></td>
+    </tr>
+    <tr>
+      <td>Linux 2.4.18-5smp<br>
+i686</td>
+      <td><b><i>all tests passed</i></b></td>
+    </tr>
+    <tr>
+      <td>OpenBSD 2.9 GENERIC#653<br>
+i386</td>
+      <td><b><i>all tests passed</i></b></td>
+    </tr>
+    <tr>
+      <td>Solaris</td>
+      <td>
+      <p>failed <span class="code">test_destructor</span></p>
+      <p>Otherwise, this is working pretty well. The destructor problem
+is minor. For some reason, the <i>second</i> time a pty file
+descriptor is created and deleted it never gets returned for use. It
+does not effect the first time or the third time or any time after
+that. It's only the second time. This is weird... This could be a file
+descriptor leak, or it could be some peculiarity of how Solaris
+recycles them. I thought it was a UNIX requirement for the OS to give
+you the lowest available filedescriptor number. In any case, this
+should not be a problem unless you create hundreds of pexpect
+instances... It may also be a pty module bug. </p>
+      </td>
+    </tr>
+    <tr>
+      <td>Windows XP Cygwin</td>
+      <td>failed <span class="code">test_destructor</span>. That it
+works at all is amazing to me. Cygwin rules!</td>
+    </tr>
+  </tbody>
+</table>
+<h1>&nbsp;</h1>
+<h1><a name="todo">TO DO</a></h1>
+<p>Add an option to add a delay after each expect() or before each
+read()/readline() call to automatically avoid the <a href="#echo_bug">echo
+bug</a>.</p>
+<p>&nbsp;</p>
+</div>
+<hr noshade="noshade" size="1">
+<table border="0">
+  <tbody>
+    <tr>
+      <td> <a href="http://www.noah.org/email/"><img src="email.png"
+ alt="Click to send email." border="0" height="16" width="100"></a> </td>
+    </tr>
+  </tbody>
+</table>
+</div>
+<div id="Menu"><b>INDEX</b><br>
+<hr noshade="noshade" size="1"> <a href="#license"
+ title="Python Software Foundation License">License</a><br>
+<a href="#download" title="Download and setup instructions">Download</a><br>
+<a href="#doc" title="Documentation and overview">Documentation</a><br>
+<a href="#status" title="Project Status">Project Status</a><br>
+<a href="#requirements" title="System requirements to use Pexpect">Requirements</a><br>
+<a href="#overview" title="Overview of what Pexpect does">Overview</a><br>
+<a href="#faq" title="FAQ">FAQ</a><br>
+<a href="#bugs" title="Bugs and work-arounds">Known Bugs</a><br>
+<a href="#changes" title="What's new with Pexpect">Recent Changes</a><br>
+<a href="#testing" title="Test results on various platforms">Testing</a><br>
+<a href="#todo" title="What to do next">To do</a><br>
+<a href="http://svn.sourceforge.net/viewcvs.cgi/pexpect/trunk/pexpect/" title="browse SVN">Browse SVN</a><br>
+<br>
+<a href="http://sourceforge.net/projects/pexpect/"
+ title="The Pexpect project page on SourceForge.net"> <img
+ src="http://sourceforge.net/sflogo.php?group_id=59762&amp;type=5"
+ alt="The Pexpect project page on SourceForge.net" border="0"
+ height="31" width="105"> </a> </div>
+</body>
+</html>

Added: packages/pexpect/branches/upstream/current/doc/index.template.html
URL: http://svn.debian.org/wsvn/python-modules/packages/pexpect/branches/upstream/current/doc/index.template.html?rev=929&op=file
==============================================================================
--- packages/pexpect/branches/upstream/current/doc/index.template.html (added)
+++ packages/pexpect/branches/upstream/current/doc/index.template.html Mon Jun 19 10:53:24 2006
@@ -1,0 +1,835 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<title>Pexpect - a Pure Python Expect-like module</title>
+<link rel="stylesheet" href="clean.css" type="text/css">
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<meta name="Author" content="Noah Spurrier">
+<meta name="Keywords"
+ content="pexpect, Noah Spurrier, pypect, Python, Libes, TCL, Expect, pipe, popen, pyExpect, expectpy, expect-like, expect-alike, expect like">
+<meta name="Description"
+ content="Pexpect is a pure Python Expect-like module. Pexpect makes Python a better tool for controlling other applications.">
+</head>
+<body bgcolor="#ffffff" text="#000000">
+<div id="Header">
+<h1>Pexpect version 2.1<br>
+a Pure Python Expect-like module
+</h1>
+</div>
+<div id="Content">
+<p>Pexpect makes Python a better tool for controlling other
+applications.</p>
+<p>Pexpect is a pure Python module for spawning child applications;
+controlling them; and responding to expected patterns in their output.
+Pexpect works like Don Libes' Expect. Pexpect allows your script to
+spawn a child application and control it as if a human were typing
+commands.</p>
+<p>Pexpect can be used for automating interactive applications such as
+ssh, ftp, passwd, telnet, etc. It can be used to a automate setup
+scripts for duplicating software package installations on different
+servers. It can be used for automated software testing. Pexpect is in
+the spirit of Don Libes' Expect, but Pexpect is pure Python. Unlike
+other Expect-like modules for Python, Pexpect does not require TCL or
+Expect nor does it require C extensions to be compiled. It should work
+on any platform that supports the standard Python pty module. The
+Pexpect interface was designed to be easy to use.</p>
+<table border="0">
+  <tbody>
+    <tr>
+      <td align="right" valign="top">Send questions to:</td>
+      <td align="left"><a href="http://www.noah.org/email/"><img
+ src="email.png" alt="Click to send email." border="0" height="16"
+ width="100"></a></td>
+    </tr>
+  </tbody>
+</table>
+<hr noshade="noshade" size="1">
+<h1><a name="license"></a>License: MIT style</h1>
+<p>
+Free, open source, and all that good stuff.<br>
+<br>
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:<br>
+<br>
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.<br>
+<br>
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+USE OR OTHER DEALINGS IN THE SOFTWARE.<br>
+<br>
+Pexpect Copyright (c) 2006 Noah Spurrier<br>
+http://pexpect.sourceforge.net/
+</p>
+
+<hr noshade="noshade" size="1">
+<h1><a name="download"></a><a
+ href="http://sourceforge.net/project/showfiles.php?group_id=59762">Download</a></h1>
+<p>Download the <a
+ href="http://sourceforge.net/project/showfiles.php?group_id=59762">
+current version here</a> from the SourceForge site. Grab the current Pexpect tarball.
+</p>
+<h2>Installing Pexpect</h2>
+<p>The Pexpect tarball is a standard Python Distutil distribution.</p>
+<ol>
+  <li>download <span class="code">pexpect-VERSION.tar.gz</span></li>
+  <li><span class="code">tar zxf pexpect-VERSION.tar.gz</span></li>
+  <li><span class="code">cd pexpect-VERSION</span></li>
+  <li><span class="code">python setup.py install</span> <i>do this as root</i></li>
+</ol>
+<h2>Examples</h2>
+<p>
+Under the <span class="code">pexpect-VERSION</span> directory you should find
+the <span class="code">examples</span> directory.
+This is the best way to learn to use Pexpect.
+See the descriptions of <a href="examples.html">Pexpect Examples</a>.
+</p>
+<h2><a name="doc"></a>API Documentation</h2>
+<p>
+<blockquote>
+<a href="pexpect.html">pexpect</a> This is the main module that you want.<br>
+<a href="pxssh.html">pxssh</a> Pexpect SSH is an extension of 'pexpect.spawn' that specializes in SSH.<br>
+</blockquote>
+the following are experimental extensions to Pexpect<br>
+<blockquote>
+<a href="fdpexpect.html">fdpexpect</a> fdpexpect extension of 'pexpect.spawn' that uses an open file descriptor.<br>
+<a href="screen.html">SCREEN</a> This represents a virtual 'screen'.<br>
+<a href="ANSI.html">ANSI</a> This parses ANSI/VT-100 terminal escape codes.<br>
+<a href="FSM.html">FSM</a> This is a finite state machine used by ANSI.<br>
+</blockquote>
+</p>
+<hr noshade="noshade" size="1">
+<h1><a name="status"></a>Project Status</h1>
+<p>Automated pyunit tests reach over 80%
+code coverage on pexpect.py. I regularly test on Linux and BSD
+platforms. I try to test on Solaris and Irix. 
+</p>
+<hr noshade="noshade" size="1">
+<h1><a name="requirements"></a>Requirements for use of Pexpect</h1>
+<h2>Python</h2>
+<blockquote>
+  <p>Pexpect was written and tested with Python 2.4. It should work on
+earlier versions that have the <span class="code">pty</span> module. I
+sometimes even manually test it with Python 1.5.2, but I can't easily
+run the PyUnit test framework against Python 1.5.2, so I have less
+confidence in Pexpect on Python 1.5.2.</p>
+</blockquote>
+<h2>pty module</h2>
+<blockquote>
+  <p>Any POSIX system (UNIX) with a working <span class="code">pty</span>
+module should be able to run Pexpect. The <span class="code">pty</span>
+module is part of the Standard Python Library, so if you are running on
+a POSIX system you should have it. The <span class="code">pty</span>
+module does not run the same on all platforms. It should be solid on Linux
+and BSD systems. I have taken effort to try to smooth the wrinkles out of the different platforms. To learn more
+about the wrinkles see <a href="#bugs">Bugs</a> and <a href="#testing">Testing</a>.</p>
+</blockquote>
+<p>Pexpect does not currently work on the standard Windows Python (see
+the pty requirement); however, it seems to work fine using <a
+ href="http://www.cygwin.com/">Cygwin</a>. It is possible to build
+something like a pty for Windows, but it would have to use a different
+technique that I am still investigating. I know it's possible because
+Libes' Expect was ported to Windows. <i>If you have any ideas or
+skills to contribute in this area then I would really appreciate some
+tips on how to approach this problem.</i> </p>
+<hr noshade="noshade" size="1">
+<h1><a name="overview"></a>Overview</h1>
+<p>Pexpect can be used for automating interactive applications such as
+ssh, ftp, mencoder, passwd, etc. The Pexpect interface was designed to be
+easy to use. Here is an example of Pexpect in action:</p>
+<blockquote>
+  <pre class="code"># This connects to the openbsd ftp site and<br># downloads the recursive directory listing.<br>import pexpect<br>child = pexpect.spawn ('ftp ftp.openbsd.org')<br>child.expect ('Name .*: ')<br>child.sendline ('anonymous')<br>child.expect ('Password:')<br>child.sendline ('noah at example.com')<br>child.expect ('ftp&gt; ')<br>child.sendline ('cd pub')<br>child.expect('ftp&gt; ')<br>child.sendline ('get ls-lR.gz')<br>child.expect('ftp&gt; ')<br>child.sendline ('bye')<br></pre>
+</blockquote>
+<p> Obviously you could write an ftp client using Python's own <span
+ class="code">ftplib</span> module, but this is just a demonstration.
+You can use this technique with any application. This is especially
+handy if you are writing automated test tools.</p>
+
+<p>There are two important methods in Pexpect -- <span class="code"><b>expect()</b></span>
+and <span class="code"><b>send()</b></span> (or <span class="code">sendline()</span>
+which is like <span class="code">send()</span> with a linefeed). 
+The <span class="code">expect()</span> method waits for the child application
+to return a given strong. The string you specify is a regular expression, so
+you can match complicated patterns. The <span class="code"><b>send()</b></span> method
+writes a string to the child application. From the child's point of
+view it looks just like someone typed the text from a terminal. After
+each call to <span class="code"><b>expect()</b></span> the <span
+ class="code"><b>before</b></span> and <span class="code"><b>after</b></span>
+properties will be set to the text printed by child application. The <span
+ class="code"><b>before</b></span> property will contain all text up to
+the expected string pattern. The <span class="code"><b>after</b></span> string
+will contain the text that was matched by the expected pattern.
+The <span class="code">match</span> property is set to the <span class="code">re MatchObject</span>.
+</p>
+
+<p>An example of Pexpect in action may make things more clear. This example uses
+<span class="code">ftp</span> to login to the OpenBSD site; list files
+in a directory; and then pass interactive control of the ftp session to
+the human user.</p>
+<blockquote>
+  <pre class="code">import pexpect<br>child = pexpect.spawn ('ftp ftp.openbsd.org')<br>child.expect ('Name .*: ')<br>child.sendline ('anonymous')<br>child.expect ('Password:')<br>child.sendline ('noah at example.com')<br>child.expect ('ftp&gt; ')<br>child.sendline ('ls /pub/OpenBSD/')<br>child.expect ('ftp&gt; ')<br>print child.before   # Print the result of the ls command.<br>child.interact()     # Give control of the child to the user.<br></pre>
+</blockquote>
+<h2>Special EOF and TIMEOUT patterns</h2>
+<p>
+There are two special patterns to match the End Of File or a Timeout condition.
+You you can pass these patterns to <span class="code">expect()</span>.
+These patterns are not regular expressions. Use them like predefined constants.
+</p>
+<p>If the child has died and you have read all the child's output then ordinarily
+<span class="code">expect()</span> will raise an <span class="code">EOF</span>
+exception. You can read everything up to the EOF without generating an
+exception by using the EOF pattern <span class="code">expect(pexpect.EOF)</span>.
+In this case everything the child has output will be available in the <span
+ class="code">before</span> property.</p>
+<p>The pattern given to <span class="code">expect()</span> may be a
+regular expression or it may also be a <b>list</b> of regular expressions.
+This allows you to match multiple optional responses. The <span class="code">expect()</span>
+method returns the index of the pattern that was matched. For example,
+say you wanted to login to a server. After entering a password you
+could get various responses from the server -- your password could be
+rejected; or you could be allowed in and asked for your terminal type;
+or you could be let right in and given a command prompt. The following
+code fragment gives an example of this:</p>
+<blockquote>
+  <pre class="code">child.expect('password:')<br>child.sendline (my_secret_password)<br># We expect any of these three patterns...<br>i = child.expect (['Permission denied', 'Terminal type', '[#\$] '])<br>if i==0:<br>    print 'Permission denied on host. Can't login'<br>    child.kill(0)<br>elif i==2:<br>    print 'Login OK... need to send terminal type.'<br>    child.sendline('vt100')<br>    child.expect ('[#\$] ')<br>elif i==3:<br>    print 'Login OK.'<br>    print 'Shell command prompt', child.after</pre>
+</blockquote>
+<p>If nothing matches an expected pattern then expect will eventually
+raise a TIMEOUT exception. The default time is 30 seconds, but you can
+change this by passing a timeout argument to expect():</p>
+<blockquote>
+  <pre class="code"># Wait no more than 2 minutes (120 seconds) for password prompt.<br>child.expect('password:', timeout=120)</pre>
+</blockquote>
+<h2>Find the end of line -- CR/LF conventions<br>
+Matching at the end of a line can be tricky<br>
+$ regex pattern is useless.<br>
+</h2>
+<p>Pexpect matches regular expressions a little differently than what
+you might be used to.
+</p>
+<p><i><b>The $ pattern for end of line match is useless</b></i>.
+The $ matches the end of string, but Pexpect reads from the child
+one character at a time, so each character looks like the end of a line.
+Pexpect can't do a look-ahead into the child's output stream.
+In general you would have this situation when using regular expressions
+with any stream.<br>
+<i>Note, pexpect does have an internal buffer, so reads are faster
+than one character at a time, but from the user's perspective the regex
+patterns test happens one character at a time.</i></p>
+<p>The best way to match the end of a line is to look for the
+newline: "\r\n" (CR/LF). Yes, that does appear to be DOS-style.
+It may surprise some UNIX people to learn that terminal TTY device drivers
+(dumb, vt100, ANSI, xterm, etc.) all use the CR/LF combination to signify
+the end of line. Pexpect uses a Pseudo-TTY device to talk to the child application, so
+when the child app prints "\n" you actually see "\r\n".
+</p>
+<p><b>UNIX uses just linefeeds to end lines of text, but not when it
+comes to TTY devices!</b> TTY devices are more like the Windows world.
+Each line of text end with a CR/LF combination. When you intercept data
+from a UNIX command from a TTY device you will find that the TTY device
+outputs a CR/LF combination. A UNIX command may only write a linefeed
+(\n), but the TTY device driver converts it to CR/LF. This means that
+your terminal will see lines end with CR/LF (hex&nbsp;<span class="code">0D&nbsp;0A</span>).
+Since Pexpect emulates a terminal, to match ends of lines you have to
+expect the CR/LF combination.</p>
+<blockquote>
+  <p class="code">child.expect ('\r\n')</p>
+</blockquote>
+<p>If you just need to skip past a new line then <span class="code">expect
+('\n')</span> by itself will work, but if you are expecting a specific
+pattern before the end of line then you need to explicitly look for the
+\r. For example the following expects a word at the end of a line:</p>
+<blockquote>
+  <p class="code">child.expect ('\w+\r\n')</p>
+</blockquote>
+<p>But the following would both fail:</p>
+<blockquote>
+  <p class="code">child.expect ('\w+\n')</p>
+</blockquote>
+<p>And as explained before, trying to use '$' to match the end of line
+would not work either:</p>
+<blockquote>
+  <p class="code">child.expect ('\w+$')</p>
+</blockquote>
+<p>So if you need to explicitly look for the END OF LINE, you want to
+look for the CR/LF combination -- not just the LF and not the $ pattern.</p>
+<p>This problem is not limited to Pexpect. This problem happens any
+time you try to perform a regular expression match on a stream. Regular
+expressions need to look ahead. With a stream it is hard to look ahead
+because the process generating the stream may not be finished. There is no
+way to know if the process has paused momentarily or is finished and
+waiting for you. <font color="#cc0000">Pexpect must implicitly always
+do a NON greedy match (minimal) at the end of a input {### already said
+this}.</font> </p>
+<p>Pexpect compiles all regular expressions with the DOTALL flag. With
+the DOTALL flag a "." will match a newline. See the Python <a
+ href="http://www.python.org/doc/current/lib/node115.html#l2h-733">documentation</a></p>
+<h2>Beware of + and * at the end of input.</h2>
+<p>Remember that any time you try to match a pattern that needs
+look-ahead that you will always get a minimal match (non greedy). For
+example, the following will always return just one character:</p>
+<blockquote>
+  <p class="code">child.expect ('.+')</p>
+</blockquote>
+<p>This example will match successfully, but will always return no
+characters:</p>
+<blockquote>
+  <p class="code">child.expect ('.*')</p>
+</blockquote>
+<p>Generally any star * expression will match as little as possible</p>
+<p>One thing you can do is to try to force a non-ambiguous character at
+the end of your <span class="code">\d+</span> pattern. Expect that
+character to delimit the string. For example, you might try making thr
+end of your pattrn be <span class="code">\D+</span> instead of <span
+ class="code">\D*</span>. That means number digits alone would not
+satisfy the (<span class="code">\d+</span>) pattern. You would need
+some number(s) and at least one <span class="code">\D</span> at the
+end. </p>
+<h2>Matching groups</h2>
+<p>You can group regular expression using parenthesis. After a match,
+the <span class="code">match</span> parameter of the spawn object will
+contain the Python Match object. </p>
+<h2>Examples</h2>
+<p>Using "match" and groups...</p>
+<h2>Debugging</h2>
+<p>If you get the string value of a pexpect.spawn object you will get
+lots of useful debugging information. For debugging it's very useful to
+use the following pattern:</p>
+<p>try:<br>
+&nbsp;&nbsp;&nbsp; i = child.expect ([pattern1, pattern2, pattern3,
+etc])<br>
+except:<br>
+&nbsp;&nbsp;&nbsp; print "Exception was thrown"<br>
+&nbsp;&nbsp;&nbsp; print "debug information:"<br>
+&nbsp;&nbsp;&nbsp; print str(child)<br>
+</p>
+<p>It is also useful to log the child's input and out to a file or the
+screen. The following will turn on logging and send output to stdout
+(the screen).<br>
+</p>
+<p>&nbsp;&nbsp;&nbsp; child = pexpect.spawn (foo)<br>
+&nbsp;&nbsp;&nbsp; child.logfile = sys.stdout<br>
+<br>
+</p>
+<hr noshade="noshade" size="1">
+<h1>Exceptions</h1>
+<p><b>EOF</b></p>
+<p>Note that two flavors of EOF Exception may be thrown. They are
+virtually identical except for the message string. For practical
+purposes you should have no need to distinguish between them, but they
+do give a little extra information about what type of platform you are
+running. The two messages are:</p>
+<blockquote>
+  <p class="code">End Of File (EOF) in read(). Exception style platform.</p>
+  <p class="code">End Of File (EOF) in read(). Empty string style
+platform.</p>
+</blockquote>
+<p>Some UNIX platforms will throw an exception when you try to read
+from a file descriptor in the EOF state. Other UNIX platforms instead
+quietly return an empty string to indicate that the EOF state has been
+reached.</p>
+<p><b>Expecting EOF</b></p>
+<p>If you wish to read up to the end of the child's output without
+generating an <span class="code">EOF</span> exception then use the <span
+ class="code">expect(pexpect.EOF)</span> method.</p>
+<p><b>TIMEOUT</b></p>
+<p>The <span class="code">expect()</span> and <span class="code">read()</span>
+methods will also timeout if the child does not generate any output for
+a given amount of time. If this happens they will raise a <span
+ class="code">TIMEOUT</span> exception. You can have these method
+ignore a timeout and block indefinitely by passing None for the timeout
+parameter.</p>
+<blockquote>
+  <p class="code">child.expect(pexpect.EOF, timeout=None)</p>
+</blockquote>
+<hr noshade="noshade" size="1">
+<h1><a name="faq"></a>FAQ</h1>
+<p>This is not a real FAQ, since no one really asked me most of these
+questions. I just made them up. If anyone asks real questions then I
+will put them here.</p>
+<p><b>Q: Isn't there already a Python Expect?</b></p>
+<p>A: Yes, there are several of them. They usually require you to
+compile C. I wanted something that was pure Python and preferably a
+single module that was simple to install. I also wanted something that
+was easy to use. This pure Python expect only recently became possible
+with the introduction of the pty module in the standard Python library.
+Previously C extensions were required.</p>
+<p><strong>Q: The before and after properties sound weird.</strong></p>
+<p>Originally I was going to model Pexpect more after Expect, but then
+I found that I could never remember how to get the context of the stuff
+I was trying to parse. I hate having to read my own documentation. I
+decided that it was easier for me to remember what before and after
+was. It just so happens that this is how the -B and -A options in grep
+works, so that made it even easier for me to remember. Whatever makes
+my life easier is what's best.</p>
+<p><b>Q: Why not just use Expect?</b></p>
+<p>A: I love it. It's great. I has bailed me out of some real jams, but
+I wanted something that would do 90% of what I need from Expect; be 10%
+of the size; and allow me to write my code in Python instead of TCL.
+Pexpect is not nearly as big as Expect, but Pexpect does everything I
+have ever used Expect for.
+<!--:-P If I liked TCL then you wouldn't be reading this. My appologies to Don Libes -- Expect is cool, TK is cool, but TCL is only slightly better than Perl in my book. Hopefully after Expyct is done I will not need to use Expect anymore -- except for that lovely autoexpect tool. Damn, I wish I had that! --> </p>
+<p><b>Q: Why not just use a pipe (popen())?</b></p>
+<p>A: A pipe works fine for getting the output to non-interactive
+programs. If you just want to get the output from <span class="code">ls</span>,
+<span class="code">uname</span>, or <span class="code">ping</span>
+then this works. Pipes do not work very well for interactive programs
+and pipes will almost certainly fail for most applications that ask for
+passwords such as telnet, ftp, or ssh.</p>
+<p>There are two reasons for this. </p>
+<p>First an application may bypass stdout and print directly to its
+controlling TTY. Something like SSH will do this when it asks you for a
+password. This is why you cannot redirect the password prompt because
+it does not go through stdout or stderr.</p>
+<p>The second reason is because most applications are built using the C
+Standard IO Library (anything that uses <span class="code">#include
+&lt;stdio.h&gt;</span>). One of the features of the stdio library is
+that it buffers all input and output. Normally output is <b><i>line
+buffered</i></b> when a program is printing to a TTY (your terminal
+screen). Everytime the program prints a line-feed the currently
+buffered data will get printed to your screen. The problem comes when
+you connect a pipe. The stdio library is smart and can tell that it is
+printing to a pipe instead of a TTY. In that case it switches from line
+buffer mode to <i><b>block buffered</b></i>. In this mode the
+currently buffered data is flushed when the buffer is full. This causes
+most interactive programs to deadlock. Block buffering is more
+efficient when writing to disks and pipes. Take the situation where a
+program prints a message "Enter your user name:\n" and then waits for
+you type type something. In block buffered mode, the stdio library will
+not put the message into the pipe even though a linefeed is printed.
+The result is that you never receive the message, yet the child
+application will sit and wait for you to type a response. Don't confuse
+the stdio lib's buffer with the pipe's buffer. The pipe buffer is
+another area that can cause problems. You could flush the input side of
+a pipe, whereas you have no control over the stdio library buffer. </p>
+<p>More information: the Standard IO library has three states for a
+FILE *. These are: _IOFBF for block buffered; _IOLBF for line buffered;
+and _IONBF for unbuffered. The STDIO lib will use block buffering when
+talking to a block file descriptor such as a pipe. This is usually not
+helpful for interactive programs. Short of recompiling your program to
+include fflush() everywhere or recompiling a custom stdio library there
+is not much a controlling application can do about this if talking over
+a pipe.</p>
+<p> The program may have put data in its output that remains unflushed
+because the output buffer is not full; then the program will go and
+deadlock while waiting for input -- because you never send it any
+because you are still waiting for its output (still stuck in the
+STDIO's output buffer).</p>
+<p>The answer is to use a pseudo-tty. A TTY device will force <i><b>line</b></i>
+buffering (as opposed to block buffering). Line buffering means that
+you will get each line when the child program sends a line feed. This
+corresponds to the way most interactive programs operate -- send a line
+of output then wait for a line of input.</p>
+<p>I put "answer" in quotes because it's ugly solution and because
+there is no POSIX standard for pseudo-TTY devices (even though they
+have a TTY standard...). What would make more sense to me would be to
+have some way to set a mode on a file descriptor so that it will tell
+the STDIO to be line-buffered. I have investigated, and I don't think
+there is a way to set the buffered state of a child process. The STDIO
+Library does not maintain any external state in the kernel or whatnot,
+so I don't think there is any way for you to alter it. I'm not quite
+sure how this line-buffered/block-buffered state change happens
+internally in the STDIO library. I think the STDIO lib looks at the
+file descriptor and decides to change behavior based on whether it's a
+TTY or a block file (see isatty()).</p>
+<p>I hope that this qualifies as helpful.</p>
+<h1>Don't use a pipe to control another application...</h1>
+<p>Pexpect may seem similar to <span class="code">os.popen()</span> or
+<span class="code">commands</span> module. The main difference is that
+Pexpect (like Expect) uses a pseudo-TTY to talk to the child
+application. Most applications do no work well through the system()
+call or through pipes. And probably all applications that ask a user to
+type in a password will fail. These applications bypass the stdin and
+read directly from the TTY device. Many applications do not explicitly
+flush their output buffers. This causes deadlocks if you try to control
+an interactive application using a pipe. What happens is that most UNIX
+applications use the stdio (#include &lt;stdio.h&gt;) for input and
+output. The stdio library behaves differently depending on where the
+output is going. There is no way to control this behavior from the
+client end.<br>
+</p>
+<p><b>Q: Can I do screen scraping with this thing?</b></p>
+<p>A: That depends. If your application just does line-oriented output
+then this is easy. If it does screen-oriented output then it may work,
+but it could be hard. For example, trying to scrape data from the 'top'
+command would be hard. The top command repaints the text window. </p>
+<p>I am working on an ANSI / VT100 terminal emulator that will have
+methods to get characters from an arbitrary X,Y coordinate of the
+virtual screen. It works and you can play with it, but I have no
+working examples at this time.</p>
+<hr noshade="noshade" size="1">
+<h1><a name="bugs"></a>Bugs</h1>
+<h2>Threads</h2>
+<p>On Linux (RH 8) you cannot spawn a child from a different thread and
+pass the handle back to a worker thread. The child is successfully
+spawned but you can't interact with it. The only way to make it work is
+to spawn and interact with the child all in the same thread. [Adam
+Kerrison] </p>
+<h2><a name="echo_bug"></a>Timing issue with send() and sendline()</h2>
+<p>This problem has been addressed and should not effect most users.</p>
+<p>It is sometimes possible to read an echo of the string sent with <span
+ class="code">send()</span> and <span class="code">sendline()</span>.
+If you call <span class="code">sendline()</span> and then immediately
+call <span class="code">readline()</span> you may get part of your
+output echoed back. You may read back what you just wrote even if the
+child application does not explicitly echo it. Timing is critical. This
+could be a security issue when talking to an application that asks for
+a password; otherwise, this does not seem like a big deal. <i>But why
+do TTYs do this</i>?</p>
+<p>People usually report this when they are trying to control SSH or
+some other login. For example, if your code looks something like this: </p>
+<pre class="code">child.expect ('[pP]assword:')<br>child.sendline (my_password)</pre>
+<p><br>
+<blockquote>
+1. SSH prints "password:" prompt to the user.<br>
+2. SSH turns off echo on the TTY device.<br>
+3. SSH waits for user to enter a password.<br>
+</blockquote>
+When scripting with Pexpect what can happen is that Pexpect will response to the "password:" prompt
+before SSH has had time to turn off TTY echo. In other words, Pexpect sends the password between
+steps 1. and 2., so the password gets echoed back to the TTY. I would call this an SSH bug.
+</p>
+<p>
+Pexpect now automatically adds a short delay before sending data to a child process.
+This more closely mimics what happens in the usual human-to-app interaction.
+The delay can be tuned with the 'delaybeforesend' attribute of the spawn class.
+In general, this fixes the problem for everyone and so this should not be an issue
+for most users. For some applications you might with to turn it off.
+    child = pexpect.spawn ("ssh user at example.com")
+    child.delaybeforesend = 0
+</p>
+<p><br>
+</p>
+<p>Try changing it to look like the following. I know that this fix
+does not look correct, but it works. I have not figured out exactly
+what is happening. You would think that the sleep should be after the
+sendline(). The fact that the sleep helps when it's between the
+expect() and the sendline() must be a clue.</p>
+<pre class="code">child.expect ('[pP]assword:')<br>child.sendline (my_password)</pre>
+<h2>Timing issue with isalive()</h2>
+<p>Reading the state of isalive() immediately after a child exits may
+sometimes return 1. This is a race condition. The child has closed its
+file descriptor, but has not yet fully exited before Pexpect's
+isalive() executes. Addings a slight delay before the isalive() will
+help. In the following example <span class="code">isalive()</span>
+sometimes returns 1:</p>
+<blockquote>
+  <pre class="code">child = pexpect.spawn('ls')<br>child.expect(pexpect.EOF)<br>print child.isalive()</pre>
+</blockquote>
+<p>But if there is any delay before the call to <span class="code">isalive()</span>
+then it will always return 0 as expected.</p>
+<blockquote>
+  <pre class="code">child = pexpect.spawn('ls')<br>child.expect(pexpect.EOF)<br>time.sleep(0.1)<br>print child.isalive()</pre>
+</blockquote>
+<h2>Truncated output just before child exits</h2>
+<p><i>So far I have seen this only on older versions of <b>Apple's MacOS X</b>.</i>
+If the child application quits it may not flush its output buffer. This
+means that your Pexpect application will receive an EOF even though it
+should have received a little more data before the child died. This is
+not generally a problem when talking to interactive child applications.
+One example where it is a problem is when trying to read output from a
+program like '<span class="code">ls</span>'. You may receive most of
+the directory listing, but the last few lines will get lost before you
+receive an EOF. The reason for this is that '<span class="code">ls</span>'
+runs; completes its task; and then exits. The buffer is not flushed
+before exit so the last few lines are lost. The following example
+demonstrates the problem:</p>
+<p> </p>
+<blockquote>
+  <pre class="code">child = pexpect.spawn ('ls -l')<br>child.expect (pexpect.EOF)<br>print child.before <br>  </pre>
+</blockquote>
+<p></p>
+<h2>Controlling SSH on Solaris</h2>
+<p>Pexpect does not yet work perfectly on Solaris.
+One common problem is that SSH sometimes will not allow TTY password
+authentication. For example, you may expect SSH to ask you for a
+password using code like this:
+</p>
+<pre class="code">child = pexpect.spawn ('ssh user at example.com')<br>child.expect ('assword')<br>child.sendline ('mypassword')<br></pre>
+You may see the following error come back from a spawned
+child SSH:
+<p></p>
+<blockquote>Permission denied (publickey,keyboard-interactive). </blockquote>
+<p>
+This means that SSH thinks it can't access the TTY to ask you for your
+password.
+The only solution I have found is to use public key authentication with
+SSH.
+This bypasses the need for a password. I'm not happy with this
+solution.
+The problem is due to poor support for Solaris Pseudo TTYs in the
+Python
+Standard Library. </p>
+<hr noshade="noshade" size="1">
+<h1><a name="changes"></a>CHANGES</h1>
+<h2>Current Release</h2>
+<p>Fixed OSError exception when a pexpect object is cleaned up.
+Previously you might have seen this exception:</p>
+<blockquote>
+  <pre class="code">Exception exceptions.OSError: (10, 'No child processes') <br>in &lt;bound method spawn.__del__ of<br>&lt;pexpect.spawn instance at 0xd248c&gt;&gt; ignored</pre>
+</blockquote>
+<p>You should not see that anymore. Thanks to Michael Surette.</p>
+<p>Added support for buffering reads. This greatly improves speed when
+trying to match long output from a child process. When you create an
+instance of the spawn object you can then set a buffer size. For now
+you MUST do the following to turn on buffering -- it may be on by
+default in future version.</p>
+<blockquote>
+  <pre class="code">child = pexpect.spawn ('my_command')<br>child.maxread=1000 # Sets buffer to 1000 characters.</pre>
+</blockquote>
+<div>
+<p>I made a subtle change to the way TIMEOUT and EOF exceptions behave.
+Previously you could either expect these states in which case pexpect
+will not raise an exception, or you could just let pexpect raise an
+exception when these states were encountered. If you expected the
+states then the 'before' property was set to everything before the
+state was encountered, but if you let pexpect raise the exception then
+'before' was not set. Now the 'before' property will get set either way
+you choose to handle these states.</p>
+<h2><i>Older changes...</i></h2>
+<p>The spawn object now provides iterators for a <i>file-like interface</i>.
+This makes Pexpect a more complete file-like object. You can now write
+code like this:</p>
+<blockquote>
+  <pre class="code">child = pexpect.spawn ('ls -l')<br>for line in child:<br>    print line<br></pre>
+</blockquote>
+<p>I added the attribute <span class="code">exitstatus</span>. This
+will give the exit code returned by the child process. This will be set
+to <span class="code">None</span> while the child is still alive. When
+<span class="code">isalive()</span> returns 0 then <span class="code">exitstatus</span>
+will be set.</p>
+<p>I made a few more tweaks to <span class="code">isalive()</span> so
+that it will operate more consistently on different platforms. Solaris
+is the most difficult to support.</p>
+<p>&nbsp;</p>
+<p>You can now put <span class="code">TIMEOUT</span> in a list of
+expected patterns. This is just like putting <span class="code">EOF</span>
+in the pattern list. Expecting for a <span class="code">TIMEOUT</span>
+may not be used as often as <span class="code">EOF</span>, but this
+makes Pexpect more consitent.</p>
+<p>Thanks to a suggestion and sample code from Chad J. Schroeder I
+added the ability for Pexpect to operate on a file descriptor that is
+already open. This means that Pexpect can be used to control streams
+such as those from serial port devices. Now you just pass the integer
+file descriptor as the "command" when contsructing a spawn open. For
+example on a Linux box with a modem on ttyS1:</p>
+<blockquote>
+  <pre class="code">fd = os.open("/dev/ttyS1", os.O_RDWR|os.O_NONBLOCK|os.O_NOCTTY)<br>m = pexpect.spawn(fd) # Note integer fd is used instead of usual string.<br>m.send("+++") # Escape sequence<br>m.send("ATZ0\r") # Reset modem to profile 0<br>rval = m.expect(["OK", "ERROR"])</pre>
+</blockquote>
+<h3>Pexpect now tests itself on Compile Farm!</h3>
+<p>I wrote a nice script that uses ssh to connect to each machine on
+Source Forge's Compile Farm and then run the testall.py script for each
+platform. The result of the test is then recorded for each platform.
+Now it's easy to run regression tests across multiple platforms.</p>
+<h3>Pexpect is a file-like object</h3>
+<p>The spawn object now provides a <i>file-like interface</i>. It
+supports most of the methods and attributes defined for Python File
+Objects. </p>
+<p>I changed write and writelines() so that they no longer return a
+value. Use send() if you need that functionality. I did this to make
+the Spawn object more closely match a file-like object.</p>
+<p>read() was renamed to read_nonblocking(). I added a new read()
+method that matches file-like object interface. In general, you should
+not notice the difference except that read() no longer allows you to
+directly set the timeout value. I hope this will not effect any
+existing code. Switching to read_nonblocking() should fix existing code.</p>
+<p>I changed the name of <span class="code">set_echo()</span> to <span
+ class="code">setecho()</span>.</p>
+<p>I changed the name of <span class="code">send_eof()</span> to <span
+ class="code">sendeof()</span>.</p>
+<p>I modified <span class="code">kill()</span> so that it checks to
+make sure the pid isalive().</p>
+<p>I modified <span class="code">spawn()</span> (really called from <span
+ class="code">__spawn()</span>)so that it does not raise an expection
+if <span class="code">setwinsize()</span> fails. Some platforms such
+as Cygwin do not like setwinsize. This was a constant problem and since
+it is not a critical feature I decided to just silence the error.
+Normally I don't like to do that, but in this case I'm making an
+exception.</p>
+<p>Added a method <span class="code">close()</span> that does what you
+think. It closes the file descriptor of the child application. It makes
+no attempt to actually kill the child or wait for its status. </p>
+<p>Add variables <span class="code">__version__</span> and <span
+ class="code">__revision__</span> (from cvs) to the pexpect modules.
+This is mainly helpful to me so that I can make sure that I'm testing
+with the right version instead of one already installed.</p>
+<h3>Logging changes</h3>
+<blockquote>
+  <p><span class="code">log_open()</span> and <span class="code">log_close()</span>
+have been removed. Now use <span class="code">setlog()</span>. The <span
+ class="code">setlog()</span> method takes a file object. This is far
+more flexible than the previous log method. Each time data is written
+to the file object it will be flushed. To turn logging off simply call <span
+ class="code">setlog()</span> with None.</p>
+</blockquote>
+<h2>isalive changes</h2>
+<blockquote>
+  <p>I renamed the <span class="code">isAlive()</span> method to <span
+ class="code">isalive()</span> to match the more typical naming style
+in Python. Also the technique used to detect child process status has
+been drastically modified. Previously I did some funky stuff with
+signals which caused indigestion in other Python modules on some
+platforms. It's was a big headache. It still is, but I think it works
+better now.</p>
+</blockquote>
+<h3>attribute name changes</h3>
+<blockquote>
+  <p>The names of some attributes have been changed. This effects the
+names of the attributes that are set after called the <span
+ class="code">expect()</span> method.</p>
+  <table class="pymenu" border="0" cellpadding="5">
+    <tbody>
+      <tr>
+        <th class="pymenu">NEW NAME</th>
+        <th class="pymenu">OLD NAME</th>
+      </tr>
+      <tr>
+        <td><span class="code">before</span><br>
+        <i>Everything before the match.</i></td>
+        <td><span class="code">before</span></td>
+      </tr>
+      <tr>
+        <td><span class="code">after</span><br>
+        <i>Everything after and including the first character of the
+match</i></td>
+        <td><span class="code">matched</span></td>
+      </tr>
+      <tr>
+        <td><span class="code">match</span><br>
+        <i>This is the re MatchObject from the match.<br>
+You can get groups() from this.<br>
+See '<span class="code">uptime.py</span>' in the examples tar ball.</i></td>
+        <td><i>New -- Did not exist</i></td>
+      </tr>
+    </tbody>
+  </table>
+</blockquote>
+<h3>EOF changes</h3>
+<blockquote>
+  <p>The <span class="code">expect_eof()</span> method is gone. You
+can now simply use the <span class="code">expect()</span> method to
+look for EOF.</p>
+  <p>Was:</p>
+  <blockquote>
+    <p><span class="code">p.expect_eof ()</span></p>
+  </blockquote>
+  <p>Now:</p>
+  <blockquote>
+    <p><span class="code">p.expect (pexpect.EOF)</span></p>
+  </blockquote>
+</blockquote>
+<hr noshade="noshade" size="1">
+<h1><a name="testing"></a>TESTING</h1>
+<p>The following platforms have been tested:</p>
+<table class="pymenu" border="0" cellpadding="5">
+  <tbody>
+    <tr>
+      <th class="pymenu">PLATFORM</th>
+      <th class="pymenu">RESULTS</th>
+    </tr>
+    <tr>
+      <td>Linux 2.4.9-ac10-rmk2-np1-cerf2<br>
+armv4l</td>
+      <td><b><i>all tests passed</i></b></td>
+    </tr>
+    <tr>
+      <td>Linux 2.4.18 #2<br>
+sparc64</td>
+      <td><b><i>all tests passed</i></b></td>
+    </tr>
+    <tr>
+      <td>MacOS X Darwin Kernel Version 5.5<br>
+powerpc</td>
+      <td>
+      <p>failed more than one test.</p>
+      <p>Generally Pexpect works on OS X, but the nature of the quirks
+cause a many of the tests to fail. See <a href="#bugs">bugs</a>
+(Incomplete Child Output). The problem is more than minor, but Pexpect
+is still more than useful for most tasks. The problem is an edge case.</p>
+      </td>
+    </tr>
+    <tr>
+      <td>Linux 2.2.20<br>
+alpha<br>
+      </td>
+      <td><b><i>all tests passed</i></b></td>
+    </tr>
+    <tr>
+      <td>Linux 2.4.18-5smp<br>
+i686</td>
+      <td><b><i>all tests passed</i></b></td>
+    </tr>
+    <tr>
+      <td>OpenBSD 2.9 GENERIC#653<br>
+i386</td>
+      <td><b><i>all tests passed</i></b></td>
+    </tr>
+    <tr>
+      <td>Solaris</td>
+      <td>
+      <p>failed <span class="code">test_destructor</span></p>
+      <p>Otherwise, this is working pretty well. The destructor problem
+is minor. For some reason, the <i>second</i> time a pty file
+descriptor is created and deleted it never gets returned for use. It
+does not effect the first time or the third time or any time after
+that. It's only the second time. This is weird... This could be a file
+descriptor leak, or it could be some peculiarity of how Solaris
+recycles them. I thought it was a UNIX requirement for the OS to give
+you the lowest available filedescriptor number. In any case, this
+should not be a problem unless you create hundreds of pexpect
+instances... It may also be a pty module bug. </p>
+      </td>
+    </tr>
+    <tr>
+      <td>Windows XP Cygwin</td>
+      <td>failed <span class="code">test_destructor</span>. That it
+works at all is amazing to me. Cygwin rules!</td>
+    </tr>
+  </tbody>
+</table>
+<h1>&nbsp;</h1>
+<h1><a name="todo">TO DO</a></h1>
+<p>Add an option to add a delay after each expect() or before each
+read()/readline() call to automatically avoid the <a href="#echo_bug">echo
+bug</a>.</p>
+<p>&nbsp;</p>
+</div>
+<hr noshade="noshade" size="1">
+<table border="0">
+  <tbody>
+    <tr>
+      <td> <a href="http://www.noah.org/email/"><img src="email.png"
+ alt="Click to send email." border="0" height="16" width="100"></a> </td>
+    </tr>
+  </tbody>
+</table>
+</div>
+<div id="Menu"><b>INDEX</b><br>
+<hr noshade="noshade" size="1"> <a href="#license"
+ title="Python Software Foundation License">License</a><br>
+<a href="#download" title="Download and setup instructions">Download</a><br>
+<a href="#doc" title="Documentation and overview">Documentation</a><br>
+<a href="#status" title="Project Status">Project Status</a><br>
+<a href="#requirements" title="System requirements to use Pexpect">Requirements</a><br>
+<a href="#overview" title="Overview of what Pexpect does">Overview</a><br>
+<a href="#faq" title="FAQ">FAQ</a><br>
+<a href="#bugs" title="Bugs and work-arounds">Known Bugs</a><br>
+<a href="#changes" title="What's new with Pexpect">Recent Changes</a><br>
+<a href="#testing" title="Test results on various platforms">Testing</a><br>
+<a href="#todo" title="What to do next">To do</a><br>
+<a href="http://svn.sourceforge.net/viewcvs.cgi/pexpect/trunk/pexpect/" title="browse SVN">Browse SVN</a><br>
+<br>
+<a href="http://sourceforge.net/projects/pexpect/"
+ title="The Pexpect project page on SourceForge.net"> <img
+ src="http://sourceforge.net/sflogo.php?group_id=59762&amp;type=5"
+ alt="The Pexpect project page on SourceForge.net" border="0"
+ height="31" width="105"> </a> </div>
+</body>
+</html>

Added: packages/pexpect/branches/upstream/current/doc/pexpect.html
URL: http://svn.debian.org/wsvn/python-modules/packages/pexpect/branches/upstream/current/doc/pexpect.html?rev=929&op=file
==============================================================================
--- packages/pexpect/branches/upstream/current/doc/pexpect.html (added)
+++ packages/pexpect/branches/upstream/current/doc/pexpect.html Mon Jun 19 10:53:24 2006
@@ -1,0 +1,653 @@
+
+<!doctype html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html><head><title>Python: module pexpect</title>
+</head><body bgcolor="#f0f0f8">
+
+<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
+<tr bgcolor="#7799ee">
+<td valign=bottom>&nbsp;<br>
+<font color="#ffffff" face="helvetica, arial">&nbsp;<br><big><big><strong>pexpect</strong></big></big> (version 2.1)</font></td
+><td align=right valign=bottom
+><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/noah/documents/export/engineering/source/python/pexpect/trunk/pexpect/pexpect.py">/home/noah/documents/export/engineering/source/python/pexpect/trunk/pexpect/pexpect.py</a></font></td></tr></table>
+    <p><tt>Pexpect&nbsp;is&nbsp;a&nbsp;Python&nbsp;module&nbsp;for&nbsp;spawning&nbsp;child&nbsp;applications&nbsp;and&nbsp;controlling<br>
+them&nbsp;automatically.&nbsp;Pexpect&nbsp;can&nbsp;be&nbsp;used&nbsp;for&nbsp;automating&nbsp;interactive&nbsp;applications<br>
+such&nbsp;as&nbsp;ssh,&nbsp;ftp,&nbsp;passwd,&nbsp;telnet,&nbsp;etc.&nbsp;It&nbsp;can&nbsp;be&nbsp;used&nbsp;to&nbsp;a&nbsp;automate&nbsp;setup<br>
+scripts&nbsp;for&nbsp;duplicating&nbsp;software&nbsp;package&nbsp;installations&nbsp;on&nbsp;different&nbsp;servers.&nbsp;It<br>
+can&nbsp;be&nbsp;used&nbsp;for&nbsp;automated&nbsp;software&nbsp;testing.&nbsp;Pexpect&nbsp;is&nbsp;in&nbsp;the&nbsp;spirit&nbsp;of&nbsp;Don<br>
+Libes'&nbsp;Expect,&nbsp;but&nbsp;Pexpect&nbsp;is&nbsp;pure&nbsp;Python.&nbsp;Other&nbsp;Expect-like&nbsp;modules&nbsp;for&nbsp;Python<br>
+require&nbsp;TCL&nbsp;and&nbsp;Expect&nbsp;or&nbsp;require&nbsp;C&nbsp;extensions&nbsp;to&nbsp;be&nbsp;compiled.&nbsp;Pexpect&nbsp;does&nbsp;not<br>
+use&nbsp;C,&nbsp;Expect,&nbsp;or&nbsp;TCL&nbsp;extensions.&nbsp;It&nbsp;should&nbsp;work&nbsp;on&nbsp;any&nbsp;platform&nbsp;that&nbsp;supports<br>
+the&nbsp;standard&nbsp;Python&nbsp;pty&nbsp;module.&nbsp;The&nbsp;Pexpect&nbsp;interface&nbsp;focuses&nbsp;on&nbsp;ease&nbsp;of&nbsp;use&nbsp;so<br>
+that&nbsp;simple&nbsp;tasks&nbsp;are&nbsp;easy.<br>
+&nbsp;<br>
+There&nbsp;are&nbsp;two&nbsp;main&nbsp;interfaces&nbsp;to&nbsp;Pexpect&nbsp;--&nbsp;the&nbsp;function,&nbsp;<a href="#-run">run</a>()&nbsp;and&nbsp;the&nbsp;class,<br>
+<a href="#spawn">spawn</a>.&nbsp;You&nbsp;can&nbsp;call&nbsp;the&nbsp;<a href="#-run">run</a>()&nbsp;function&nbsp;to&nbsp;execute&nbsp;a&nbsp;command&nbsp;and&nbsp;return&nbsp;the<br>
+output.&nbsp;This&nbsp;is&nbsp;a&nbsp;handy&nbsp;replacement&nbsp;for&nbsp;os.system().<br>
+&nbsp;<br>
+For&nbsp;example:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;pexpect.<a href="#-run">run</a>('ls&nbsp;-la')<br>
+&nbsp;<br>
+The&nbsp;more&nbsp;powerful&nbsp;interface&nbsp;is&nbsp;the&nbsp;<a href="#spawn">spawn</a>&nbsp;class.&nbsp;You&nbsp;can&nbsp;use&nbsp;this&nbsp;to&nbsp;<a href="#spawn">spawn</a>&nbsp;an<br>
+external&nbsp;child&nbsp;command&nbsp;and&nbsp;then&nbsp;interact&nbsp;with&nbsp;the&nbsp;child&nbsp;by&nbsp;sending&nbsp;lines&nbsp;and<br>
+expecting&nbsp;responses.<br>
+&nbsp;<br>
+For&nbsp;example:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;child&nbsp;=&nbsp;pexpect.<a href="#spawn">spawn</a>('scp&nbsp;foo&nbsp;myname at host.example.com:.')<br>
+&nbsp;&nbsp;&nbsp;&nbsp;child.expect&nbsp;('Password:')<br>
+&nbsp;&nbsp;&nbsp;&nbsp;child.sendline&nbsp;(mypassword)<br>
+&nbsp;<br>
+This&nbsp;works&nbsp;even&nbsp;for&nbsp;commands&nbsp;that&nbsp;ask&nbsp;for&nbsp;passwords&nbsp;or&nbsp;other&nbsp;input&nbsp;outside&nbsp;of<br>
+the&nbsp;normal&nbsp;stdio&nbsp;streams.<br>
+&nbsp;<br>
+Credits:<br>
+Noah&nbsp;Spurrier,&nbsp;Richard&nbsp;Holden,&nbsp;Marco&nbsp;Molteni,&nbsp;Kimberley&nbsp;Burchett,&nbsp;Robert&nbsp;Stone,<br>
+Hartmut&nbsp;Goebel,&nbsp;Chad&nbsp;Schroeder,&nbsp;Erick&nbsp;Tryzelaar,&nbsp;Dave&nbsp;Kirby,&nbsp;Ids&nbsp;vander&nbsp;Molen,<br>
+George&nbsp;Todd,&nbsp;Noel&nbsp;Taylor,&nbsp;Nicolas&nbsp;D.&nbsp;Cesar,&nbsp;Alexander&nbsp;Gattin,<br>
+Geoffrey&nbsp;Marshall,&nbsp;Francisco&nbsp;Lourenco,&nbsp;Glen&nbsp;Mabey,&nbsp;Karthik&nbsp;Gurusamy,<br>
+Fernando&nbsp;Perez&nbsp;<br>
+(Let&nbsp;me&nbsp;know&nbsp;if&nbsp;I&nbsp;forgot&nbsp;anyone.)<br>
+&nbsp;<br>
+Free,&nbsp;open&nbsp;source,&nbsp;and&nbsp;all&nbsp;that&nbsp;good&nbsp;stuff.<br>
+&nbsp;<br>
+Permission&nbsp;is&nbsp;hereby&nbsp;granted,&nbsp;free&nbsp;of&nbsp;charge,&nbsp;to&nbsp;any&nbsp;person&nbsp;obtaining&nbsp;a&nbsp;copy&nbsp;of<br>
+this&nbsp;software&nbsp;and&nbsp;associated&nbsp;documentation&nbsp;files&nbsp;(the&nbsp;"Software"),&nbsp;to&nbsp;deal&nbsp;in<br>
+the&nbsp;Software&nbsp;without&nbsp;restriction,&nbsp;including&nbsp;without&nbsp;limitation&nbsp;the&nbsp;rights&nbsp;to<br>
+use,&nbsp;copy,&nbsp;modify,&nbsp;merge,&nbsp;publish,&nbsp;distribute,&nbsp;sublicense,&nbsp;and/or&nbsp;sell&nbsp;copies<br>
+of&nbsp;the&nbsp;Software,&nbsp;and&nbsp;to&nbsp;permit&nbsp;persons&nbsp;to&nbsp;whom&nbsp;the&nbsp;Software&nbsp;is&nbsp;furnished&nbsp;to&nbsp;do<br>
+so,&nbsp;subject&nbsp;to&nbsp;the&nbsp;following&nbsp;conditions:<br>
+&nbsp;<br>
+The&nbsp;above&nbsp;copyright&nbsp;notice&nbsp;and&nbsp;this&nbsp;permission&nbsp;notice&nbsp;shall&nbsp;be&nbsp;included&nbsp;in&nbsp;all<br>
+copies&nbsp;or&nbsp;substantial&nbsp;portions&nbsp;of&nbsp;the&nbsp;Software.<br>
+&nbsp;<br>
+THE&nbsp;SOFTWARE&nbsp;IS&nbsp;PROVIDED&nbsp;"AS&nbsp;IS",&nbsp;WITHOUT&nbsp;WARRANTY&nbsp;OF&nbsp;ANY&nbsp;KIND,&nbsp;EXPRESS&nbsp;OR<br>
+IMPLIED,&nbsp;INCLUDING&nbsp;BUT&nbsp;NOT&nbsp;LIMITED&nbsp;TO&nbsp;THE&nbsp;WARRANTIES&nbsp;OF&nbsp;MERCHANTABILITY,<br>
+FITNESS&nbsp;FOR&nbsp;A&nbsp;PARTICULAR&nbsp;PURPOSE&nbsp;AND&nbsp;NONINFRINGEMENT.&nbsp;IN&nbsp;NO&nbsp;EVENT&nbsp;SHALL&nbsp;THE<br>
+AUTHORS&nbsp;OR&nbsp;COPYRIGHT&nbsp;HOLDERS&nbsp;BE&nbsp;LIABLE&nbsp;FOR&nbsp;ANY&nbsp;CLAIM,&nbsp;DAMAGES&nbsp;OR&nbsp;OTHER<br>
+LIABILITY,&nbsp;WHETHER&nbsp;IN&nbsp;AN&nbsp;ACTION&nbsp;OF&nbsp;CONTRACT,&nbsp;TORT&nbsp;OR&nbsp;OTHERWISE,&nbsp;ARISING&nbsp;FROM,<br>
+OUT&nbsp;OF&nbsp;OR&nbsp;IN&nbsp;CONNECTION&nbsp;WITH&nbsp;THE&nbsp;SOFTWARE&nbsp;OR&nbsp;THE&nbsp;USE&nbsp;OR&nbsp;OTHER&nbsp;DEALINGS&nbsp;IN&nbsp;THE<br>
+SOFTWARE.<br>
+&nbsp;<br>
+Pexpect&nbsp;Copyright&nbsp;(c)&nbsp;2006&nbsp;Noah&nbsp;Spurrier<br>
+<a href="http://pexpect.sourceforge.net/">http://pexpect.sourceforge.net/</a><br>
+&nbsp;<br>
+$Revision:&nbsp;395&nbsp;$<br>
+$Date:&nbsp;2006-05-31&nbsp;20:07:18&nbsp;-0700&nbsp;(Wed,&nbsp;31&nbsp;May&nbsp;2006)&nbsp;$</tt></p>
+<p>
+<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
+<tr bgcolor="#aa55cc">
+<td colspan=3 valign=bottom>&nbsp;<br>
+<font color="#fffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
+    
+<tr><td bgcolor="#aa55cc"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
+<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="errno.html">errno</a><br>
+<a href="fcntl.html">fcntl</a><br>
+<a href="os.html">os</a><br>
+<a href="pty.html">pty</a><br>
+</td><td width="25%" valign=top><a href="re.html">re</a><br>
+<a href="resource.html">resource</a><br>
+<a href="select.html">select</a><br>
+<a href="signal.html">signal</a><br>
+</td><td width="25%" valign=top><a href="string.html">string</a><br>
+<a href="struct.html">struct</a><br>
+<a href="sys.html">sys</a><br>
+<a href="termios.html">termios</a><br>
+</td><td width="25%" valign=top><a href="time.html">time</a><br>
+<a href="traceback.html">traceback</a><br>
+<a href="tty.html">tty</a><br>
+<a href="types.html">types</a><br>
+</td></tr></table></td></tr></table><p>
+<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
+<tr bgcolor="#ee77aa">
+<td colspan=3 valign=bottom>&nbsp;<br>
+<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
+    
+<tr><td bgcolor="#ee77aa"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
+<td width="100%"><dl>
+<dt><font face="helvetica, arial"><a href="__builtin__.html#object">__builtin__.object</a>
+</font></dt><dd>
+<dl>
+<dt><font face="helvetica, arial"><a href="pexpect.html#spawn">spawn</a>
+</font></dt></dl>
+</dd>
+<dt><font face="helvetica, arial"><a href="exceptions.html#Exception">exceptions.Exception</a>
+</font></dt><dd>
+<dl>
+<dt><font face="helvetica, arial"><a href="pexpect.html#ExceptionPexpect">ExceptionPexpect</a>
+</font></dt><dd>
+<dl>
+<dt><font face="helvetica, arial"><a href="pexpect.html#EOF">EOF</a>
+</font></dt><dt><font face="helvetica, arial"><a href="pexpect.html#TIMEOUT">TIMEOUT</a>
+</font></dt></dl>
+</dd>
+</dl>
+</dd>
+</dl>
+ <p>
+<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
+<tr bgcolor="#ffc8d8">
+<td colspan=3 valign=bottom>&nbsp;<br>
+<font color="#000000" face="helvetica, arial"><a name="EOF">class <strong>EOF</strong></a>(<a href="pexpect.html#ExceptionPexpect">ExceptionPexpect</a>)</font></td></tr>
+    
+<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
+<td colspan=2><tt>Raised&nbsp;when&nbsp;<a href="#EOF">EOF</a>&nbsp;is&nbsp;read&nbsp;from&nbsp;a&nbsp;child.<br>&nbsp;</tt></td></tr>
+<tr><td>&nbsp;</td>
+<td width="100%"><dl><dt>Method resolution order:</dt>
+<dd><a href="pexpect.html#EOF">EOF</a></dd>
+<dd><a href="pexpect.html#ExceptionPexpect">ExceptionPexpect</a></dd>
+<dd><a href="exceptions.html#Exception">exceptions.Exception</a></dd>
+</dl>
+<hr>
+Methods inherited from <a href="pexpect.html#ExceptionPexpect">ExceptionPexpect</a>:<br>
+<dl><dt><a name="EOF-__init__"><strong>__init__</strong></a>(self, value)</dt></dl>
+
+<dl><dt><a name="EOF-__str__"><strong>__str__</strong></a>(self)</dt></dl>
+
+<dl><dt><a name="EOF-get_trace"><strong>get_trace</strong></a>(self)</dt><dd><tt>This&nbsp;returns&nbsp;an&nbsp;abbreviated&nbsp;stack&nbsp;trace&nbsp;with&nbsp;lines&nbsp;that&nbsp;only&nbsp;concern&nbsp;the&nbsp;caller.<br>
+In&nbsp;other&nbsp;words,&nbsp;the&nbsp;stack&nbsp;trace&nbsp;inside&nbsp;the&nbsp;Pexpect&nbsp;module&nbsp;is&nbsp;not&nbsp;included.</tt></dd></dl>
+
+<hr>
+Methods inherited from <a href="exceptions.html#Exception">exceptions.Exception</a>:<br>
+<dl><dt><a name="EOF-__getitem__"><strong>__getitem__</strong></a>(...)</dt></dl>
+
+</td></tr></table> <p>
+<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
+<tr bgcolor="#ffc8d8">
+<td colspan=3 valign=bottom>&nbsp;<br>
+<font color="#000000" face="helvetica, arial"><a name="ExceptionPexpect">class <strong>ExceptionPexpect</strong></a>(<a href="exceptions.html#Exception">exceptions.Exception</a>)</font></td></tr>
+    
+<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
+<td colspan=2><tt>Base&nbsp;class&nbsp;for&nbsp;all&nbsp;exceptions&nbsp;raised&nbsp;by&nbsp;this&nbsp;module.<br>&nbsp;</tt></td></tr>
+<tr><td>&nbsp;</td>
+<td width="100%">Methods defined here:<br>
+<dl><dt><a name="ExceptionPexpect-__init__"><strong>__init__</strong></a>(self, value)</dt></dl>
+
+<dl><dt><a name="ExceptionPexpect-__str__"><strong>__str__</strong></a>(self)</dt></dl>
+
+<dl><dt><a name="ExceptionPexpect-get_trace"><strong>get_trace</strong></a>(self)</dt><dd><tt>This&nbsp;returns&nbsp;an&nbsp;abbreviated&nbsp;stack&nbsp;trace&nbsp;with&nbsp;lines&nbsp;that&nbsp;only&nbsp;concern&nbsp;the&nbsp;caller.<br>
+In&nbsp;other&nbsp;words,&nbsp;the&nbsp;stack&nbsp;trace&nbsp;inside&nbsp;the&nbsp;Pexpect&nbsp;module&nbsp;is&nbsp;not&nbsp;included.</tt></dd></dl>
+
+<hr>
+Methods inherited from <a href="exceptions.html#Exception">exceptions.Exception</a>:<br>
+<dl><dt><a name="ExceptionPexpect-__getitem__"><strong>__getitem__</strong></a>(...)</dt></dl>
+
+</td></tr></table> <p>
+<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
+<tr bgcolor="#ffc8d8">
+<td colspan=3 valign=bottom>&nbsp;<br>
+<font color="#000000" face="helvetica, arial"><a name="TIMEOUT">class <strong>TIMEOUT</strong></a>(<a href="pexpect.html#ExceptionPexpect">ExceptionPexpect</a>)</font></td></tr>
+    
+<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
+<td colspan=2><tt>Raised&nbsp;when&nbsp;a&nbsp;read&nbsp;time&nbsp;exceeds&nbsp;the&nbsp;timeout.<br>&nbsp;</tt></td></tr>
+<tr><td>&nbsp;</td>
+<td width="100%"><dl><dt>Method resolution order:</dt>
+<dd><a href="pexpect.html#TIMEOUT">TIMEOUT</a></dd>
+<dd><a href="pexpect.html#ExceptionPexpect">ExceptionPexpect</a></dd>
+<dd><a href="exceptions.html#Exception">exceptions.Exception</a></dd>
+</dl>
+<hr>
+Methods inherited from <a href="pexpect.html#ExceptionPexpect">ExceptionPexpect</a>:<br>
+<dl><dt><a name="TIMEOUT-__init__"><strong>__init__</strong></a>(self, value)</dt></dl>
+
+<dl><dt><a name="TIMEOUT-__str__"><strong>__str__</strong></a>(self)</dt></dl>
+
+<dl><dt><a name="TIMEOUT-get_trace"><strong>get_trace</strong></a>(self)</dt><dd><tt>This&nbsp;returns&nbsp;an&nbsp;abbreviated&nbsp;stack&nbsp;trace&nbsp;with&nbsp;lines&nbsp;that&nbsp;only&nbsp;concern&nbsp;the&nbsp;caller.<br>
+In&nbsp;other&nbsp;words,&nbsp;the&nbsp;stack&nbsp;trace&nbsp;inside&nbsp;the&nbsp;Pexpect&nbsp;module&nbsp;is&nbsp;not&nbsp;included.</tt></dd></dl>
+
+<hr>
+Methods inherited from <a href="exceptions.html#Exception">exceptions.Exception</a>:<br>
+<dl><dt><a name="TIMEOUT-__getitem__"><strong>__getitem__</strong></a>(...)</dt></dl>
+
+</td></tr></table> <p>
+<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
+<tr bgcolor="#ffc8d8">
+<td colspan=3 valign=bottom>&nbsp;<br>
+<font color="#000000" face="helvetica, arial"><a name="spawn">class <strong>spawn</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr>
+    
+<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
+<td colspan=2><tt>This&nbsp;is&nbsp;the&nbsp;main&nbsp;class&nbsp;interface&nbsp;for&nbsp;Pexpect.<br>
+Use&nbsp;this&nbsp;class&nbsp;to&nbsp;start&nbsp;and&nbsp;control&nbsp;child&nbsp;applications.<br>&nbsp;</tt></td></tr>
+<tr><td>&nbsp;</td>
+<td width="100%">Methods defined here:<br>
+<dl><dt><a name="spawn-__del__"><strong>__del__</strong></a>(self)</dt><dd><tt>This&nbsp;makes&nbsp;sure&nbsp;that&nbsp;no&nbsp;system&nbsp;resources&nbsp;are&nbsp;left&nbsp;open.<br>
+Python&nbsp;only&nbsp;garbage&nbsp;collects&nbsp;Python&nbsp;objects.&nbsp;OS&nbsp;file&nbsp;descriptors<br>
+are&nbsp;not&nbsp;Python&nbsp;objects,&nbsp;so&nbsp;they&nbsp;must&nbsp;be&nbsp;handled&nbsp;explicitly.<br>
+If&nbsp;the&nbsp;child&nbsp;file&nbsp;descriptor&nbsp;was&nbsp;opened&nbsp;outside&nbsp;of&nbsp;this&nbsp;class<br>
+(passed&nbsp;to&nbsp;the&nbsp;constructor)&nbsp;then&nbsp;this&nbsp;does&nbsp;not&nbsp;close&nbsp;it.</tt></dd></dl>
+
+<dl><dt><a name="spawn-__init__"><strong>__init__</strong></a>(self, command, args<font color="#909090">=[]</font>, timeout<font color="#909090">=30</font>, maxread<font color="#909090">=2000</font>, searchwindowsize<font color="#909090">=None</font>, logfile<font color="#909090">=None</font>, env<font color="#909090">=None</font>)</dt><dd><tt>This&nbsp;is&nbsp;the&nbsp;constructor.&nbsp;The&nbsp;command&nbsp;parameter&nbsp;may&nbsp;be&nbsp;a&nbsp;string<br>
+that&nbsp;includes&nbsp;a&nbsp;command&nbsp;and&nbsp;any&nbsp;arguments&nbsp;to&nbsp;the&nbsp;command.&nbsp;For&nbsp;example:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p&nbsp;=&nbsp;pexpect.<a href="#spawn">spawn</a>&nbsp;('/usr/bin/ftp')<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p&nbsp;=&nbsp;pexpect.<a href="#spawn">spawn</a>&nbsp;('/usr/bin/ssh&nbsp;user at example.com')<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p&nbsp;=&nbsp;pexpect.<a href="#spawn">spawn</a>&nbsp;('ls&nbsp;-latr&nbsp;/tmp')<br>
+You&nbsp;may&nbsp;also&nbsp;construct&nbsp;it&nbsp;with&nbsp;a&nbsp;list&nbsp;of&nbsp;arguments&nbsp;like&nbsp;so:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p&nbsp;=&nbsp;pexpect.<a href="#spawn">spawn</a>&nbsp;('/usr/bin/ftp',&nbsp;[])<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p&nbsp;=&nbsp;pexpect.<a href="#spawn">spawn</a>&nbsp;('/usr/bin/ssh',&nbsp;['user at example.com'])<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p&nbsp;=&nbsp;pexpect.<a href="#spawn">spawn</a>&nbsp;('ls',&nbsp;['-latr',&nbsp;'/tmp'])<br>
+After&nbsp;this&nbsp;the&nbsp;child&nbsp;application&nbsp;will&nbsp;be&nbsp;created&nbsp;and<br>
+will&nbsp;be&nbsp;ready&nbsp;to&nbsp;talk&nbsp;to.&nbsp;For&nbsp;normal&nbsp;use,&nbsp;see&nbsp;<a href="#spawn-expect">expect</a>()&nbsp;and&nbsp;<br>
+<a href="#spawn-send">send</a>()&nbsp;and&nbsp;<a href="#spawn-sendline">sendline</a>().<br>
+&nbsp;<br>
+The&nbsp;maxread&nbsp;attribute&nbsp;sets&nbsp;the&nbsp;read&nbsp;buffer&nbsp;size.<br>
+This&nbsp;is&nbsp;maximum&nbsp;number&nbsp;of&nbsp;bytes&nbsp;that&nbsp;Pexpect&nbsp;will&nbsp;try&nbsp;to&nbsp;read<br>
+from&nbsp;a&nbsp;TTY&nbsp;at&nbsp;one&nbsp;time.<br>
+Seeting&nbsp;the&nbsp;maxread&nbsp;size&nbsp;to&nbsp;1&nbsp;will&nbsp;turn&nbsp;off&nbsp;buffering.<br>
+Setting&nbsp;the&nbsp;maxread&nbsp;value&nbsp;higher&nbsp;may&nbsp;help&nbsp;performance&nbsp;in&nbsp;cases<br>
+where&nbsp;large&nbsp;amounts&nbsp;of&nbsp;output&nbsp;are&nbsp;read&nbsp;back&nbsp;from&nbsp;the&nbsp;child.<br>
+This&nbsp;feature&nbsp;is&nbsp;useful&nbsp;in&nbsp;conjunction&nbsp;with&nbsp;searchwindowsize.<br>
+&nbsp;<br>
+The&nbsp;searchwindowsize&nbsp;attribute&nbsp;sets&nbsp;the&nbsp;how&nbsp;far&nbsp;back&nbsp;in<br>
+the&nbsp;incomming&nbsp;seach&nbsp;buffer&nbsp;Pexpect&nbsp;will&nbsp;search&nbsp;for&nbsp;pattern&nbsp;matches.<br>
+Every&nbsp;time&nbsp;Pexpect&nbsp;reads&nbsp;some&nbsp;data&nbsp;from&nbsp;the&nbsp;child&nbsp;it&nbsp;will&nbsp;append&nbsp;the&nbsp;data&nbsp;to<br>
+the&nbsp;incomming&nbsp;buffer.&nbsp;The&nbsp;default&nbsp;is&nbsp;to&nbsp;search&nbsp;from&nbsp;the&nbsp;beginning&nbsp;of&nbsp;the<br>
+imcomming&nbsp;buffer&nbsp;each&nbsp;time&nbsp;new&nbsp;data&nbsp;is&nbsp;read&nbsp;from&nbsp;the&nbsp;child.<br>
+But&nbsp;this&nbsp;is&nbsp;very&nbsp;inefficient&nbsp;if&nbsp;you&nbsp;are&nbsp;running&nbsp;a&nbsp;command&nbsp;that<br>
+generates&nbsp;a&nbsp;large&nbsp;amount&nbsp;of&nbsp;data&nbsp;where&nbsp;you&nbsp;want&nbsp;to&nbsp;match<br>
+The&nbsp;searchwindowsize&nbsp;does&nbsp;not&nbsp;effect&nbsp;the&nbsp;size&nbsp;of&nbsp;the&nbsp;incomming&nbsp;data&nbsp;buffer.<br>
+You&nbsp;will&nbsp;still&nbsp;have&nbsp;access&nbsp;to&nbsp;the&nbsp;full&nbsp;buffer&nbsp;after&nbsp;<a href="#spawn-expect">expect</a>()&nbsp;returns.<br>
+&nbsp;<br>
+The&nbsp;logfile&nbsp;member&nbsp;turns&nbsp;on&nbsp;or&nbsp;off&nbsp;logging.<br>
+All&nbsp;input&nbsp;and&nbsp;output&nbsp;will&nbsp;be&nbsp;copied&nbsp;to&nbsp;the&nbsp;given&nbsp;file&nbsp;<a href="__builtin__.html#object">object</a>.<br>
+Set&nbsp;logfile&nbsp;to&nbsp;None&nbsp;to&nbsp;stop&nbsp;logging.&nbsp;This&nbsp;is&nbsp;the&nbsp;default.<br>
+Set&nbsp;logfile&nbsp;to&nbsp;sys.stdout&nbsp;to&nbsp;echo&nbsp;everything&nbsp;to&nbsp;standard&nbsp;output.<br>
+The&nbsp;logfile&nbsp;is&nbsp;flushed&nbsp;after&nbsp;each&nbsp;write.<br>
+Example&nbsp;1:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;child&nbsp;=&nbsp;pexpect.<a href="#spawn">spawn</a>('some_command')<br>
+&nbsp;&nbsp;&nbsp;&nbsp;fout&nbsp;=&nbsp;file('mylog.txt','w')<br>
+&nbsp;&nbsp;&nbsp;&nbsp;child.logfile&nbsp;=&nbsp;fout<br>
+Example&nbsp;2:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;child&nbsp;=&nbsp;pexpect.<a href="#spawn">spawn</a>('some_command')<br>
+&nbsp;&nbsp;&nbsp;&nbsp;child.logfile&nbsp;=&nbsp;sys.stdout<br>
+&nbsp;&nbsp;&nbsp;&nbsp;<br>
+The&nbsp;delaybeforesend&nbsp;helps&nbsp;overcome&nbsp;a&nbsp;weird&nbsp;behavior&nbsp;that&nbsp;many&nbsp;users&nbsp;were&nbsp;experiencing.<br>
+The&nbsp;typical&nbsp;problem&nbsp;was&nbsp;that&nbsp;a&nbsp;user&nbsp;would&nbsp;<a href="#spawn-expect">expect</a>()&nbsp;a&nbsp;"Password:"&nbsp;prompt&nbsp;and<br>
+then&nbsp;immediately&nbsp;call&nbsp;<a href="#spawn-sendline">sendline</a>()&nbsp;to&nbsp;send&nbsp;the&nbsp;password.&nbsp;The&nbsp;user&nbsp;would&nbsp;then<br>
+see&nbsp;that&nbsp;their&nbsp;password&nbsp;was&nbsp;echoed&nbsp;back&nbsp;to&nbsp;them.&nbsp;Passwords&nbsp;don't<br>
+normally&nbsp;echo.&nbsp;The&nbsp;problem&nbsp;is&nbsp;caused&nbsp;by&nbsp;the&nbsp;fact&nbsp;that&nbsp;most&nbsp;applications<br>
+print&nbsp;out&nbsp;the&nbsp;"Password"&nbsp;prompt&nbsp;and&nbsp;then&nbsp;turn&nbsp;off&nbsp;stdin&nbsp;echo,&nbsp;but&nbsp;if&nbsp;you<br>
+send&nbsp;your&nbsp;password&nbsp;before&nbsp;the&nbsp;application&nbsp;turned&nbsp;off&nbsp;echo,&nbsp;then&nbsp;you&nbsp;get<br>
+your&nbsp;password&nbsp;echoed.&nbsp;Normally&nbsp;this&nbsp;wouldn't&nbsp;be&nbsp;a&nbsp;problem&nbsp;when&nbsp;interacting<br>
+with&nbsp;a&nbsp;human&nbsp;at&nbsp;a&nbsp;real&nbsp;heyboard.&nbsp;If&nbsp;you&nbsp;introduce&nbsp;a&nbsp;slight&nbsp;delay&nbsp;just&nbsp;before&nbsp;<br>
+writing&nbsp;then&nbsp;this&nbsp;seems&nbsp;to&nbsp;clear&nbsp;up&nbsp;the&nbsp;problem.&nbsp;This&nbsp;was&nbsp;such&nbsp;a&nbsp;common&nbsp;problem&nbsp;<br>
+for&nbsp;many&nbsp;users&nbsp;that&nbsp;I&nbsp;decided&nbsp;that&nbsp;the&nbsp;default&nbsp;pexpect&nbsp;behavior<br>
+should&nbsp;be&nbsp;to&nbsp;sleep&nbsp;just&nbsp;before&nbsp;writing&nbsp;to&nbsp;the&nbsp;child&nbsp;application.<br>
+1/10th&nbsp;of&nbsp;a&nbsp;second&nbsp;(100&nbsp;ms)&nbsp;seems&nbsp;to&nbsp;be&nbsp;enough&nbsp;to&nbsp;clear&nbsp;up&nbsp;the&nbsp;problem.<br>
+You&nbsp;can&nbsp;set&nbsp;delaybeforesend&nbsp;to&nbsp;0&nbsp;to&nbsp;return&nbsp;to&nbsp;the&nbsp;old&nbsp;behavior.<br>
+&nbsp;<br>
+Note&nbsp;that&nbsp;<a href="#spawn">spawn</a>&nbsp;is&nbsp;clever&nbsp;about&nbsp;finding&nbsp;commands&nbsp;on&nbsp;your&nbsp;path.<br>
+It&nbsp;uses&nbsp;the&nbsp;same&nbsp;logic&nbsp;that&nbsp;"which"&nbsp;uses&nbsp;to&nbsp;find&nbsp;executables.<br>
+&nbsp;<br>
+If&nbsp;you&nbsp;wish&nbsp;to&nbsp;get&nbsp;the&nbsp;exit&nbsp;status&nbsp;of&nbsp;the&nbsp;child&nbsp;you&nbsp;must&nbsp;call<br>
+the&nbsp;<a href="#spawn-close">close</a>()&nbsp;method.&nbsp;The&nbsp;exit&nbsp;or&nbsp;signal&nbsp;status&nbsp;of&nbsp;the&nbsp;child&nbsp;will&nbsp;be<br>
+stored&nbsp;in&nbsp;self.<strong>exitstatus</strong>&nbsp;or&nbsp;self.<strong>signalstatus</strong>.<br>
+If&nbsp;the&nbsp;child&nbsp;exited&nbsp;normally&nbsp;then&nbsp;exitstatus&nbsp;will&nbsp;store&nbsp;the&nbsp;exit&nbsp;return&nbsp;code&nbsp;and<br>
+signalstatus&nbsp;will&nbsp;be&nbsp;None.<br>
+If&nbsp;the&nbsp;child&nbsp;was&nbsp;terminated&nbsp;abnormally&nbsp;with&nbsp;a&nbsp;signal&nbsp;then&nbsp;signalstatus&nbsp;will&nbsp;store<br>
+the&nbsp;signal&nbsp;value&nbsp;and&nbsp;exitstatus&nbsp;will&nbsp;be&nbsp;None.<br>
+If&nbsp;you&nbsp;need&nbsp;more&nbsp;detail&nbsp;you&nbsp;can&nbsp;also&nbsp;read&nbsp;the&nbsp;self.<strong>status</strong>&nbsp;member&nbsp;which&nbsp;stores<br>
+the&nbsp;status&nbsp;returned&nbsp;by&nbsp;os.waitpid.&nbsp;You&nbsp;can&nbsp;interpret&nbsp;this&nbsp;using<br>
+os.WIFEXITED/os.WEXITSTATUS&nbsp;or&nbsp;os.WIFSIGNALED/os.TERMSIG.</tt></dd></dl>
+
+<dl><dt><a name="spawn-__iter__"><strong>__iter__</strong></a>(self)</dt><dd><tt>This&nbsp;is&nbsp;to&nbsp;support&nbsp;iterators&nbsp;over&nbsp;a&nbsp;file-like&nbsp;<a href="__builtin__.html#object">object</a>.</tt></dd></dl>
+
+<dl><dt><a name="spawn-__str__"><strong>__str__</strong></a>(self)</dt><dd><tt>This&nbsp;returns&nbsp;the&nbsp;current&nbsp;state&nbsp;of&nbsp;the&nbsp;pexpect&nbsp;<a href="__builtin__.html#object">object</a>&nbsp;as&nbsp;a&nbsp;string.</tt></dd></dl>
+
+<dl><dt><a name="spawn-close"><strong>close</strong></a>(self, force<font color="#909090">=True</font>)</dt><dd><tt>This&nbsp;closes&nbsp;the&nbsp;connection&nbsp;with&nbsp;the&nbsp;child&nbsp;application.<br>
+Note&nbsp;that&nbsp;calling&nbsp;<a href="#spawn-close">close</a>()&nbsp;more&nbsp;than&nbsp;once&nbsp;is&nbsp;valid.<br>
+This&nbsp;emulates&nbsp;standard&nbsp;Python&nbsp;behavior&nbsp;with&nbsp;files.<br>
+Set&nbsp;force&nbsp;to&nbsp;True&nbsp;if&nbsp;you&nbsp;want&nbsp;to&nbsp;make&nbsp;sure&nbsp;that&nbsp;the&nbsp;child&nbsp;is&nbsp;terminated<br>
+(SIGKILL&nbsp;is&nbsp;sent&nbsp;if&nbsp;the&nbsp;child&nbsp;ignores&nbsp;SIGHUP&nbsp;and&nbsp;SIGINT).</tt></dd></dl>
+
+<dl><dt><a name="spawn-compile_pattern_list"><strong>compile_pattern_list</strong></a>(self, patterns)</dt><dd><tt>This&nbsp;compiles&nbsp;a&nbsp;pattern-string&nbsp;or&nbsp;a&nbsp;list&nbsp;of&nbsp;pattern-strings.<br>
+Patterns&nbsp;must&nbsp;be&nbsp;a&nbsp;StringType,&nbsp;<a href="#EOF">EOF</a>,&nbsp;<a href="#TIMEOUT">TIMEOUT</a>,&nbsp;SRE_Pattern,&nbsp;or&nbsp;<br>
+a&nbsp;list&nbsp;of&nbsp;those.&nbsp;Patterns&nbsp;may&nbsp;also&nbsp;be&nbsp;None&nbsp;which&nbsp;results&nbsp;in<br>
+an&nbsp;empty&nbsp;list.<br>
+&nbsp;<br>
+This&nbsp;is&nbsp;used&nbsp;by&nbsp;<a href="#spawn-expect">expect</a>()&nbsp;when&nbsp;calling&nbsp;<a href="#spawn-expect_list">expect_list</a>().<br>
+Thus&nbsp;<a href="#spawn-expect">expect</a>()&nbsp;is&nbsp;nothing&nbsp;more&nbsp;than::<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cpl&nbsp;=&nbsp;<a href="#spawn-compile_pattern_list">compile_pattern_list</a>(pl)<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;<a href="#spawn-expect_list">expect_list</a>(clp,&nbsp;timeout)<br>
+&nbsp;<br>
+If&nbsp;you&nbsp;are&nbsp;using&nbsp;<a href="#spawn-expect">expect</a>()&nbsp;within&nbsp;a&nbsp;loop&nbsp;it&nbsp;may&nbsp;be&nbsp;more<br>
+efficient&nbsp;to&nbsp;compile&nbsp;the&nbsp;patterns&nbsp;first&nbsp;and&nbsp;then&nbsp;call&nbsp;<a href="#spawn-expect_list">expect_list</a>().<br>
+This&nbsp;avoid&nbsp;calls&nbsp;in&nbsp;a&nbsp;loop&nbsp;to&nbsp;<a href="#spawn-compile_pattern_list">compile_pattern_list</a>():<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cpl&nbsp;=&nbsp;<a href="#spawn-compile_pattern_list">compile_pattern_list</a>(my_pattern)<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;while&nbsp;some_condition:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;...<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;i&nbsp;=&nbsp;<a href="#spawn-expect_list">expect_list</a>(clp,&nbsp;timeout)<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;...</tt></dd></dl>
+
+<dl><dt><a name="spawn-eof"><strong>eof</strong></a>(self)</dt><dd><tt>This&nbsp;returns&nbsp;True&nbsp;if&nbsp;the&nbsp;<a href="#EOF">EOF</a>&nbsp;exception&nbsp;was&nbsp;ever&nbsp;raised.</tt></dd></dl>
+
+<dl><dt><a name="spawn-expect"><strong>expect</strong></a>(self, pattern, timeout<font color="#909090">=-1</font>, searchwindowsize<font color="#909090">=None</font>)</dt><dd><tt>This&nbsp;seeks&nbsp;through&nbsp;the&nbsp;stream&nbsp;until&nbsp;a&nbsp;pattern&nbsp;is&nbsp;matched.<br>
+The&nbsp;pattern&nbsp;is&nbsp;overloaded&nbsp;and&nbsp;may&nbsp;take&nbsp;several&nbsp;types&nbsp;including&nbsp;a&nbsp;list.<br>
+The&nbsp;pattern&nbsp;can&nbsp;be&nbsp;a&nbsp;StringType,&nbsp;<a href="#EOF">EOF</a>,&nbsp;a&nbsp;compiled&nbsp;re,&nbsp;or&nbsp;a&nbsp;list&nbsp;of<br>
+those&nbsp;types.&nbsp;Strings&nbsp;will&nbsp;be&nbsp;compiled&nbsp;to&nbsp;re&nbsp;types.&nbsp;This&nbsp;returns&nbsp;the<br>
+index&nbsp;into&nbsp;the&nbsp;pattern&nbsp;list.&nbsp;If&nbsp;the&nbsp;pattern&nbsp;was&nbsp;not&nbsp;a&nbsp;list&nbsp;this<br>
+returns&nbsp;index&nbsp;0&nbsp;on&nbsp;a&nbsp;successful&nbsp;match.&nbsp;This&nbsp;may&nbsp;raise&nbsp;exceptions&nbsp;for<br>
+<a href="#EOF">EOF</a>&nbsp;or&nbsp;<a href="#TIMEOUT">TIMEOUT</a>.&nbsp;To&nbsp;avoid&nbsp;the&nbsp;<a href="#EOF">EOF</a>&nbsp;or&nbsp;<a href="#TIMEOUT">TIMEOUT</a>&nbsp;exceptions&nbsp;add<br>
+<a href="#EOF">EOF</a>&nbsp;or&nbsp;<a href="#TIMEOUT">TIMEOUT</a>&nbsp;to&nbsp;the&nbsp;pattern&nbsp;list.<br>
+&nbsp;<br>
+After&nbsp;a&nbsp;match&nbsp;is&nbsp;found&nbsp;the&nbsp;instance&nbsp;attributes<br>
+'before',&nbsp;'after'&nbsp;and&nbsp;'match'&nbsp;will&nbsp;be&nbsp;set.<br>
+You&nbsp;can&nbsp;see&nbsp;all&nbsp;the&nbsp;data&nbsp;read&nbsp;before&nbsp;the&nbsp;match&nbsp;in&nbsp;'before'.<br>
+You&nbsp;can&nbsp;see&nbsp;the&nbsp;data&nbsp;that&nbsp;was&nbsp;matched&nbsp;in&nbsp;'after'.<br>
+The&nbsp;re.MatchObject&nbsp;used&nbsp;in&nbsp;the&nbsp;re&nbsp;match&nbsp;will&nbsp;be&nbsp;in&nbsp;'match'.<br>
+If&nbsp;an&nbsp;error&nbsp;occured&nbsp;then&nbsp;'before'&nbsp;will&nbsp;be&nbsp;set&nbsp;to&nbsp;all&nbsp;the<br>
+data&nbsp;read&nbsp;so&nbsp;far&nbsp;and&nbsp;'after'&nbsp;and&nbsp;'match'&nbsp;will&nbsp;be&nbsp;None.<br>
+&nbsp;<br>
+If&nbsp;timeout&nbsp;is&nbsp;-1&nbsp;then&nbsp;timeout&nbsp;will&nbsp;be&nbsp;set&nbsp;to&nbsp;the&nbsp;self.<strong>timeout</strong>&nbsp;value.<br>
+&nbsp;<br>
+Note:&nbsp;A&nbsp;list&nbsp;entry&nbsp;may&nbsp;be&nbsp;<a href="#EOF">EOF</a>&nbsp;or&nbsp;<a href="#TIMEOUT">TIMEOUT</a>&nbsp;instead&nbsp;of&nbsp;a&nbsp;string.<br>
+This&nbsp;will&nbsp;catch&nbsp;these&nbsp;exceptions&nbsp;and&nbsp;return&nbsp;the&nbsp;index<br>
+of&nbsp;the&nbsp;list&nbsp;entry&nbsp;instead&nbsp;of&nbsp;raising&nbsp;the&nbsp;exception.<br>
+The&nbsp;attribute&nbsp;'after'&nbsp;will&nbsp;be&nbsp;set&nbsp;to&nbsp;the&nbsp;exception&nbsp;type.<br>
+The&nbsp;attribute&nbsp;'match'&nbsp;will&nbsp;be&nbsp;None.<br>
+This&nbsp;allows&nbsp;you&nbsp;to&nbsp;write&nbsp;code&nbsp;like&nbsp;this:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;index&nbsp;=&nbsp;p.expect&nbsp;(['good',&nbsp;'bad',&nbsp;pexpect.<a href="#EOF">EOF</a>,&nbsp;pexpect.<a href="#TIMEOUT">TIMEOUT</a>])<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;index&nbsp;==&nbsp;0:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;do_something()<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;elif&nbsp;index&nbsp;==&nbsp;1:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;do_something_else()<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;elif&nbsp;index&nbsp;==&nbsp;2:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;do_some_other_thing()<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;elif&nbsp;index&nbsp;==&nbsp;3:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;do_something_completely_different()<br>
+instead&nbsp;of&nbsp;code&nbsp;like&nbsp;this:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;index&nbsp;=&nbsp;p.expect&nbsp;(['good',&nbsp;'bad'])<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;index&nbsp;==&nbsp;0:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;do_something()<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;elif&nbsp;index&nbsp;==&nbsp;1:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;do_something_else()<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;except&nbsp;<a href="#EOF">EOF</a>:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;do_some_other_thing()<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;except&nbsp;<a href="#TIMEOUT">TIMEOUT</a>:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;do_something_completely_different()<br>
+These&nbsp;two&nbsp;forms&nbsp;are&nbsp;equivalent.&nbsp;It&nbsp;all&nbsp;depends&nbsp;on&nbsp;what&nbsp;you&nbsp;want.<br>
+You&nbsp;can&nbsp;also&nbsp;just&nbsp;expect&nbsp;the&nbsp;<a href="#EOF">EOF</a>&nbsp;if&nbsp;you&nbsp;are&nbsp;waiting&nbsp;for&nbsp;all&nbsp;output<br>
+of&nbsp;a&nbsp;child&nbsp;to&nbsp;finish.&nbsp;For&nbsp;example:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p&nbsp;=&nbsp;pexpect.<a href="#spawn">spawn</a>('/bin/ls')<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p.expect&nbsp;(pexpect.<a href="#EOF">EOF</a>)<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print&nbsp;p.before<br>
+&nbsp;<br>
+If&nbsp;you&nbsp;are&nbsp;trying&nbsp;to&nbsp;optimize&nbsp;for&nbsp;speed&nbsp;then&nbsp;see&nbsp;<a href="#spawn-expect_list">expect_list</a>().</tt></dd></dl>
+
+<dl><dt><a name="spawn-expect_exact"><strong>expect_exact</strong></a>(self, pattern_list, timeout<font color="#909090">=-1</font>)</dt><dd><tt>This&nbsp;method&nbsp;is&nbsp;no&nbsp;longer&nbsp;supported&nbsp;or&nbsp;allowed.<br>
+It&nbsp;was&nbsp;too&nbsp;hard&nbsp;to&nbsp;maintain&nbsp;and&nbsp;keep&nbsp;it&nbsp;up&nbsp;to&nbsp;date&nbsp;with&nbsp;expect_list.<br>
+Few&nbsp;people&nbsp;used&nbsp;this&nbsp;method.&nbsp;Most&nbsp;people&nbsp;favored&nbsp;reliability&nbsp;over&nbsp;speed.<br>
+The&nbsp;implementation&nbsp;is&nbsp;left&nbsp;in&nbsp;comments&nbsp;in&nbsp;case&nbsp;anyone&nbsp;needs&nbsp;to&nbsp;hack&nbsp;this<br>
+feature&nbsp;back&nbsp;into&nbsp;their&nbsp;copy.<br>
+If&nbsp;someone&nbsp;wants&nbsp;to&nbsp;diff&nbsp;this&nbsp;with&nbsp;expect_list&nbsp;and&nbsp;make&nbsp;them&nbsp;work<br>
+nearly&nbsp;the&nbsp;same&nbsp;then&nbsp;I&nbsp;will&nbsp;consider&nbsp;adding&nbsp;this&nbsp;make&nbsp;in.</tt></dd></dl>
+
+<dl><dt><a name="spawn-expect_list"><strong>expect_list</strong></a>(self, pattern_list, timeout<font color="#909090">=-1</font>, searchwindowsize<font color="#909090">=-1</font>)</dt><dd><tt>This&nbsp;takes&nbsp;a&nbsp;list&nbsp;of&nbsp;compiled&nbsp;regular&nbsp;expressions&nbsp;and&nbsp;returns&nbsp;<br>
+the&nbsp;index&nbsp;into&nbsp;the&nbsp;pattern_list&nbsp;that&nbsp;matched&nbsp;the&nbsp;child&nbsp;output.<br>
+The&nbsp;list&nbsp;may&nbsp;also&nbsp;contain&nbsp;<a href="#EOF">EOF</a>&nbsp;or&nbsp;<a href="#TIMEOUT">TIMEOUT</a>&nbsp;(which&nbsp;are&nbsp;not<br>
+compiled&nbsp;regular&nbsp;expressions).&nbsp;This&nbsp;method&nbsp;is&nbsp;similar&nbsp;to<br>
+the&nbsp;<a href="#spawn-expect">expect</a>()&nbsp;method&nbsp;except&nbsp;that&nbsp;<a href="#spawn-expect_list">expect_list</a>()&nbsp;does&nbsp;not<br>
+recompile&nbsp;the&nbsp;pattern&nbsp;list&nbsp;on&nbsp;every&nbsp;call.<br>
+This&nbsp;may&nbsp;help&nbsp;if&nbsp;you&nbsp;are&nbsp;trying&nbsp;to&nbsp;optimize&nbsp;for&nbsp;speed,&nbsp;otherwise<br>
+just&nbsp;use&nbsp;the&nbsp;<a href="#spawn-expect">expect</a>()&nbsp;method.&nbsp;&nbsp;This&nbsp;is&nbsp;called&nbsp;by&nbsp;<a href="#spawn-expect">expect</a>().<br>
+If&nbsp;timeout==-1&nbsp;then&nbsp;the&nbsp;self.<strong>timeout</strong>&nbsp;value&nbsp;is&nbsp;used.<br>
+If&nbsp;searchwindowsize==-1&nbsp;then&nbsp;the&nbsp;self.<strong>searchwindowsize</strong>&nbsp;value&nbsp;is&nbsp;used.</tt></dd></dl>
+
+<dl><dt><a name="spawn-fileno"><strong>fileno</strong></a>(self)</dt><dd><tt>This&nbsp;returns&nbsp;the&nbsp;file&nbsp;descriptor&nbsp;of&nbsp;the&nbsp;pty&nbsp;for&nbsp;the&nbsp;child.</tt></dd></dl>
+
+<dl><dt><a name="spawn-flush"><strong>flush</strong></a>(self)</dt><dd><tt>This&nbsp;does&nbsp;nothing.&nbsp;It&nbsp;is&nbsp;here&nbsp;to&nbsp;support&nbsp;the&nbsp;interface&nbsp;for&nbsp;a&nbsp;File-like&nbsp;<a href="__builtin__.html#object">object</a>.</tt></dd></dl>
+
+<dl><dt><a name="spawn-getwinsize"><strong>getwinsize</strong></a>(self)</dt><dd><tt>This&nbsp;returns&nbsp;the&nbsp;terminal&nbsp;window&nbsp;size&nbsp;of&nbsp;the&nbsp;child&nbsp;tty.<br>
+The&nbsp;return&nbsp;value&nbsp;is&nbsp;a&nbsp;tuple&nbsp;of&nbsp;(rows,&nbsp;cols).</tt></dd></dl>
+
+<dl><dt><a name="spawn-interact"><strong>interact</strong></a>(self, escape_character<font color="#909090">='<font color="#c040c0">\x1d</font>'</font>, input_filter<font color="#909090">=None</font>, output_filter<font color="#909090">=None</font>)</dt><dd><tt>This&nbsp;gives&nbsp;control&nbsp;of&nbsp;the&nbsp;child&nbsp;process&nbsp;to&nbsp;the&nbsp;interactive&nbsp;user<br>
+(the&nbsp;human&nbsp;at&nbsp;the&nbsp;keyboard).<br>
+Keystrokes&nbsp;are&nbsp;sent&nbsp;to&nbsp;the&nbsp;child&nbsp;process,&nbsp;and&nbsp;the&nbsp;stdout&nbsp;and&nbsp;stderr<br>
+output&nbsp;of&nbsp;the&nbsp;child&nbsp;process&nbsp;is&nbsp;printed.<br>
+This&nbsp;simply&nbsp;echos&nbsp;the&nbsp;child&nbsp;stdout&nbsp;and&nbsp;child&nbsp;stderr&nbsp;to&nbsp;the&nbsp;real<br>
+stdout&nbsp;and&nbsp;it&nbsp;echos&nbsp;the&nbsp;real&nbsp;stdin&nbsp;to&nbsp;the&nbsp;child&nbsp;stdin.<br>
+When&nbsp;the&nbsp;user&nbsp;types&nbsp;the&nbsp;escape_character&nbsp;this&nbsp;method&nbsp;will&nbsp;stop.<br>
+The&nbsp;default&nbsp;for&nbsp;escape_character&nbsp;is&nbsp;^].&nbsp;This&nbsp;should&nbsp;not&nbsp;be&nbsp;confused<br>
+with&nbsp;ASCII&nbsp;27&nbsp;--&nbsp;the&nbsp;ESC&nbsp;character.&nbsp;ASCII&nbsp;29&nbsp;was&nbsp;chosen<br>
+for&nbsp;historical&nbsp;merit&nbsp;because&nbsp;this&nbsp;is&nbsp;the&nbsp;character&nbsp;used<br>
+by&nbsp;'telnet'&nbsp;as&nbsp;the&nbsp;escape&nbsp;character.&nbsp;The&nbsp;escape_character&nbsp;will<br>
+not&nbsp;be&nbsp;sent&nbsp;to&nbsp;the&nbsp;child&nbsp;process.<br>
+&nbsp;<br>
+You&nbsp;may&nbsp;pass&nbsp;in&nbsp;optional&nbsp;input&nbsp;and&nbsp;output&nbsp;filter&nbsp;functions.<br>
+These&nbsp;functions&nbsp;should&nbsp;take&nbsp;a&nbsp;string&nbsp;and&nbsp;return&nbsp;a&nbsp;string.<br>
+The&nbsp;output_filter&nbsp;will&nbsp;be&nbsp;passed&nbsp;all&nbsp;the&nbsp;output&nbsp;from&nbsp;the&nbsp;child&nbsp;process.<br>
+The&nbsp;input_filter&nbsp;will&nbsp;be&nbsp;passed&nbsp;all&nbsp;the&nbsp;keyboard&nbsp;input&nbsp;from&nbsp;the&nbsp;user.<br>
+The&nbsp;input_filter&nbsp;is&nbsp;run&nbsp;BEFORE&nbsp;the&nbsp;check&nbsp;for&nbsp;the&nbsp;escape_character.<br>
+&nbsp;<br>
+Note&nbsp;that&nbsp;if&nbsp;you&nbsp;change&nbsp;the&nbsp;window&nbsp;size&nbsp;of&nbsp;the&nbsp;parent<br>
+the&nbsp;SIGWINCH&nbsp;signal&nbsp;will&nbsp;not&nbsp;be&nbsp;passed&nbsp;through&nbsp;to&nbsp;the&nbsp;child.<br>
+If&nbsp;you&nbsp;want&nbsp;the&nbsp;child&nbsp;window&nbsp;size&nbsp;to&nbsp;change&nbsp;when&nbsp;the&nbsp;parent's<br>
+window&nbsp;size&nbsp;changes&nbsp;then&nbsp;do&nbsp;something&nbsp;like&nbsp;the&nbsp;following&nbsp;example:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;import&nbsp;pexpect,&nbsp;struct,&nbsp;fcntl,&nbsp;termios,&nbsp;signal,&nbsp;sys<br>
+&nbsp;&nbsp;&nbsp;&nbsp;def&nbsp;sigwinch_passthrough&nbsp;(sig,&nbsp;data):<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;s&nbsp;=&nbsp;struct.pack("HHHH",&nbsp;0,&nbsp;0,&nbsp;0,&nbsp;0)<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a&nbsp;=&nbsp;struct.unpack('hhhh',&nbsp;fcntl.ioctl(sys.stdout.<a href="#spawn-fileno">fileno</a>(),&nbsp;termios.TIOCGWINSZ&nbsp;,&nbsp;s))<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;global&nbsp;p<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p.<a href="#spawn-setwinsize">setwinsize</a>(a[0],a[1])<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p&nbsp;=&nbsp;pexpect.<a href="#spawn">spawn</a>('/bin/bash')&nbsp;#&nbsp;Note&nbsp;this&nbsp;is&nbsp;global&nbsp;and&nbsp;used&nbsp;in&nbsp;sigwinch_passthrough.<br>
+&nbsp;&nbsp;&nbsp;&nbsp;signal.signal(signal.SIGWINCH,&nbsp;sigwinch_passthrough)<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p.<a href="#spawn-interact">interact</a>()</tt></dd></dl>
+
+<dl><dt><a name="spawn-isalive"><strong>isalive</strong></a>(self)</dt><dd><tt>This&nbsp;tests&nbsp;if&nbsp;the&nbsp;child&nbsp;process&nbsp;is&nbsp;running&nbsp;or&nbsp;not.<br>
+This&nbsp;is&nbsp;non-blocking.&nbsp;If&nbsp;the&nbsp;child&nbsp;was&nbsp;terminated&nbsp;then&nbsp;this<br>
+will&nbsp;read&nbsp;the&nbsp;exitstatus&nbsp;or&nbsp;signalstatus&nbsp;of&nbsp;the&nbsp;child.<br>
+This&nbsp;returns&nbsp;True&nbsp;if&nbsp;the&nbsp;child&nbsp;process&nbsp;appears&nbsp;to&nbsp;be&nbsp;running&nbsp;or&nbsp;False&nbsp;if&nbsp;not.<br>
+It&nbsp;can&nbsp;take&nbsp;literally&nbsp;SECONDS&nbsp;for&nbsp;Solaris&nbsp;to&nbsp;return&nbsp;the&nbsp;right&nbsp;status.</tt></dd></dl>
+
+<dl><dt><a name="spawn-isatty"><strong>isatty</strong></a>(self)</dt><dd><tt>This&nbsp;returns&nbsp;True&nbsp;if&nbsp;the&nbsp;file&nbsp;descriptor&nbsp;is&nbsp;open&nbsp;and&nbsp;connected&nbsp;to&nbsp;a&nbsp;tty(-like)&nbsp;device,&nbsp;else&nbsp;False.</tt></dd></dl>
+
+<dl><dt><a name="spawn-kill"><strong>kill</strong></a>(self, sig)</dt><dd><tt>This&nbsp;sends&nbsp;the&nbsp;given&nbsp;signal&nbsp;to&nbsp;the&nbsp;child&nbsp;application.<br>
+In&nbsp;keeping&nbsp;with&nbsp;UNIX&nbsp;tradition&nbsp;it&nbsp;has&nbsp;a&nbsp;misleading&nbsp;name.<br>
+It&nbsp;does&nbsp;not&nbsp;necessarily&nbsp;kill&nbsp;the&nbsp;child&nbsp;unless<br>
+you&nbsp;send&nbsp;the&nbsp;right&nbsp;signal.</tt></dd></dl>
+
+<dl><dt><a name="spawn-next"><strong>next</strong></a>(self)</dt><dd><tt>This&nbsp;is&nbsp;to&nbsp;support&nbsp;iterators&nbsp;over&nbsp;a&nbsp;file-like&nbsp;<a href="__builtin__.html#object">object</a>.</tt></dd></dl>
+
+<dl><dt><a name="spawn-read"><strong>read</strong></a>(self, size<font color="#909090">=-1</font>)</dt><dd><tt>This&nbsp;reads&nbsp;at&nbsp;most&nbsp;"size"&nbsp;bytes&nbsp;from&nbsp;the&nbsp;file&nbsp;<br>
+(less&nbsp;if&nbsp;the&nbsp;read&nbsp;hits&nbsp;<a href="#EOF">EOF</a>&nbsp;before&nbsp;obtaining&nbsp;size&nbsp;bytes).&nbsp;<br>
+If&nbsp;the&nbsp;size&nbsp;argument&nbsp;is&nbsp;negative&nbsp;or&nbsp;omitted,&nbsp;<br>
+read&nbsp;all&nbsp;data&nbsp;until&nbsp;<a href="#EOF">EOF</a>&nbsp;is&nbsp;reached.&nbsp;<br>
+The&nbsp;bytes&nbsp;are&nbsp;returned&nbsp;as&nbsp;a&nbsp;string&nbsp;<a href="__builtin__.html#object">object</a>.&nbsp;<br>
+An&nbsp;empty&nbsp;string&nbsp;is&nbsp;returned&nbsp;when&nbsp;<a href="#EOF">EOF</a>&nbsp;is&nbsp;encountered&nbsp;immediately.</tt></dd></dl>
+
+<dl><dt><a name="spawn-read_nonblocking"><strong>read_nonblocking</strong></a>(self, size<font color="#909090">=1</font>, timeout<font color="#909090">=-1</font>)</dt><dd><tt>This&nbsp;reads&nbsp;at&nbsp;most&nbsp;size&nbsp;characters&nbsp;from&nbsp;the&nbsp;child&nbsp;application.<br>
+It&nbsp;includes&nbsp;a&nbsp;timeout.&nbsp;If&nbsp;the&nbsp;read&nbsp;does&nbsp;not&nbsp;complete&nbsp;within&nbsp;the<br>
+timeout&nbsp;period&nbsp;then&nbsp;a&nbsp;<a href="#TIMEOUT">TIMEOUT</a>&nbsp;exception&nbsp;is&nbsp;raised.<br>
+If&nbsp;the&nbsp;end&nbsp;of&nbsp;file&nbsp;is&nbsp;read&nbsp;then&nbsp;an&nbsp;<a href="#EOF">EOF</a>&nbsp;exception&nbsp;will&nbsp;be&nbsp;raised.<br>
+If&nbsp;a&nbsp;log&nbsp;file&nbsp;was&nbsp;set&nbsp;using&nbsp;<a href="#spawn-setlog">setlog</a>()&nbsp;then&nbsp;all&nbsp;data&nbsp;will<br>
+also&nbsp;be&nbsp;written&nbsp;to&nbsp;the&nbsp;log&nbsp;file.<br>
+&nbsp;<br>
+If&nbsp;timeout==None&nbsp;then&nbsp;the&nbsp;read&nbsp;may&nbsp;block&nbsp;indefinitely.<br>
+If&nbsp;timeout==-1&nbsp;then&nbsp;the&nbsp;self.<strong>timeout</strong>&nbsp;value&nbsp;is&nbsp;used.<br>
+If&nbsp;timeout==0&nbsp;then&nbsp;the&nbsp;child&nbsp;is&nbsp;polled&nbsp;and&nbsp;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;there&nbsp;was&nbsp;no&nbsp;data&nbsp;immediately&nbsp;ready&nbsp;then&nbsp;this&nbsp;will&nbsp;raise&nbsp;a&nbsp;<a href="#TIMEOUT">TIMEOUT</a>&nbsp;exception.<br>
+&nbsp;<br>
+The&nbsp;"timeout"&nbsp;refers&nbsp;only&nbsp;to&nbsp;the&nbsp;amount&nbsp;of&nbsp;time&nbsp;to&nbsp;read&nbsp;at&nbsp;least&nbsp;one&nbsp;character.<br>
+This&nbsp;is&nbsp;not&nbsp;effected&nbsp;by&nbsp;the&nbsp;'size'&nbsp;parameter,&nbsp;so&nbsp;if&nbsp;you&nbsp;call<br>
+<a href="#spawn-read_nonblocking">read_nonblocking</a>(size=100,&nbsp;timeout=30)&nbsp;and&nbsp;only&nbsp;one&nbsp;character&nbsp;is<br>
+available&nbsp;right&nbsp;away&nbsp;then&nbsp;one&nbsp;character&nbsp;will&nbsp;be&nbsp;returned&nbsp;immediately.&nbsp;<br>
+It&nbsp;will&nbsp;not&nbsp;wait&nbsp;for&nbsp;30&nbsp;seconds&nbsp;for&nbsp;another&nbsp;99&nbsp;characters&nbsp;to&nbsp;come&nbsp;in.<br>
+&nbsp;<br>
+This&nbsp;is&nbsp;a&nbsp;wrapper&nbsp;around&nbsp;os.<a href="#spawn-read">read</a>().<br>
+It&nbsp;uses&nbsp;select.select()&nbsp;to&nbsp;implement&nbsp;a&nbsp;timeout.</tt></dd></dl>
+
+<dl><dt><a name="spawn-readline"><strong>readline</strong></a>(self, size<font color="#909090">=-1</font>)</dt><dd><tt>This&nbsp;reads&nbsp;and&nbsp;returns&nbsp;one&nbsp;entire&nbsp;line.&nbsp;A&nbsp;trailing&nbsp;newline&nbsp;is&nbsp;kept&nbsp;in<br>
+the&nbsp;string,&nbsp;but&nbsp;may&nbsp;be&nbsp;absent&nbsp;when&nbsp;a&nbsp;file&nbsp;ends&nbsp;with&nbsp;an&nbsp;incomplete&nbsp;line.&nbsp;<br>
+Note:&nbsp;This&nbsp;<a href="#spawn-readline">readline</a>()&nbsp;looks&nbsp;for&nbsp;a&nbsp;\r\n&nbsp;pair&nbsp;even&nbsp;on&nbsp;UNIX&nbsp;because<br>
+this&nbsp;is&nbsp;what&nbsp;the&nbsp;pseudo&nbsp;tty&nbsp;device&nbsp;returns.&nbsp;So&nbsp;contrary&nbsp;to&nbsp;what&nbsp;you<br>
+may&nbsp;expect&nbsp;you&nbsp;will&nbsp;receive&nbsp;the&nbsp;newline&nbsp;as&nbsp;\r\n.<br>
+An&nbsp;empty&nbsp;string&nbsp;is&nbsp;returned&nbsp;when&nbsp;<a href="#EOF">EOF</a>&nbsp;is&nbsp;hit&nbsp;immediately.<br>
+Currently,&nbsp;the&nbsp;size&nbsp;agument&nbsp;is&nbsp;mostly&nbsp;ignored,&nbsp;so&nbsp;this&nbsp;behavior&nbsp;is&nbsp;not<br>
+standard&nbsp;for&nbsp;a&nbsp;file-like&nbsp;<a href="__builtin__.html#object">object</a>.&nbsp;If&nbsp;size&nbsp;is&nbsp;0&nbsp;then&nbsp;an&nbsp;empty&nbsp;string<br>
+is&nbsp;returned.</tt></dd></dl>
+
+<dl><dt><a name="spawn-readlines"><strong>readlines</strong></a>(self, sizehint<font color="#909090">=-1</font>)</dt><dd><tt>This&nbsp;reads&nbsp;until&nbsp;<a href="#EOF">EOF</a>&nbsp;using&nbsp;<a href="#spawn-readline">readline</a>()&nbsp;and&nbsp;returns&nbsp;a&nbsp;list&nbsp;containing&nbsp;<br>
+the&nbsp;lines&nbsp;thus&nbsp;read.&nbsp;The&nbsp;optional&nbsp;"sizehint"&nbsp;argument&nbsp;is&nbsp;ignored.</tt></dd></dl>
+
+<dl><dt><a name="spawn-send"><strong>send</strong></a>(self, str)</dt><dd><tt>This&nbsp;sends&nbsp;a&nbsp;string&nbsp;to&nbsp;the&nbsp;child&nbsp;process.<br>
+This&nbsp;returns&nbsp;the&nbsp;number&nbsp;of&nbsp;bytes&nbsp;written.<br>
+If&nbsp;a&nbsp;log&nbsp;file&nbsp;was&nbsp;set&nbsp;then&nbsp;the&nbsp;data&nbsp;is&nbsp;also&nbsp;written&nbsp;to&nbsp;the&nbsp;log.</tt></dd></dl>
+
+<dl><dt><a name="spawn-sendeof"><strong>sendeof</strong></a>(self)</dt><dd><tt>This&nbsp;sends&nbsp;an&nbsp;<a href="#EOF">EOF</a>&nbsp;to&nbsp;the&nbsp;child.<br>
+This&nbsp;sends&nbsp;a&nbsp;character&nbsp;which&nbsp;causes&nbsp;the&nbsp;pending&nbsp;parent&nbsp;output<br>
+buffer&nbsp;to&nbsp;be&nbsp;sent&nbsp;to&nbsp;the&nbsp;waiting&nbsp;child&nbsp;program&nbsp;without<br>
+waiting&nbsp;for&nbsp;end-of-line.&nbsp;If&nbsp;it&nbsp;is&nbsp;the&nbsp;first&nbsp;character&nbsp;of&nbsp;the<br>
+line,&nbsp;the&nbsp;<a href="#spawn-read">read</a>()&nbsp;in&nbsp;the&nbsp;user&nbsp;program&nbsp;returns&nbsp;0,&nbsp;which<br>
+signifies&nbsp;end-of-file.&nbsp;This&nbsp;means&nbsp;to&nbsp;work&nbsp;as&nbsp;expected&nbsp;<br>
+a&nbsp;<a href="#spawn-sendeof">sendeof</a>()&nbsp;has&nbsp;to&nbsp;be&nbsp;called&nbsp;at&nbsp;the&nbsp;begining&nbsp;of&nbsp;a&nbsp;line.&nbsp;<br>
+This&nbsp;method&nbsp;does&nbsp;not&nbsp;send&nbsp;a&nbsp;newline.&nbsp;It&nbsp;is&nbsp;the&nbsp;responsibility<br>
+of&nbsp;the&nbsp;caller&nbsp;to&nbsp;ensure&nbsp;the&nbsp;eof&nbsp;is&nbsp;sent&nbsp;at&nbsp;the&nbsp;beginning&nbsp;of&nbsp;a&nbsp;line.</tt></dd></dl>
+
+<dl><dt><a name="spawn-sendline"><strong>sendline</strong></a>(self, str<font color="#909090">=''</font>)</dt><dd><tt>This&nbsp;is&nbsp;like&nbsp;<a href="#spawn-send">send</a>(),&nbsp;but&nbsp;it&nbsp;adds&nbsp;a&nbsp;line&nbsp;feed&nbsp;(os.linesep).<br>
+This&nbsp;returns&nbsp;the&nbsp;number&nbsp;of&nbsp;bytes&nbsp;written.</tt></dd></dl>
+
+<dl><dt><a name="spawn-setecho"><strong>setecho</strong></a>(self, state)</dt><dd><tt>This&nbsp;sets&nbsp;the&nbsp;terminal&nbsp;echo&nbsp;mode&nbsp;on&nbsp;or&nbsp;off.<br>
+Note&nbsp;that&nbsp;anything&nbsp;the&nbsp;child&nbsp;sent&nbsp;before&nbsp;the&nbsp;echo&nbsp;will&nbsp;be&nbsp;lost,&nbsp;so<br>
+you&nbsp;should&nbsp;be&nbsp;sure&nbsp;that&nbsp;your&nbsp;input&nbsp;buffer&nbsp;is&nbsp;empty&nbsp;before&nbsp;you&nbsp;setecho.<br>
+For&nbsp;example,&nbsp;the&nbsp;following&nbsp;will&nbsp;work&nbsp;as&nbsp;expected.<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p&nbsp;=&nbsp;pexpect.<a href="#spawn">spawn</a>('cat')<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p.sendline&nbsp;('1234')&nbsp;#&nbsp;We&nbsp;will&nbsp;see&nbsp;this&nbsp;twice&nbsp;(once&nbsp;from&nbsp;tty&nbsp;echo&nbsp;and&nbsp;again&nbsp;from&nbsp;cat).<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p.expect&nbsp;(['1234'])<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p.expect&nbsp;(['1234'])<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p.<a href="#spawn-setecho">setecho</a>(False)&nbsp;#&nbsp;Turn&nbsp;off&nbsp;tty&nbsp;echo<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p.sendline&nbsp;('abcd')&nbsp;#&nbsp;We&nbsp;will&nbsp;set&nbsp;this&nbsp;only&nbsp;once&nbsp;(echoed&nbsp;by&nbsp;cat).<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p.sendline&nbsp;('wxyz')&nbsp;#&nbsp;We&nbsp;will&nbsp;set&nbsp;this&nbsp;only&nbsp;once&nbsp;(echoed&nbsp;by&nbsp;cat)<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p.expect&nbsp;(['abcd'])<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p.expect&nbsp;(['wxyz'])<br>
+The&nbsp;following&nbsp;WILL&nbsp;NOT&nbsp;WORK&nbsp;because&nbsp;the&nbsp;lines&nbsp;sent&nbsp;before&nbsp;the&nbsp;setecho<br>
+will&nbsp;be&nbsp;lost:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p&nbsp;=&nbsp;pexpect.<a href="#spawn">spawn</a>('cat')<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p.sendline&nbsp;('1234')&nbsp;#&nbsp;We&nbsp;will&nbsp;see&nbsp;this&nbsp;twice&nbsp;(once&nbsp;from&nbsp;tty&nbsp;echo&nbsp;and&nbsp;again&nbsp;from&nbsp;cat).<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p.<a href="#spawn-setecho">setecho</a>(False)&nbsp;#&nbsp;Turn&nbsp;off&nbsp;tty&nbsp;echo<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p.sendline&nbsp;('abcd')&nbsp;#&nbsp;We&nbsp;will&nbsp;set&nbsp;this&nbsp;only&nbsp;once&nbsp;(echoed&nbsp;by&nbsp;cat).<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p.sendline&nbsp;('wxyz')&nbsp;#&nbsp;We&nbsp;will&nbsp;set&nbsp;this&nbsp;only&nbsp;once&nbsp;(echoed&nbsp;by&nbsp;cat)<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p.expect&nbsp;(['1234'])<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p.expect&nbsp;(['1234'])<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p.expect&nbsp;(['abcd'])<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p.expect&nbsp;(['wxyz'])</tt></dd></dl>
+
+<dl><dt><a name="spawn-setlog"><strong>setlog</strong></a>(self, fileobject)</dt><dd><tt>This&nbsp;method&nbsp;is&nbsp;no&nbsp;longer&nbsp;supported&nbsp;or&nbsp;allowed.</tt></dd></dl>
+
+<dl><dt><a name="spawn-setmaxread"><strong>setmaxread</strong></a>(self, maxread)</dt><dd><tt>This&nbsp;method&nbsp;is&nbsp;no&nbsp;longer&nbsp;supported&nbsp;or&nbsp;allowed.<br>
+I&nbsp;don't&nbsp;like&nbsp;getters&nbsp;and&nbsp;setters&nbsp;without&nbsp;a&nbsp;good&nbsp;reason.</tt></dd></dl>
+
+<dl><dt><a name="spawn-setwinsize"><strong>setwinsize</strong></a>(self, r, c)</dt><dd><tt>This&nbsp;sets&nbsp;the&nbsp;terminal&nbsp;window&nbsp;size&nbsp;of&nbsp;the&nbsp;child&nbsp;tty.<br>
+This&nbsp;will&nbsp;cause&nbsp;a&nbsp;SIGWINCH&nbsp;signal&nbsp;to&nbsp;be&nbsp;sent&nbsp;to&nbsp;the&nbsp;child.<br>
+This&nbsp;does&nbsp;not&nbsp;change&nbsp;the&nbsp;physical&nbsp;window&nbsp;size.<br>
+It&nbsp;changes&nbsp;the&nbsp;size&nbsp;reported&nbsp;to&nbsp;TTY-aware&nbsp;applications&nbsp;like<br>
+vi&nbsp;or&nbsp;curses&nbsp;--&nbsp;applications&nbsp;that&nbsp;respond&nbsp;to&nbsp;the&nbsp;SIGWINCH&nbsp;signal.</tt></dd></dl>
+
+<dl><dt><a name="spawn-terminate"><strong>terminate</strong></a>(self, force<font color="#909090">=False</font>)</dt><dd><tt>This&nbsp;forces&nbsp;a&nbsp;child&nbsp;process&nbsp;to&nbsp;terminate.<br>
+It&nbsp;starts&nbsp;nicely&nbsp;with&nbsp;SIGHUP&nbsp;and&nbsp;SIGINT.&nbsp;If&nbsp;"force"&nbsp;is&nbsp;True&nbsp;then<br>
+moves&nbsp;onto&nbsp;SIGKILL.<br>
+This&nbsp;returns&nbsp;True&nbsp;if&nbsp;the&nbsp;child&nbsp;was&nbsp;terminated.<br>
+This&nbsp;returns&nbsp;False&nbsp;if&nbsp;the&nbsp;child&nbsp;could&nbsp;not&nbsp;be&nbsp;terminated.</tt></dd></dl>
+
+<dl><dt><a name="spawn-wait"><strong>wait</strong></a>(self)</dt><dd><tt>This&nbsp;waits&nbsp;until&nbsp;the&nbsp;child&nbsp;exits.&nbsp;This&nbsp;is&nbsp;a&nbsp;blocking&nbsp;call.<br>
+This&nbsp;will&nbsp;not&nbsp;read&nbsp;any&nbsp;data&nbsp;from&nbsp;the&nbsp;child,&nbsp;so&nbsp;this&nbsp;will&nbsp;block&nbsp;forever<br>
+if&nbsp;the&nbsp;child&nbsp;has&nbsp;unread&nbsp;output&nbsp;and&nbsp;has&nbsp;terminated.&nbsp;In&nbsp;other&nbsp;words,&nbsp;the&nbsp;child<br>
+may&nbsp;have&nbsp;printed&nbsp;output&nbsp;then&nbsp;called&nbsp;exit();&nbsp;but,&nbsp;technically,&nbsp;the&nbsp;child&nbsp;is<br>
+still&nbsp;alive&nbsp;until&nbsp;its&nbsp;output&nbsp;is&nbsp;read.</tt></dd></dl>
+
+<dl><dt><a name="spawn-write"><strong>write</strong></a>(self, str)</dt><dd><tt>This&nbsp;is&nbsp;similar&nbsp;to&nbsp;<a href="#spawn-send">send</a>()&nbsp;except&nbsp;that&nbsp;there&nbsp;is&nbsp;no&nbsp;return&nbsp;value.</tt></dd></dl>
+
+<dl><dt><a name="spawn-writelines"><strong>writelines</strong></a>(self, sequence)</dt><dd><tt>This&nbsp;calls&nbsp;<a href="#spawn-write">write</a>()&nbsp;for&nbsp;each&nbsp;element&nbsp;in&nbsp;the&nbsp;sequence.<br>
+The&nbsp;sequence&nbsp;can&nbsp;be&nbsp;any&nbsp;iterable&nbsp;<a href="__builtin__.html#object">object</a>&nbsp;producing&nbsp;strings,&nbsp;<br>
+typically&nbsp;a&nbsp;list&nbsp;of&nbsp;strings.&nbsp;This&nbsp;does&nbsp;not&nbsp;add&nbsp;line&nbsp;separators<br>
+There&nbsp;is&nbsp;no&nbsp;return&nbsp;value.</tt></dd></dl>
+
+<hr>
+Data and other attributes defined here:<br>
+<dl><dt><strong>__dict__</strong> = &lt;dictproxy object&gt;<dd><tt>dictionary&nbsp;for&nbsp;instance&nbsp;variables&nbsp;(if&nbsp;defined)</tt></dl>
+
+<dl><dt><strong>__weakref__</strong> = &lt;attribute '__weakref__' of 'spawn' objects&gt;<dd><tt>list&nbsp;of&nbsp;weak&nbsp;references&nbsp;to&nbsp;the&nbsp;<a href="__builtin__.html#object">object</a>&nbsp;(if&nbsp;defined)</tt></dl>
+
+</td></tr></table></td></tr></table><p>
+<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
+<tr bgcolor="#eeaa77">
+<td colspan=3 valign=bottom>&nbsp;<br>
+<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
+    
+<tr><td bgcolor="#eeaa77"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
+<td width="100%"><dl><dt><a name="-run"><strong>run</strong></a>(command, timeout<font color="#909090">=-1</font>, withexitstatus<font color="#909090">=False</font>, events<font color="#909090">=None</font>, extra_args<font color="#909090">=None</font>, logfile<font color="#909090">=None</font>)</dt><dd><tt>This&nbsp;function&nbsp;runs&nbsp;the&nbsp;given&nbsp;command;&nbsp;waits&nbsp;for&nbsp;it&nbsp;to&nbsp;finish;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;then&nbsp;returns&nbsp;all&nbsp;output&nbsp;as&nbsp;a&nbsp;string.&nbsp;STDERR&nbsp;is&nbsp;included&nbsp;in&nbsp;output.<br>
+&nbsp;&nbsp;&nbsp;&nbsp;If&nbsp;the&nbsp;full&nbsp;path&nbsp;to&nbsp;the&nbsp;command&nbsp;is&nbsp;not&nbsp;given&nbsp;then&nbsp;the&nbsp;path&nbsp;is&nbsp;searched.<br>
+&nbsp;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;Note&nbsp;that&nbsp;lines&nbsp;are&nbsp;terminated&nbsp;by&nbsp;CR/LF&nbsp;(\r\n)&nbsp;combination<br>
+&nbsp;&nbsp;&nbsp;&nbsp;even&nbsp;on&nbsp;UNIX-like&nbsp;systems&nbsp;because&nbsp;this&nbsp;is&nbsp;the&nbsp;standard&nbsp;for&nbsp;pseudo&nbsp;ttys.<br>
+&nbsp;&nbsp;&nbsp;&nbsp;If&nbsp;you&nbsp;set&nbsp;withexitstatus&nbsp;to&nbsp;true,&nbsp;then&nbsp;run&nbsp;will&nbsp;return&nbsp;a&nbsp;tuple&nbsp;of<br>
+&nbsp;&nbsp;&nbsp;&nbsp;(command_output,&nbsp;exitstatus).&nbsp;If&nbsp;withexitstatus&nbsp;is&nbsp;false&nbsp;then&nbsp;this<br>
+&nbsp;&nbsp;&nbsp;&nbsp;returns&nbsp;just&nbsp;command_output.<br>
+&nbsp;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;<a href="#-run">run</a>()&nbsp;function&nbsp;can&nbsp;often&nbsp;be&nbsp;used&nbsp;instead&nbsp;of&nbsp;creating&nbsp;a&nbsp;<a href="#spawn">spawn</a>&nbsp;instance.<br>
+&nbsp;&nbsp;&nbsp;&nbsp;For&nbsp;example,&nbsp;the&nbsp;following&nbsp;code&nbsp;uses&nbsp;<a href="#spawn">spawn</a>:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from&nbsp;pexpect&nbsp;import&nbsp;*<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;child&nbsp;=&nbsp;<a href="#spawn">spawn</a>('scp&nbsp;foo&nbsp;myname at host.example.com:.')<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;child.expect&nbsp;('(?i)password')<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;child.sendline&nbsp;(mypassword)<br>
+&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;previous&nbsp;code&nbsp;can&nbsp;be&nbsp;replace&nbsp;with&nbsp;the&nbsp;following,&nbsp;which&nbsp;you&nbsp;may<br>
+&nbsp;&nbsp;&nbsp;&nbsp;or&nbsp;may&nbsp;not&nbsp;find&nbsp;simpler:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from&nbsp;pexpect&nbsp;import&nbsp;*<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;run&nbsp;('scp&nbsp;foo&nbsp;myname at host.example.com:.',&nbsp;events={'(?i)password':&nbsp;mypassword})<br>
+&nbsp;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;Examples:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;Start&nbsp;the&nbsp;apache&nbsp;daemon&nbsp;on&nbsp;the&nbsp;local&nbsp;machine:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from&nbsp;pexpect&nbsp;import&nbsp;*<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;run&nbsp;("/usr/local/apache/bin/apachectl&nbsp;start")<br>
+&nbsp;&nbsp;&nbsp;&nbsp;Check&nbsp;in&nbsp;a&nbsp;file&nbsp;using&nbsp;SVN:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from&nbsp;pexpect&nbsp;import&nbsp;*<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;run&nbsp;("svn&nbsp;ci&nbsp;-m&nbsp;'automatic&nbsp;commit'&nbsp;my_file.py")<br>
+&nbsp;&nbsp;&nbsp;&nbsp;Run&nbsp;a&nbsp;command&nbsp;and&nbsp;capture&nbsp;exit&nbsp;status:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from&nbsp;pexpect&nbsp;import&nbsp;*<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(command_output,&nbsp;exitstatus)&nbsp;=&nbsp;run&nbsp;('ls&nbsp;-l&nbsp;/bin',&nbsp;withexitstatus=1)<br>
+&nbsp;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;Tricky&nbsp;Examples:&nbsp;&nbsp;&nbsp;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;following&nbsp;will&nbsp;run&nbsp;SSH&nbsp;and&nbsp;execute&nbsp;'ls&nbsp;-l'&nbsp;on&nbsp;the&nbsp;remote&nbsp;machine.<br>
+&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;password&nbsp;'secret'&nbsp;will&nbsp;be&nbsp;sent&nbsp;if&nbsp;the&nbsp;'(?i)password'&nbsp;pattern&nbsp;is&nbsp;ever&nbsp;seen.<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;run&nbsp;("ssh&nbsp;username at machine.example.com&nbsp;'ls&nbsp;-l'",&nbsp;events={'(?i)password':'secret<br>
+'})<br>
+&nbsp;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;This&nbsp;will&nbsp;start&nbsp;mencoder&nbsp;to&nbsp;rip&nbsp;a&nbsp;video&nbsp;from&nbsp;DVD.&nbsp;This&nbsp;will&nbsp;also&nbsp;display<br>
+&nbsp;&nbsp;&nbsp;&nbsp;progress&nbsp;ticks&nbsp;every&nbsp;5&nbsp;seconds&nbsp;as&nbsp;it&nbsp;runs.<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;from&nbsp;pexpect&nbsp;import&nbsp;*<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;def&nbsp;print_ticks(d):<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print&nbsp;d['event_count'],<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;run&nbsp;("mencoder&nbsp;dvd://1&nbsp;-o&nbsp;video.avi&nbsp;-oac&nbsp;copy&nbsp;-ovc&nbsp;copy",&nbsp;events={<a href="#TIMEOUT">TIMEOUT</a>:print_ticks},&nbsp;timeout=5)<br>
+&nbsp;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;'events'&nbsp;argument&nbsp;should&nbsp;be&nbsp;a&nbsp;dictionary&nbsp;of&nbsp;patterns&nbsp;and&nbsp;responses.<br>
+&nbsp;&nbsp;&nbsp;&nbsp;Whenever&nbsp;one&nbsp;of&nbsp;the&nbsp;patterns&nbsp;is&nbsp;seen&nbsp;in&nbsp;the&nbsp;command&nbsp;out<br>
+&nbsp;&nbsp;&nbsp;&nbsp;<a href="#-run">run</a>()&nbsp;will&nbsp;send&nbsp;the&nbsp;associated&nbsp;response&nbsp;string.&nbsp;Note&nbsp;that&nbsp;you&nbsp;should<br>
+&nbsp;&nbsp;&nbsp;&nbsp;put&nbsp;newlines&nbsp;in&nbsp;your&nbsp;string&nbsp;if&nbsp;Enter&nbsp;is&nbsp;necessary.<br>
+&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;responses&nbsp;may&nbsp;also&nbsp;contain&nbsp;callback&nbsp;functions.<br>
+&nbsp;&nbsp;&nbsp;&nbsp;Any&nbsp;callback&nbsp;is&nbsp;function&nbsp;that&nbsp;takes&nbsp;a&nbsp;dictionary&nbsp;as&nbsp;an&nbsp;argument.<br>
+&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;dictionary&nbsp;contains&nbsp;all&nbsp;the&nbsp;locals&nbsp;from&nbsp;the&nbsp;<a href="#-run">run</a>()&nbsp;function,&nbsp;so<br>
+&nbsp;&nbsp;&nbsp;&nbsp;you&nbsp;can&nbsp;access&nbsp;the&nbsp;child&nbsp;<a href="#spawn">spawn</a>&nbsp;<a href="__builtin__.html#object">object</a>&nbsp;or&nbsp;any&nbsp;other&nbsp;variable&nbsp;defined<br>
+&nbsp;&nbsp;&nbsp;&nbsp;in&nbsp;<a href="#-run">run</a>()&nbsp;(event_count,&nbsp;child,&nbsp;and&nbsp;extra_args&nbsp;are&nbsp;the&nbsp;most&nbsp;useful).<br>
+&nbsp;&nbsp;&nbsp;&nbsp;A&nbsp;callback&nbsp;may&nbsp;return&nbsp;True&nbsp;to&nbsp;stop&nbsp;the&nbsp;current&nbsp;run&nbsp;process&nbsp;otherwise<br>
+&nbsp;&nbsp;&nbsp;&nbsp;<a href="#-run">run</a>()&nbsp;continues&nbsp;until&nbsp;the&nbsp;next&nbsp;event.<br>
+&nbsp;&nbsp;&nbsp;&nbsp;A&nbsp;callback&nbsp;may&nbsp;also&nbsp;return&nbsp;a&nbsp;string&nbsp;which&nbsp;will&nbsp;be&nbsp;sent&nbsp;to&nbsp;the&nbsp;child.<br>
+&nbsp;&nbsp;&nbsp;&nbsp;'extra_args'&nbsp;is&nbsp;not&nbsp;used&nbsp;by&nbsp;directly&nbsp;<a href="#-run">run</a>().&nbsp;It&nbsp;provides&nbsp;a&nbsp;way&nbsp;to&nbsp;pass&nbsp;data&nbsp;to<br>
+&nbsp;&nbsp;&nbsp;&nbsp;a&nbsp;callback&nbsp;function&nbsp;through&nbsp;<a href="#-run">run</a>()&nbsp;through&nbsp;the&nbsp;locals&nbsp;dictionary&nbsp;passed&nbsp;to&nbsp;a&nbsp;callback.</tt></dd></dl>
+ <dl><dt><a name="-split_command_line"><strong>split_command_line</strong></a>(command_line)</dt><dd><tt>This&nbsp;splits&nbsp;a&nbsp;command&nbsp;line&nbsp;into&nbsp;a&nbsp;list&nbsp;of&nbsp;arguments.<br>
+It&nbsp;splits&nbsp;arguments&nbsp;on&nbsp;spaces,&nbsp;but&nbsp;handles<br>
+embedded&nbsp;quotes,&nbsp;doublequotes,&nbsp;and&nbsp;escaped&nbsp;characters.<br>
+It's&nbsp;impossible&nbsp;to&nbsp;do&nbsp;this&nbsp;with&nbsp;a&nbsp;regular&nbsp;expression,&nbsp;so<br>
+I&nbsp;wrote&nbsp;a&nbsp;little&nbsp;state&nbsp;machine&nbsp;to&nbsp;parse&nbsp;the&nbsp;command&nbsp;line.</tt></dd></dl>
+ <dl><dt><a name="-which"><strong>which</strong></a>(filename)</dt><dd><tt>This&nbsp;takes&nbsp;a&nbsp;given&nbsp;filename;&nbsp;tries&nbsp;to&nbsp;find&nbsp;it&nbsp;in&nbsp;the&nbsp;environment&nbsp;path;&nbsp;<br>
+then&nbsp;checks&nbsp;if&nbsp;it&nbsp;is&nbsp;executable.<br>
+This&nbsp;returns&nbsp;the&nbsp;full&nbsp;path&nbsp;to&nbsp;the&nbsp;filename&nbsp;if&nbsp;found&nbsp;and&nbsp;executable.<br>
+Otherwise&nbsp;this&nbsp;returns&nbsp;None.</tt></dd></dl>
+</td></tr></table><p>
+<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
+<tr bgcolor="#55aa55">
+<td colspan=3 valign=bottom>&nbsp;<br>
+<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
+    
+<tr><td bgcolor="#55aa55"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
+<td width="100%"><strong>__all__</strong> = ['ExceptionPexpect', 'EOF', 'TIMEOUT', 'spawn', 'run', 'which', 'split_command_line', '__version__', '__revision__']<br>
+<strong>__revision__</strong> = '$Revision: 395 $'<br>
+<strong>__version__</strong> = '2.1'</td></tr></table>
+</body></html>

Added: packages/pexpect/branches/upstream/current/doc/pxssh.html
URL: http://svn.debian.org/wsvn/python-modules/packages/pexpect/branches/upstream/current/doc/pxssh.html?rev=929&op=file
==============================================================================
--- packages/pexpect/branches/upstream/current/doc/pxssh.html (added)
+++ packages/pexpect/branches/upstream/current/doc/pxssh.html Mon Jun 19 10:53:24 2006
@@ -1,0 +1,377 @@
+
+<!doctype html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html><head><title>Python: module pxssh</title>
+</head><body bgcolor="#f0f0f8">
+
+<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
+<tr bgcolor="#7799ee">
+<td valign=bottom>&nbsp;<br>
+<font color="#ffffff" face="helvetica, arial">&nbsp;<br><big><big><strong>pxssh</strong></big></big> (version 2.1)</font></td
+><td align=right valign=bottom
+><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/noah/documents/export/engineering/source/python/pexpect/trunk/pexpect/pxssh.py">/home/noah/documents/export/engineering/source/python/pexpect/trunk/pexpect/pxssh.py</a></font></td></tr></table>
+    <p></p>
+<p>
+<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
+<tr bgcolor="#ee77aa">
+<td colspan=3 valign=bottom>&nbsp;<br>
+<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
+    
+<tr><td bgcolor="#ee77aa"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
+<td width="100%"><dl>
+<dt><font face="helvetica, arial"><a href="pexpect.html#spawn">pexpect.spawn</a>(<a href="__builtin__.html#object">__builtin__.object</a>)
+</font></dt><dd>
+<dl>
+<dt><font face="helvetica, arial"><a href="pxssh.html#pxssh">pxssh</a>
+</font></dt></dl>
+</dd>
+</dl>
+ <p>
+<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
+<tr bgcolor="#ffc8d8">
+<td colspan=3 valign=bottom>&nbsp;<br>
+<font color="#000000" face="helvetica, arial"><a name="pxssh">class <strong>pxssh</strong></a>(<a href="pexpect.html#spawn">pexpect.spawn</a>)</font></td></tr>
+    
+<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
+<td colspan=2><tt>This&nbsp;class&nbsp;extends&nbsp;pexpect.<a href="pexpect.html#spawn">spawn</a>&nbsp;to&nbsp;specialize&nbsp;setting&nbsp;up&nbsp;SSH&nbsp;connections.<br>
+This&nbsp;adds&nbsp;methods&nbsp;for&nbsp;login,&nbsp;logout,&nbsp;and&nbsp;expecting&nbsp;the&nbsp;prompt.<br>
+It&nbsp;does&nbsp;various&nbsp;hacky&nbsp;things&nbsp;to&nbsp;handle&nbsp;any&nbsp;situation&nbsp;in&nbsp;the&nbsp;SSH&nbsp;login&nbsp;process.<br>
+For&nbsp;example,&nbsp;if&nbsp;the&nbsp;session&nbsp;is&nbsp;your&nbsp;first&nbsp;login,&nbsp;then&nbsp;it&nbsp;automatically<br>
+accepts&nbsp;the&nbsp;certificate;&nbsp;or&nbsp;if&nbsp;you&nbsp;have&nbsp;public&nbsp;key&nbsp;authentication&nbsp;setup<br>
+and&nbsp;you&nbsp;don't&nbsp;need&nbsp;a&nbsp;password&nbsp;then&nbsp;this&nbsp;is&nbsp;OK&nbsp;too.<br>
+&nbsp;<br>
+Example&nbsp;usage&nbsp;that&nbsp;runs&nbsp;'ls&nbsp;-l'&nbsp;on&nbsp;server&nbsp;and&nbsp;prints&nbsp;the&nbsp;result:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;import&nbsp;<a href="#pxssh">pxssh</a><br>
+&nbsp;&nbsp;&nbsp;&nbsp;s&nbsp;=&nbsp;<a href="#pxssh">pxssh</a>.<a href="#pxssh">pxssh</a>()<br>
+&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;not&nbsp;s.login&nbsp;('localhost',&nbsp;'myusername',&nbsp;'mypassword'):<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print&nbsp;"SSH&nbsp;session&nbsp;failed&nbsp;on&nbsp;login."<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print&nbsp;str(s)<br>
+&nbsp;&nbsp;&nbsp;&nbsp;else:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print&nbsp;"SSH&nbsp;session&nbsp;login&nbsp;successful"<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;s.sendline&nbsp;('ls&nbsp;-l')<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;s.<a href="#pxssh-prompt">prompt</a>()&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;match&nbsp;the&nbsp;prompt<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print&nbsp;s.before&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#&nbsp;print&nbsp;everything&nbsp;before&nbsp;the&nbsp;prompt.<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;s.<a href="#pxssh-logout">logout</a>()<br>&nbsp;</tt></td></tr>
+<tr><td>&nbsp;</td>
+<td width="100%"><dl><dt>Method resolution order:</dt>
+<dd><a href="pxssh.html#pxssh">pxssh</a></dd>
+<dd><a href="pexpect.html#spawn">pexpect.spawn</a></dd>
+<dd><a href="__builtin__.html#object">__builtin__.object</a></dd>
+</dl>
+<hr>
+Methods defined here:<br>
+<dl><dt><a name="pxssh-__init__"><strong>__init__</strong></a>(self)</dt></dl>
+
+<dl><dt><a name="pxssh-login"><strong>login</strong></a>(self, server, username, password<font color="#909090">=''</font>, terminal_type<font color="#909090">='ansi'</font>, original_prompts<font color="#909090">='][#$]|~[#$]|bash.*?[#$]|[#$] '</font>, login_timeout<font color="#909090">=10</font>)</dt><dd><tt>This&nbsp;logs&nbsp;the&nbsp;user&nbsp;into&nbsp;the&nbsp;given&nbsp;server.&nbsp;By&nbsp;default&nbsp;the&nbsp;prompt&nbsp;is<br>
+rather&nbsp;optimistic&nbsp;and&nbsp;should&nbsp;be&nbsp;considered&nbsp;more&nbsp;of&nbsp;an&nbsp;example.&nbsp;It's<br>
+better&nbsp;to&nbsp;try&nbsp;to&nbsp;match&nbsp;the&nbsp;prompt&nbsp;as&nbsp;exactly&nbsp;as&nbsp;possible&nbsp;to&nbsp;prevent<br>
+any&nbsp;false&nbsp;matches&nbsp;by&nbsp;server&nbsp;strings&nbsp;such&nbsp;as&nbsp;a&nbsp;"Message&nbsp;Of&nbsp;The&nbsp;Day"&nbsp;or<br>
+something.&nbsp;The&nbsp;closer&nbsp;you&nbsp;can&nbsp;make&nbsp;the&nbsp;original_prompt&nbsp;match&nbsp;your&nbsp;real&nbsp;prompt<br>
+then&nbsp;the&nbsp;better.&nbsp;A&nbsp;timeout&nbsp;will&nbsp;not&nbsp;necessarily&nbsp;cause&nbsp;the&nbsp;login&nbsp;to&nbsp;fail.<br>
+In&nbsp;the&nbsp;case&nbsp;of&nbsp;a&nbsp;timeout&nbsp;we&nbsp;assume&nbsp;that&nbsp;the&nbsp;prompt&nbsp;was&nbsp;so&nbsp;weird&nbsp;that<br>
+we&nbsp;could&nbsp;not&nbsp;match&nbsp;it.&nbsp;We&nbsp;still&nbsp;try&nbsp;to&nbsp;reset&nbsp;the&nbsp;prompt&nbsp;to&nbsp;something<br>
+more&nbsp;unique.&nbsp;If&nbsp;that&nbsp;still&nbsp;fails&nbsp;then&nbsp;we&nbsp;return&nbsp;False.</tt></dd></dl>
+
+<dl><dt><a name="pxssh-logout"><strong>logout</strong></a>(self)</dt><dd><tt>This&nbsp;sends&nbsp;exit.&nbsp;If&nbsp;there&nbsp;are&nbsp;stopped&nbsp;jobs&nbsp;then&nbsp;this&nbsp;sends&nbsp;exit&nbsp;twice.</tt></dd></dl>
+
+<dl><dt><a name="pxssh-prompt"><strong>prompt</strong></a>(self, timeout<font color="#909090">=20</font>)</dt><dd><tt>This&nbsp;expects&nbsp;the&nbsp;prompt.&nbsp;This&nbsp;returns&nbsp;True&nbsp;if&nbsp;the&nbsp;prompt&nbsp;was&nbsp;matched.<br>
+This&nbsp;returns&nbsp;False&nbsp;if&nbsp;there&nbsp;was&nbsp;a&nbsp;timeout.</tt></dd></dl>
+
+<dl><dt><a name="pxssh-set_unique_prompt"><strong>set_unique_prompt</strong></a>(self, optional_prompt<font color="#909090">=None</font>)</dt><dd><tt>This&nbsp;attempts&nbsp;to&nbsp;reset&nbsp;the&nbsp;shell&nbsp;prompt&nbsp;to&nbsp;something&nbsp;more&nbsp;unique.<br>
+This&nbsp;makes&nbsp;it&nbsp;easier&nbsp;to&nbsp;match&nbsp;unambiguously.</tt></dd></dl>
+
+<hr>
+Methods inherited from <a href="pexpect.html#spawn">pexpect.spawn</a>:<br>
+<dl><dt><a name="pxssh-__del__"><strong>__del__</strong></a>(self)</dt><dd><tt>This&nbsp;makes&nbsp;sure&nbsp;that&nbsp;no&nbsp;system&nbsp;resources&nbsp;are&nbsp;left&nbsp;open.<br>
+Python&nbsp;only&nbsp;garbage&nbsp;collects&nbsp;Python&nbsp;objects.&nbsp;OS&nbsp;file&nbsp;descriptors<br>
+are&nbsp;not&nbsp;Python&nbsp;objects,&nbsp;so&nbsp;they&nbsp;must&nbsp;be&nbsp;handled&nbsp;explicitly.<br>
+If&nbsp;the&nbsp;child&nbsp;file&nbsp;descriptor&nbsp;was&nbsp;opened&nbsp;outside&nbsp;of&nbsp;this&nbsp;class<br>
+(passed&nbsp;to&nbsp;the&nbsp;constructor)&nbsp;then&nbsp;this&nbsp;does&nbsp;not&nbsp;close&nbsp;it.</tt></dd></dl>
+
+<dl><dt><a name="pxssh-__iter__"><strong>__iter__</strong></a>(self)</dt><dd><tt>This&nbsp;is&nbsp;to&nbsp;support&nbsp;iterators&nbsp;over&nbsp;a&nbsp;file-like&nbsp;object.</tt></dd></dl>
+
+<dl><dt><a name="pxssh-__str__"><strong>__str__</strong></a>(self)</dt><dd><tt>This&nbsp;returns&nbsp;the&nbsp;current&nbsp;state&nbsp;of&nbsp;the&nbsp;pexpect&nbsp;object&nbsp;as&nbsp;a&nbsp;string.</tt></dd></dl>
+
+<dl><dt><a name="pxssh-close"><strong>close</strong></a>(self, force<font color="#909090">=True</font>)</dt><dd><tt>This&nbsp;closes&nbsp;the&nbsp;connection&nbsp;with&nbsp;the&nbsp;child&nbsp;application.<br>
+Note&nbsp;that&nbsp;calling&nbsp;<a href="#pxssh-close">close</a>()&nbsp;more&nbsp;than&nbsp;once&nbsp;is&nbsp;valid.<br>
+This&nbsp;emulates&nbsp;standard&nbsp;Python&nbsp;behavior&nbsp;with&nbsp;files.<br>
+Set&nbsp;force&nbsp;to&nbsp;True&nbsp;if&nbsp;you&nbsp;want&nbsp;to&nbsp;make&nbsp;sure&nbsp;that&nbsp;the&nbsp;child&nbsp;is&nbsp;terminated<br>
+(SIGKILL&nbsp;is&nbsp;sent&nbsp;if&nbsp;the&nbsp;child&nbsp;ignores&nbsp;SIGHUP&nbsp;and&nbsp;SIGINT).</tt></dd></dl>
+
+<dl><dt><a name="pxssh-compile_pattern_list"><strong>compile_pattern_list</strong></a>(self, patterns)</dt><dd><tt>This&nbsp;compiles&nbsp;a&nbsp;pattern-string&nbsp;or&nbsp;a&nbsp;list&nbsp;of&nbsp;pattern-strings.<br>
+Patterns&nbsp;must&nbsp;be&nbsp;a&nbsp;StringType,&nbsp;EOF,&nbsp;TIMEOUT,&nbsp;SRE_Pattern,&nbsp;or&nbsp;<br>
+a&nbsp;list&nbsp;of&nbsp;those.&nbsp;Patterns&nbsp;may&nbsp;also&nbsp;be&nbsp;None&nbsp;which&nbsp;results&nbsp;in<br>
+an&nbsp;empty&nbsp;list.<br>
+&nbsp;<br>
+This&nbsp;is&nbsp;used&nbsp;by&nbsp;<a href="#pxssh-expect">expect</a>()&nbsp;when&nbsp;calling&nbsp;<a href="#pxssh-expect_list">expect_list</a>().<br>
+Thus&nbsp;<a href="#pxssh-expect">expect</a>()&nbsp;is&nbsp;nothing&nbsp;more&nbsp;than::<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cpl&nbsp;=&nbsp;<a href="#pxssh-compile_pattern_list">compile_pattern_list</a>(pl)<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;<a href="#pxssh-expect_list">expect_list</a>(clp,&nbsp;timeout)<br>
+&nbsp;<br>
+If&nbsp;you&nbsp;are&nbsp;using&nbsp;<a href="#pxssh-expect">expect</a>()&nbsp;within&nbsp;a&nbsp;loop&nbsp;it&nbsp;may&nbsp;be&nbsp;more<br>
+efficient&nbsp;to&nbsp;compile&nbsp;the&nbsp;patterns&nbsp;first&nbsp;and&nbsp;then&nbsp;call&nbsp;<a href="#pxssh-expect_list">expect_list</a>().<br>
+This&nbsp;avoid&nbsp;calls&nbsp;in&nbsp;a&nbsp;loop&nbsp;to&nbsp;<a href="#pxssh-compile_pattern_list">compile_pattern_list</a>():<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cpl&nbsp;=&nbsp;<a href="#pxssh-compile_pattern_list">compile_pattern_list</a>(my_pattern)<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;while&nbsp;some_condition:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;...<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;i&nbsp;=&nbsp;<a href="#pxssh-expect_list">expect_list</a>(clp,&nbsp;timeout)<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;...</tt></dd></dl>
+
+<dl><dt><a name="pxssh-eof"><strong>eof</strong></a>(self)</dt><dd><tt>This&nbsp;returns&nbsp;True&nbsp;if&nbsp;the&nbsp;EOF&nbsp;exception&nbsp;was&nbsp;ever&nbsp;raised.</tt></dd></dl>
+
+<dl><dt><a name="pxssh-expect"><strong>expect</strong></a>(self, pattern, timeout<font color="#909090">=-1</font>, searchwindowsize<font color="#909090">=None</font>)</dt><dd><tt>This&nbsp;seeks&nbsp;through&nbsp;the&nbsp;stream&nbsp;until&nbsp;a&nbsp;pattern&nbsp;is&nbsp;matched.<br>
+The&nbsp;pattern&nbsp;is&nbsp;overloaded&nbsp;and&nbsp;may&nbsp;take&nbsp;several&nbsp;types&nbsp;including&nbsp;a&nbsp;list.<br>
+The&nbsp;pattern&nbsp;can&nbsp;be&nbsp;a&nbsp;StringType,&nbsp;EOF,&nbsp;a&nbsp;compiled&nbsp;re,&nbsp;or&nbsp;a&nbsp;list&nbsp;of<br>
+those&nbsp;types.&nbsp;Strings&nbsp;will&nbsp;be&nbsp;compiled&nbsp;to&nbsp;re&nbsp;types.&nbsp;This&nbsp;returns&nbsp;the<br>
+index&nbsp;into&nbsp;the&nbsp;pattern&nbsp;list.&nbsp;If&nbsp;the&nbsp;pattern&nbsp;was&nbsp;not&nbsp;a&nbsp;list&nbsp;this<br>
+returns&nbsp;index&nbsp;0&nbsp;on&nbsp;a&nbsp;successful&nbsp;match.&nbsp;This&nbsp;may&nbsp;raise&nbsp;exceptions&nbsp;for<br>
+EOF&nbsp;or&nbsp;TIMEOUT.&nbsp;To&nbsp;avoid&nbsp;the&nbsp;EOF&nbsp;or&nbsp;TIMEOUT&nbsp;exceptions&nbsp;add<br>
+EOF&nbsp;or&nbsp;TIMEOUT&nbsp;to&nbsp;the&nbsp;pattern&nbsp;list.<br>
+&nbsp;<br>
+After&nbsp;a&nbsp;match&nbsp;is&nbsp;found&nbsp;the&nbsp;instance&nbsp;attributes<br>
+'before',&nbsp;'after'&nbsp;and&nbsp;'match'&nbsp;will&nbsp;be&nbsp;set.<br>
+You&nbsp;can&nbsp;see&nbsp;all&nbsp;the&nbsp;data&nbsp;read&nbsp;before&nbsp;the&nbsp;match&nbsp;in&nbsp;'before'.<br>
+You&nbsp;can&nbsp;see&nbsp;the&nbsp;data&nbsp;that&nbsp;was&nbsp;matched&nbsp;in&nbsp;'after'.<br>
+The&nbsp;re.MatchObject&nbsp;used&nbsp;in&nbsp;the&nbsp;re&nbsp;match&nbsp;will&nbsp;be&nbsp;in&nbsp;'match'.<br>
+If&nbsp;an&nbsp;error&nbsp;occured&nbsp;then&nbsp;'before'&nbsp;will&nbsp;be&nbsp;set&nbsp;to&nbsp;all&nbsp;the<br>
+data&nbsp;read&nbsp;so&nbsp;far&nbsp;and&nbsp;'after'&nbsp;and&nbsp;'match'&nbsp;will&nbsp;be&nbsp;None.<br>
+&nbsp;<br>
+If&nbsp;timeout&nbsp;is&nbsp;-1&nbsp;then&nbsp;timeout&nbsp;will&nbsp;be&nbsp;set&nbsp;to&nbsp;the&nbsp;self.<strong>timeout</strong>&nbsp;value.<br>
+&nbsp;<br>
+Note:&nbsp;A&nbsp;list&nbsp;entry&nbsp;may&nbsp;be&nbsp;EOF&nbsp;or&nbsp;TIMEOUT&nbsp;instead&nbsp;of&nbsp;a&nbsp;string.<br>
+This&nbsp;will&nbsp;catch&nbsp;these&nbsp;exceptions&nbsp;and&nbsp;return&nbsp;the&nbsp;index<br>
+of&nbsp;the&nbsp;list&nbsp;entry&nbsp;instead&nbsp;of&nbsp;raising&nbsp;the&nbsp;exception.<br>
+The&nbsp;attribute&nbsp;'after'&nbsp;will&nbsp;be&nbsp;set&nbsp;to&nbsp;the&nbsp;exception&nbsp;type.<br>
+The&nbsp;attribute&nbsp;'match'&nbsp;will&nbsp;be&nbsp;None.<br>
+This&nbsp;allows&nbsp;you&nbsp;to&nbsp;write&nbsp;code&nbsp;like&nbsp;this:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;index&nbsp;=&nbsp;p.expect&nbsp;(['good',&nbsp;'bad',&nbsp;pexpect.EOF,&nbsp;pexpect.TIMEOUT])<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;index&nbsp;==&nbsp;0:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;do_something()<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;elif&nbsp;index&nbsp;==&nbsp;1:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;do_something_else()<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;elif&nbsp;index&nbsp;==&nbsp;2:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;do_some_other_thing()<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;elif&nbsp;index&nbsp;==&nbsp;3:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;do_something_completely_different()<br>
+instead&nbsp;of&nbsp;code&nbsp;like&nbsp;this:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;index&nbsp;=&nbsp;p.expect&nbsp;(['good',&nbsp;'bad'])<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;index&nbsp;==&nbsp;0:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;do_something()<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;elif&nbsp;index&nbsp;==&nbsp;1:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;do_something_else()<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;except&nbsp;EOF:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;do_some_other_thing()<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;except&nbsp;TIMEOUT:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;do_something_completely_different()<br>
+These&nbsp;two&nbsp;forms&nbsp;are&nbsp;equivalent.&nbsp;It&nbsp;all&nbsp;depends&nbsp;on&nbsp;what&nbsp;you&nbsp;want.<br>
+You&nbsp;can&nbsp;also&nbsp;just&nbsp;expect&nbsp;the&nbsp;EOF&nbsp;if&nbsp;you&nbsp;are&nbsp;waiting&nbsp;for&nbsp;all&nbsp;output<br>
+of&nbsp;a&nbsp;child&nbsp;to&nbsp;finish.&nbsp;For&nbsp;example:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p&nbsp;=&nbsp;pexpect.<a href="pexpect.html#spawn">spawn</a>('/bin/ls')<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p.expect&nbsp;(pexpect.EOF)<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print&nbsp;p.before<br>
+&nbsp;<br>
+If&nbsp;you&nbsp;are&nbsp;trying&nbsp;to&nbsp;optimize&nbsp;for&nbsp;speed&nbsp;then&nbsp;see&nbsp;<a href="#pxssh-expect_list">expect_list</a>().</tt></dd></dl>
+
+<dl><dt><a name="pxssh-expect_exact"><strong>expect_exact</strong></a>(self, pattern_list, timeout<font color="#909090">=-1</font>)</dt><dd><tt>This&nbsp;method&nbsp;is&nbsp;no&nbsp;longer&nbsp;supported&nbsp;or&nbsp;allowed.<br>
+It&nbsp;was&nbsp;too&nbsp;hard&nbsp;to&nbsp;maintain&nbsp;and&nbsp;keep&nbsp;it&nbsp;up&nbsp;to&nbsp;date&nbsp;with&nbsp;expect_list.<br>
+Few&nbsp;people&nbsp;used&nbsp;this&nbsp;method.&nbsp;Most&nbsp;people&nbsp;favored&nbsp;reliability&nbsp;over&nbsp;speed.<br>
+The&nbsp;implementation&nbsp;is&nbsp;left&nbsp;in&nbsp;comments&nbsp;in&nbsp;case&nbsp;anyone&nbsp;needs&nbsp;to&nbsp;hack&nbsp;this<br>
+feature&nbsp;back&nbsp;into&nbsp;their&nbsp;copy.<br>
+If&nbsp;someone&nbsp;wants&nbsp;to&nbsp;diff&nbsp;this&nbsp;with&nbsp;expect_list&nbsp;and&nbsp;make&nbsp;them&nbsp;work<br>
+nearly&nbsp;the&nbsp;same&nbsp;then&nbsp;I&nbsp;will&nbsp;consider&nbsp;adding&nbsp;this&nbsp;make&nbsp;in.</tt></dd></dl>
+
+<dl><dt><a name="pxssh-expect_list"><strong>expect_list</strong></a>(self, pattern_list, timeout<font color="#909090">=-1</font>, searchwindowsize<font color="#909090">=-1</font>)</dt><dd><tt>This&nbsp;takes&nbsp;a&nbsp;list&nbsp;of&nbsp;compiled&nbsp;regular&nbsp;expressions&nbsp;and&nbsp;returns&nbsp;<br>
+the&nbsp;index&nbsp;into&nbsp;the&nbsp;pattern_list&nbsp;that&nbsp;matched&nbsp;the&nbsp;child&nbsp;output.<br>
+The&nbsp;list&nbsp;may&nbsp;also&nbsp;contain&nbsp;EOF&nbsp;or&nbsp;TIMEOUT&nbsp;(which&nbsp;are&nbsp;not<br>
+compiled&nbsp;regular&nbsp;expressions).&nbsp;This&nbsp;method&nbsp;is&nbsp;similar&nbsp;to<br>
+the&nbsp;<a href="#pxssh-expect">expect</a>()&nbsp;method&nbsp;except&nbsp;that&nbsp;<a href="#pxssh-expect_list">expect_list</a>()&nbsp;does&nbsp;not<br>
+recompile&nbsp;the&nbsp;pattern&nbsp;list&nbsp;on&nbsp;every&nbsp;call.<br>
+This&nbsp;may&nbsp;help&nbsp;if&nbsp;you&nbsp;are&nbsp;trying&nbsp;to&nbsp;optimize&nbsp;for&nbsp;speed,&nbsp;otherwise<br>
+just&nbsp;use&nbsp;the&nbsp;<a href="#pxssh-expect">expect</a>()&nbsp;method.&nbsp;&nbsp;This&nbsp;is&nbsp;called&nbsp;by&nbsp;<a href="#pxssh-expect">expect</a>().<br>
+If&nbsp;timeout==-1&nbsp;then&nbsp;the&nbsp;self.<strong>timeout</strong>&nbsp;value&nbsp;is&nbsp;used.<br>
+If&nbsp;searchwindowsize==-1&nbsp;then&nbsp;the&nbsp;self.<strong>searchwindowsize</strong>&nbsp;value&nbsp;is&nbsp;used.</tt></dd></dl>
+
+<dl><dt><a name="pxssh-fileno"><strong>fileno</strong></a>(self)</dt><dd><tt>This&nbsp;returns&nbsp;the&nbsp;file&nbsp;descriptor&nbsp;of&nbsp;the&nbsp;pty&nbsp;for&nbsp;the&nbsp;child.</tt></dd></dl>
+
+<dl><dt><a name="pxssh-flush"><strong>flush</strong></a>(self)</dt><dd><tt>This&nbsp;does&nbsp;nothing.&nbsp;It&nbsp;is&nbsp;here&nbsp;to&nbsp;support&nbsp;the&nbsp;interface&nbsp;for&nbsp;a&nbsp;File-like&nbsp;object.</tt></dd></dl>
+
+<dl><dt><a name="pxssh-getwinsize"><strong>getwinsize</strong></a>(self)</dt><dd><tt>This&nbsp;returns&nbsp;the&nbsp;terminal&nbsp;window&nbsp;size&nbsp;of&nbsp;the&nbsp;child&nbsp;tty.<br>
+The&nbsp;return&nbsp;value&nbsp;is&nbsp;a&nbsp;tuple&nbsp;of&nbsp;(rows,&nbsp;cols).</tt></dd></dl>
+
+<dl><dt><a name="pxssh-interact"><strong>interact</strong></a>(self, escape_character<font color="#909090">='<font color="#c040c0">\x1d</font>'</font>, input_filter<font color="#909090">=None</font>, output_filter<font color="#909090">=None</font>)</dt><dd><tt>This&nbsp;gives&nbsp;control&nbsp;of&nbsp;the&nbsp;child&nbsp;process&nbsp;to&nbsp;the&nbsp;interactive&nbsp;user<br>
+(the&nbsp;human&nbsp;at&nbsp;the&nbsp;keyboard).<br>
+Keystrokes&nbsp;are&nbsp;sent&nbsp;to&nbsp;the&nbsp;child&nbsp;process,&nbsp;and&nbsp;the&nbsp;stdout&nbsp;and&nbsp;stderr<br>
+output&nbsp;of&nbsp;the&nbsp;child&nbsp;process&nbsp;is&nbsp;printed.<br>
+This&nbsp;simply&nbsp;echos&nbsp;the&nbsp;child&nbsp;stdout&nbsp;and&nbsp;child&nbsp;stderr&nbsp;to&nbsp;the&nbsp;real<br>
+stdout&nbsp;and&nbsp;it&nbsp;echos&nbsp;the&nbsp;real&nbsp;stdin&nbsp;to&nbsp;the&nbsp;child&nbsp;stdin.<br>
+When&nbsp;the&nbsp;user&nbsp;types&nbsp;the&nbsp;escape_character&nbsp;this&nbsp;method&nbsp;will&nbsp;stop.<br>
+The&nbsp;default&nbsp;for&nbsp;escape_character&nbsp;is&nbsp;^].&nbsp;This&nbsp;should&nbsp;not&nbsp;be&nbsp;confused<br>
+with&nbsp;ASCII&nbsp;27&nbsp;--&nbsp;the&nbsp;ESC&nbsp;character.&nbsp;ASCII&nbsp;29&nbsp;was&nbsp;chosen<br>
+for&nbsp;historical&nbsp;merit&nbsp;because&nbsp;this&nbsp;is&nbsp;the&nbsp;character&nbsp;used<br>
+by&nbsp;'telnet'&nbsp;as&nbsp;the&nbsp;escape&nbsp;character.&nbsp;The&nbsp;escape_character&nbsp;will<br>
+not&nbsp;be&nbsp;sent&nbsp;to&nbsp;the&nbsp;child&nbsp;process.<br>
+&nbsp;<br>
+You&nbsp;may&nbsp;pass&nbsp;in&nbsp;optional&nbsp;input&nbsp;and&nbsp;output&nbsp;filter&nbsp;functions.<br>
+These&nbsp;functions&nbsp;should&nbsp;take&nbsp;a&nbsp;string&nbsp;and&nbsp;return&nbsp;a&nbsp;string.<br>
+The&nbsp;output_filter&nbsp;will&nbsp;be&nbsp;passed&nbsp;all&nbsp;the&nbsp;output&nbsp;from&nbsp;the&nbsp;child&nbsp;process.<br>
+The&nbsp;input_filter&nbsp;will&nbsp;be&nbsp;passed&nbsp;all&nbsp;the&nbsp;keyboard&nbsp;input&nbsp;from&nbsp;the&nbsp;user.<br>
+The&nbsp;input_filter&nbsp;is&nbsp;run&nbsp;BEFORE&nbsp;the&nbsp;check&nbsp;for&nbsp;the&nbsp;escape_character.<br>
+&nbsp;<br>
+Note&nbsp;that&nbsp;if&nbsp;you&nbsp;change&nbsp;the&nbsp;window&nbsp;size&nbsp;of&nbsp;the&nbsp;parent<br>
+the&nbsp;SIGWINCH&nbsp;signal&nbsp;will&nbsp;not&nbsp;be&nbsp;passed&nbsp;through&nbsp;to&nbsp;the&nbsp;child.<br>
+If&nbsp;you&nbsp;want&nbsp;the&nbsp;child&nbsp;window&nbsp;size&nbsp;to&nbsp;change&nbsp;when&nbsp;the&nbsp;parent's<br>
+window&nbsp;size&nbsp;changes&nbsp;then&nbsp;do&nbsp;something&nbsp;like&nbsp;the&nbsp;following&nbsp;example:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;import&nbsp;pexpect,&nbsp;struct,&nbsp;fcntl,&nbsp;termios,&nbsp;signal,&nbsp;sys<br>
+&nbsp;&nbsp;&nbsp;&nbsp;def&nbsp;sigwinch_passthrough&nbsp;(sig,&nbsp;data):<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;s&nbsp;=&nbsp;struct.pack("HHHH",&nbsp;0,&nbsp;0,&nbsp;0,&nbsp;0)<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a&nbsp;=&nbsp;struct.unpack('hhhh',&nbsp;fcntl.ioctl(sys.stdout.<a href="#pxssh-fileno">fileno</a>(),&nbsp;termios.TIOCGWINSZ&nbsp;,&nbsp;s))<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;global&nbsp;p<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p.<a href="#pxssh-setwinsize">setwinsize</a>(a[0],a[1])<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p&nbsp;=&nbsp;pexpect.<a href="pexpect.html#spawn">spawn</a>('/bin/bash')&nbsp;#&nbsp;Note&nbsp;this&nbsp;is&nbsp;global&nbsp;and&nbsp;used&nbsp;in&nbsp;sigwinch_passthrough.<br>
+&nbsp;&nbsp;&nbsp;&nbsp;signal.signal(signal.SIGWINCH,&nbsp;sigwinch_passthrough)<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p.<a href="#pxssh-interact">interact</a>()</tt></dd></dl>
+
+<dl><dt><a name="pxssh-isalive"><strong>isalive</strong></a>(self)</dt><dd><tt>This&nbsp;tests&nbsp;if&nbsp;the&nbsp;child&nbsp;process&nbsp;is&nbsp;running&nbsp;or&nbsp;not.<br>
+This&nbsp;is&nbsp;non-blocking.&nbsp;If&nbsp;the&nbsp;child&nbsp;was&nbsp;terminated&nbsp;then&nbsp;this<br>
+will&nbsp;read&nbsp;the&nbsp;exitstatus&nbsp;or&nbsp;signalstatus&nbsp;of&nbsp;the&nbsp;child.<br>
+This&nbsp;returns&nbsp;True&nbsp;if&nbsp;the&nbsp;child&nbsp;process&nbsp;appears&nbsp;to&nbsp;be&nbsp;running&nbsp;or&nbsp;False&nbsp;if&nbsp;not.<br>
+It&nbsp;can&nbsp;take&nbsp;literally&nbsp;SECONDS&nbsp;for&nbsp;Solaris&nbsp;to&nbsp;return&nbsp;the&nbsp;right&nbsp;status.</tt></dd></dl>
+
+<dl><dt><a name="pxssh-isatty"><strong>isatty</strong></a>(self)</dt><dd><tt>This&nbsp;returns&nbsp;True&nbsp;if&nbsp;the&nbsp;file&nbsp;descriptor&nbsp;is&nbsp;open&nbsp;and&nbsp;connected&nbsp;to&nbsp;a&nbsp;tty(-like)&nbsp;device,&nbsp;else&nbsp;False.</tt></dd></dl>
+
+<dl><dt><a name="pxssh-kill"><strong>kill</strong></a>(self, sig)</dt><dd><tt>This&nbsp;sends&nbsp;the&nbsp;given&nbsp;signal&nbsp;to&nbsp;the&nbsp;child&nbsp;application.<br>
+In&nbsp;keeping&nbsp;with&nbsp;UNIX&nbsp;tradition&nbsp;it&nbsp;has&nbsp;a&nbsp;misleading&nbsp;name.<br>
+It&nbsp;does&nbsp;not&nbsp;necessarily&nbsp;kill&nbsp;the&nbsp;child&nbsp;unless<br>
+you&nbsp;send&nbsp;the&nbsp;right&nbsp;signal.</tt></dd></dl>
+
+<dl><dt><a name="pxssh-next"><strong>next</strong></a>(self)</dt><dd><tt>This&nbsp;is&nbsp;to&nbsp;support&nbsp;iterators&nbsp;over&nbsp;a&nbsp;file-like&nbsp;object.</tt></dd></dl>
+
+<dl><dt><a name="pxssh-read"><strong>read</strong></a>(self, size<font color="#909090">=-1</font>)</dt><dd><tt>This&nbsp;reads&nbsp;at&nbsp;most&nbsp;"size"&nbsp;bytes&nbsp;from&nbsp;the&nbsp;file&nbsp;<br>
+(less&nbsp;if&nbsp;the&nbsp;read&nbsp;hits&nbsp;EOF&nbsp;before&nbsp;obtaining&nbsp;size&nbsp;bytes).&nbsp;<br>
+If&nbsp;the&nbsp;size&nbsp;argument&nbsp;is&nbsp;negative&nbsp;or&nbsp;omitted,&nbsp;<br>
+read&nbsp;all&nbsp;data&nbsp;until&nbsp;EOF&nbsp;is&nbsp;reached.&nbsp;<br>
+The&nbsp;bytes&nbsp;are&nbsp;returned&nbsp;as&nbsp;a&nbsp;string&nbsp;object.&nbsp;<br>
+An&nbsp;empty&nbsp;string&nbsp;is&nbsp;returned&nbsp;when&nbsp;EOF&nbsp;is&nbsp;encountered&nbsp;immediately.</tt></dd></dl>
+
+<dl><dt><a name="pxssh-read_nonblocking"><strong>read_nonblocking</strong></a>(self, size<font color="#909090">=1</font>, timeout<font color="#909090">=-1</font>)</dt><dd><tt>This&nbsp;reads&nbsp;at&nbsp;most&nbsp;size&nbsp;characters&nbsp;from&nbsp;the&nbsp;child&nbsp;application.<br>
+It&nbsp;includes&nbsp;a&nbsp;timeout.&nbsp;If&nbsp;the&nbsp;read&nbsp;does&nbsp;not&nbsp;complete&nbsp;within&nbsp;the<br>
+timeout&nbsp;period&nbsp;then&nbsp;a&nbsp;TIMEOUT&nbsp;exception&nbsp;is&nbsp;raised.<br>
+If&nbsp;the&nbsp;end&nbsp;of&nbsp;file&nbsp;is&nbsp;read&nbsp;then&nbsp;an&nbsp;EOF&nbsp;exception&nbsp;will&nbsp;be&nbsp;raised.<br>
+If&nbsp;a&nbsp;log&nbsp;file&nbsp;was&nbsp;set&nbsp;using&nbsp;<a href="#pxssh-setlog">setlog</a>()&nbsp;then&nbsp;all&nbsp;data&nbsp;will<br>
+also&nbsp;be&nbsp;written&nbsp;to&nbsp;the&nbsp;log&nbsp;file.<br>
+&nbsp;<br>
+If&nbsp;timeout==None&nbsp;then&nbsp;the&nbsp;read&nbsp;may&nbsp;block&nbsp;indefinitely.<br>
+If&nbsp;timeout==-1&nbsp;then&nbsp;the&nbsp;self.<strong>timeout</strong>&nbsp;value&nbsp;is&nbsp;used.<br>
+If&nbsp;timeout==0&nbsp;then&nbsp;the&nbsp;child&nbsp;is&nbsp;polled&nbsp;and&nbsp;<br>
+&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;there&nbsp;was&nbsp;no&nbsp;data&nbsp;immediately&nbsp;ready&nbsp;then&nbsp;this&nbsp;will&nbsp;raise&nbsp;a&nbsp;TIMEOUT&nbsp;exception.<br>
+&nbsp;<br>
+The&nbsp;"timeout"&nbsp;refers&nbsp;only&nbsp;to&nbsp;the&nbsp;amount&nbsp;of&nbsp;time&nbsp;to&nbsp;read&nbsp;at&nbsp;least&nbsp;one&nbsp;character.<br>
+This&nbsp;is&nbsp;not&nbsp;effected&nbsp;by&nbsp;the&nbsp;'size'&nbsp;parameter,&nbsp;so&nbsp;if&nbsp;you&nbsp;call<br>
+<a href="#pxssh-read_nonblocking">read_nonblocking</a>(size=100,&nbsp;timeout=30)&nbsp;and&nbsp;only&nbsp;one&nbsp;character&nbsp;is<br>
+available&nbsp;right&nbsp;away&nbsp;then&nbsp;one&nbsp;character&nbsp;will&nbsp;be&nbsp;returned&nbsp;immediately.&nbsp;<br>
+It&nbsp;will&nbsp;not&nbsp;wait&nbsp;for&nbsp;30&nbsp;seconds&nbsp;for&nbsp;another&nbsp;99&nbsp;characters&nbsp;to&nbsp;come&nbsp;in.<br>
+&nbsp;<br>
+This&nbsp;is&nbsp;a&nbsp;wrapper&nbsp;around&nbsp;os.<a href="#pxssh-read">read</a>().<br>
+It&nbsp;uses&nbsp;select.select()&nbsp;to&nbsp;implement&nbsp;a&nbsp;timeout.</tt></dd></dl>
+
+<dl><dt><a name="pxssh-readline"><strong>readline</strong></a>(self, size<font color="#909090">=-1</font>)</dt><dd><tt>This&nbsp;reads&nbsp;and&nbsp;returns&nbsp;one&nbsp;entire&nbsp;line.&nbsp;A&nbsp;trailing&nbsp;newline&nbsp;is&nbsp;kept&nbsp;in<br>
+the&nbsp;string,&nbsp;but&nbsp;may&nbsp;be&nbsp;absent&nbsp;when&nbsp;a&nbsp;file&nbsp;ends&nbsp;with&nbsp;an&nbsp;incomplete&nbsp;line.&nbsp;<br>
+Note:&nbsp;This&nbsp;<a href="#pxssh-readline">readline</a>()&nbsp;looks&nbsp;for&nbsp;a&nbsp;\r\n&nbsp;pair&nbsp;even&nbsp;on&nbsp;UNIX&nbsp;because<br>
+this&nbsp;is&nbsp;what&nbsp;the&nbsp;pseudo&nbsp;tty&nbsp;device&nbsp;returns.&nbsp;So&nbsp;contrary&nbsp;to&nbsp;what&nbsp;you<br>
+may&nbsp;expect&nbsp;you&nbsp;will&nbsp;receive&nbsp;the&nbsp;newline&nbsp;as&nbsp;\r\n.<br>
+An&nbsp;empty&nbsp;string&nbsp;is&nbsp;returned&nbsp;when&nbsp;EOF&nbsp;is&nbsp;hit&nbsp;immediately.<br>
+Currently,&nbsp;the&nbsp;size&nbsp;agument&nbsp;is&nbsp;mostly&nbsp;ignored,&nbsp;so&nbsp;this&nbsp;behavior&nbsp;is&nbsp;not<br>
+standard&nbsp;for&nbsp;a&nbsp;file-like&nbsp;object.&nbsp;If&nbsp;size&nbsp;is&nbsp;0&nbsp;then&nbsp;an&nbsp;empty&nbsp;string<br>
+is&nbsp;returned.</tt></dd></dl>
+
+<dl><dt><a name="pxssh-readlines"><strong>readlines</strong></a>(self, sizehint<font color="#909090">=-1</font>)</dt><dd><tt>This&nbsp;reads&nbsp;until&nbsp;EOF&nbsp;using&nbsp;<a href="#pxssh-readline">readline</a>()&nbsp;and&nbsp;returns&nbsp;a&nbsp;list&nbsp;containing&nbsp;<br>
+the&nbsp;lines&nbsp;thus&nbsp;read.&nbsp;The&nbsp;optional&nbsp;"sizehint"&nbsp;argument&nbsp;is&nbsp;ignored.</tt></dd></dl>
+
+<dl><dt><a name="pxssh-send"><strong>send</strong></a>(self, str)</dt><dd><tt>This&nbsp;sends&nbsp;a&nbsp;string&nbsp;to&nbsp;the&nbsp;child&nbsp;process.<br>
+This&nbsp;returns&nbsp;the&nbsp;number&nbsp;of&nbsp;bytes&nbsp;written.<br>
+If&nbsp;a&nbsp;log&nbsp;file&nbsp;was&nbsp;set&nbsp;then&nbsp;the&nbsp;data&nbsp;is&nbsp;also&nbsp;written&nbsp;to&nbsp;the&nbsp;log.</tt></dd></dl>
+
+<dl><dt><a name="pxssh-sendeof"><strong>sendeof</strong></a>(self)</dt><dd><tt>This&nbsp;sends&nbsp;an&nbsp;EOF&nbsp;to&nbsp;the&nbsp;child.<br>
+This&nbsp;sends&nbsp;a&nbsp;character&nbsp;which&nbsp;causes&nbsp;the&nbsp;pending&nbsp;parent&nbsp;output<br>
+buffer&nbsp;to&nbsp;be&nbsp;sent&nbsp;to&nbsp;the&nbsp;waiting&nbsp;child&nbsp;program&nbsp;without<br>
+waiting&nbsp;for&nbsp;end-of-line.&nbsp;If&nbsp;it&nbsp;is&nbsp;the&nbsp;first&nbsp;character&nbsp;of&nbsp;the<br>
+line,&nbsp;the&nbsp;<a href="#pxssh-read">read</a>()&nbsp;in&nbsp;the&nbsp;user&nbsp;program&nbsp;returns&nbsp;0,&nbsp;which<br>
+signifies&nbsp;end-of-file.&nbsp;This&nbsp;means&nbsp;to&nbsp;work&nbsp;as&nbsp;expected&nbsp;<br>
+a&nbsp;<a href="#pxssh-sendeof">sendeof</a>()&nbsp;has&nbsp;to&nbsp;be&nbsp;called&nbsp;at&nbsp;the&nbsp;begining&nbsp;of&nbsp;a&nbsp;line.&nbsp;<br>
+This&nbsp;method&nbsp;does&nbsp;not&nbsp;send&nbsp;a&nbsp;newline.&nbsp;It&nbsp;is&nbsp;the&nbsp;responsibility<br>
+of&nbsp;the&nbsp;caller&nbsp;to&nbsp;ensure&nbsp;the&nbsp;eof&nbsp;is&nbsp;sent&nbsp;at&nbsp;the&nbsp;beginning&nbsp;of&nbsp;a&nbsp;line.</tt></dd></dl>
+
+<dl><dt><a name="pxssh-sendline"><strong>sendline</strong></a>(self, str<font color="#909090">=''</font>)</dt><dd><tt>This&nbsp;is&nbsp;like&nbsp;<a href="#pxssh-send">send</a>(),&nbsp;but&nbsp;it&nbsp;adds&nbsp;a&nbsp;line&nbsp;feed&nbsp;(os.linesep).<br>
+This&nbsp;returns&nbsp;the&nbsp;number&nbsp;of&nbsp;bytes&nbsp;written.</tt></dd></dl>
+
+<dl><dt><a name="pxssh-setecho"><strong>setecho</strong></a>(self, state)</dt><dd><tt>This&nbsp;sets&nbsp;the&nbsp;terminal&nbsp;echo&nbsp;mode&nbsp;on&nbsp;or&nbsp;off.<br>
+Note&nbsp;that&nbsp;anything&nbsp;the&nbsp;child&nbsp;sent&nbsp;before&nbsp;the&nbsp;echo&nbsp;will&nbsp;be&nbsp;lost,&nbsp;so<br>
+you&nbsp;should&nbsp;be&nbsp;sure&nbsp;that&nbsp;your&nbsp;input&nbsp;buffer&nbsp;is&nbsp;empty&nbsp;before&nbsp;you&nbsp;setecho.<br>
+For&nbsp;example,&nbsp;the&nbsp;following&nbsp;will&nbsp;work&nbsp;as&nbsp;expected.<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p&nbsp;=&nbsp;pexpect.<a href="pexpect.html#spawn">spawn</a>('cat')<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p.sendline&nbsp;('1234')&nbsp;#&nbsp;We&nbsp;will&nbsp;see&nbsp;this&nbsp;twice&nbsp;(once&nbsp;from&nbsp;tty&nbsp;echo&nbsp;and&nbsp;again&nbsp;from&nbsp;cat).<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p.expect&nbsp;(['1234'])<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p.expect&nbsp;(['1234'])<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p.<a href="#pxssh-setecho">setecho</a>(False)&nbsp;#&nbsp;Turn&nbsp;off&nbsp;tty&nbsp;echo<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p.sendline&nbsp;('abcd')&nbsp;#&nbsp;We&nbsp;will&nbsp;set&nbsp;this&nbsp;only&nbsp;once&nbsp;(echoed&nbsp;by&nbsp;cat).<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p.sendline&nbsp;('wxyz')&nbsp;#&nbsp;We&nbsp;will&nbsp;set&nbsp;this&nbsp;only&nbsp;once&nbsp;(echoed&nbsp;by&nbsp;cat)<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p.expect&nbsp;(['abcd'])<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p.expect&nbsp;(['wxyz'])<br>
+The&nbsp;following&nbsp;WILL&nbsp;NOT&nbsp;WORK&nbsp;because&nbsp;the&nbsp;lines&nbsp;sent&nbsp;before&nbsp;the&nbsp;setecho<br>
+will&nbsp;be&nbsp;lost:<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p&nbsp;=&nbsp;pexpect.<a href="pexpect.html#spawn">spawn</a>('cat')<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p.sendline&nbsp;('1234')&nbsp;#&nbsp;We&nbsp;will&nbsp;see&nbsp;this&nbsp;twice&nbsp;(once&nbsp;from&nbsp;tty&nbsp;echo&nbsp;and&nbsp;again&nbsp;from&nbsp;cat).<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p.<a href="#pxssh-setecho">setecho</a>(False)&nbsp;#&nbsp;Turn&nbsp;off&nbsp;tty&nbsp;echo<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p.sendline&nbsp;('abcd')&nbsp;#&nbsp;We&nbsp;will&nbsp;set&nbsp;this&nbsp;only&nbsp;once&nbsp;(echoed&nbsp;by&nbsp;cat).<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p.sendline&nbsp;('wxyz')&nbsp;#&nbsp;We&nbsp;will&nbsp;set&nbsp;this&nbsp;only&nbsp;once&nbsp;(echoed&nbsp;by&nbsp;cat)<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p.expect&nbsp;(['1234'])<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p.expect&nbsp;(['1234'])<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p.expect&nbsp;(['abcd'])<br>
+&nbsp;&nbsp;&nbsp;&nbsp;p.expect&nbsp;(['wxyz'])</tt></dd></dl>
+
+<dl><dt><a name="pxssh-setlog"><strong>setlog</strong></a>(self, fileobject)</dt><dd><tt>This&nbsp;method&nbsp;is&nbsp;no&nbsp;longer&nbsp;supported&nbsp;or&nbsp;allowed.</tt></dd></dl>
+
+<dl><dt><a name="pxssh-setmaxread"><strong>setmaxread</strong></a>(self, maxread)</dt><dd><tt>This&nbsp;method&nbsp;is&nbsp;no&nbsp;longer&nbsp;supported&nbsp;or&nbsp;allowed.<br>
+I&nbsp;don't&nbsp;like&nbsp;getters&nbsp;and&nbsp;setters&nbsp;without&nbsp;a&nbsp;good&nbsp;reason.</tt></dd></dl>
+
+<dl><dt><a name="pxssh-setwinsize"><strong>setwinsize</strong></a>(self, r, c)</dt><dd><tt>This&nbsp;sets&nbsp;the&nbsp;terminal&nbsp;window&nbsp;size&nbsp;of&nbsp;the&nbsp;child&nbsp;tty.<br>
+This&nbsp;will&nbsp;cause&nbsp;a&nbsp;SIGWINCH&nbsp;signal&nbsp;to&nbsp;be&nbsp;sent&nbsp;to&nbsp;the&nbsp;child.<br>
+This&nbsp;does&nbsp;not&nbsp;change&nbsp;the&nbsp;physical&nbsp;window&nbsp;size.<br>
+It&nbsp;changes&nbsp;the&nbsp;size&nbsp;reported&nbsp;to&nbsp;TTY-aware&nbsp;applications&nbsp;like<br>
+vi&nbsp;or&nbsp;curses&nbsp;--&nbsp;applications&nbsp;that&nbsp;respond&nbsp;to&nbsp;the&nbsp;SIGWINCH&nbsp;signal.</tt></dd></dl>
+
+<dl><dt><a name="pxssh-terminate"><strong>terminate</strong></a>(self, force<font color="#909090">=False</font>)</dt><dd><tt>This&nbsp;forces&nbsp;a&nbsp;child&nbsp;process&nbsp;to&nbsp;terminate.<br>
+It&nbsp;starts&nbsp;nicely&nbsp;with&nbsp;SIGHUP&nbsp;and&nbsp;SIGINT.&nbsp;If&nbsp;"force"&nbsp;is&nbsp;True&nbsp;then<br>
+moves&nbsp;onto&nbsp;SIGKILL.<br>
+This&nbsp;returns&nbsp;True&nbsp;if&nbsp;the&nbsp;child&nbsp;was&nbsp;terminated.<br>
+This&nbsp;returns&nbsp;False&nbsp;if&nbsp;the&nbsp;child&nbsp;could&nbsp;not&nbsp;be&nbsp;terminated.</tt></dd></dl>
+
+<dl><dt><a name="pxssh-wait"><strong>wait</strong></a>(self)</dt><dd><tt>This&nbsp;waits&nbsp;until&nbsp;the&nbsp;child&nbsp;exits.&nbsp;This&nbsp;is&nbsp;a&nbsp;blocking&nbsp;call.<br>
+This&nbsp;will&nbsp;not&nbsp;read&nbsp;any&nbsp;data&nbsp;from&nbsp;the&nbsp;child,&nbsp;so&nbsp;this&nbsp;will&nbsp;block&nbsp;forever<br>
+if&nbsp;the&nbsp;child&nbsp;has&nbsp;unread&nbsp;output&nbsp;and&nbsp;has&nbsp;terminated.&nbsp;In&nbsp;other&nbsp;words,&nbsp;the&nbsp;child<br>
+may&nbsp;have&nbsp;printed&nbsp;output&nbsp;then&nbsp;called&nbsp;exit();&nbsp;but,&nbsp;technically,&nbsp;the&nbsp;child&nbsp;is<br>
+still&nbsp;alive&nbsp;until&nbsp;its&nbsp;output&nbsp;is&nbsp;read.</tt></dd></dl>
+
+<dl><dt><a name="pxssh-write"><strong>write</strong></a>(self, str)</dt><dd><tt>This&nbsp;is&nbsp;similar&nbsp;to&nbsp;<a href="#pxssh-send">send</a>()&nbsp;except&nbsp;that&nbsp;there&nbsp;is&nbsp;no&nbsp;return&nbsp;value.</tt></dd></dl>
+
+<dl><dt><a name="pxssh-writelines"><strong>writelines</strong></a>(self, sequence)</dt><dd><tt>This&nbsp;calls&nbsp;<a href="#pxssh-write">write</a>()&nbsp;for&nbsp;each&nbsp;element&nbsp;in&nbsp;the&nbsp;sequence.<br>
+The&nbsp;sequence&nbsp;can&nbsp;be&nbsp;any&nbsp;iterable&nbsp;object&nbsp;producing&nbsp;strings,&nbsp;<br>
+typically&nbsp;a&nbsp;list&nbsp;of&nbsp;strings.&nbsp;This&nbsp;does&nbsp;not&nbsp;add&nbsp;line&nbsp;separators<br>
+There&nbsp;is&nbsp;no&nbsp;return&nbsp;value.</tt></dd></dl>
+
+<hr>
+Data and other attributes inherited from <a href="pexpect.html#spawn">pexpect.spawn</a>:<br>
+<dl><dt><strong>__dict__</strong> = &lt;dictproxy object&gt;<dd><tt>dictionary&nbsp;for&nbsp;instance&nbsp;variables&nbsp;(if&nbsp;defined)</tt></dl>
+
+<dl><dt><strong>__weakref__</strong> = &lt;attribute '__weakref__' of 'spawn' objects&gt;<dd><tt>list&nbsp;of&nbsp;weak&nbsp;references&nbsp;to&nbsp;the&nbsp;object&nbsp;(if&nbsp;defined)</tt></dl>
+
+</td></tr></table></td></tr></table><p>
+<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
+<tr bgcolor="#55aa55">
+<td colspan=3 valign=bottom>&nbsp;<br>
+<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
+    
+<tr><td bgcolor="#55aa55"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
+<td width="100%"><strong>__revision__</strong> = '$Revision: 395 $'<br>
+<strong>__version__</strong> = '2.1'</td></tr></table>
+</body></html>

Added: packages/pexpect/branches/upstream/current/doc/screen.html
URL: http://svn.debian.org/wsvn/python-modules/packages/pexpect/branches/upstream/current/doc/screen.html?rev=929&op=file
==============================================================================
--- packages/pexpect/branches/upstream/current/doc/screen.html (added)
+++ packages/pexpect/branches/upstream/current/doc/screen.html Mon Jun 19 10:53:24 2006
@@ -1,0 +1,174 @@
+
+<!doctype html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html><head><title>Python: module screen</title>
+</head><body bgcolor="#f0f0f8">
+
+<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
+<tr bgcolor="#7799ee">
+<td valign=bottom>&nbsp;<br>
+<font color="#ffffff" face="helvetica, arial">&nbsp;<br><big><big><strong>screen</strong></big></big></font></td
+><td align=right valign=bottom
+><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/noah/documents/export/engineering/source/python/pexpect/trunk/pexpect/screen.py">/home/noah/documents/export/engineering/source/python/pexpect/trunk/pexpect/screen.py</a></font></td></tr></table>
+    <p><tt>$Revision:&nbsp;372&nbsp;$<br>
+$Date:&nbsp;2006-03-05&nbsp;18:19:39&nbsp;-0800&nbsp;(Sun,&nbsp;05&nbsp;Mar&nbsp;2006)&nbsp;$</tt></p>
+<p>
+<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
+<tr bgcolor="#aa55cc">
+<td colspan=3 valign=bottom>&nbsp;<br>
+<font color="#fffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
+    
+<tr><td bgcolor="#aa55cc"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
+<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="copy.html">copy</a><br>
+</td><td width="25%" valign=top></td><td width="25%" valign=top></td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
+<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
+<tr bgcolor="#ee77aa">
+<td colspan=3 valign=bottom>&nbsp;<br>
+<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
+    
+<tr><td bgcolor="#ee77aa"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
+<td width="100%"><dl>
+<dt><font face="helvetica, arial"><a href="screen.html#screen">screen</a>
+</font></dt></dl>
+ <p>
+<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
+<tr bgcolor="#ffc8d8">
+<td colspan=3 valign=bottom>&nbsp;<br>
+<font color="#000000" face="helvetica, arial"><a name="screen">class <strong>screen</strong></a></font></td></tr>
+    
+<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
+<td colspan=2><tt>This&nbsp;maintains&nbsp;the&nbsp;state&nbsp;of&nbsp;a&nbsp;virtual&nbsp;text&nbsp;<a href="#screen">screen</a>.<br>
+This&nbsp;maintains&nbsp;a&nbsp;cursor&nbsp;position&nbsp;and&nbsp;handles<br>
+scrolling&nbsp;as&nbsp;characters&nbsp;are&nbsp;added.<br>
+This&nbsp;supports&nbsp;most&nbsp;of&nbsp;the&nbsp;methods&nbsp;needed&nbsp;by&nbsp;an<br>
+ANSI&nbsp;text&nbsp;<a href="#screen">screen</a>.<br>
+Row&nbsp;and&nbsp;column&nbsp;indexes&nbsp;are&nbsp;1-based&nbsp;(not&nbsp;zero-based,<br>
+like&nbsp;arrays).<br>&nbsp;</tt></td></tr>
+<tr><td>&nbsp;</td>
+<td width="100%">Methods defined here:<br>
+<dl><dt><a name="screen-__init__"><strong>__init__</strong></a>(self, r<font color="#909090">=24</font>, c<font color="#909090">=80</font>)</dt></dl>
+
+<dl><dt><a name="screen-__str__"><strong>__str__</strong></a>(self)</dt></dl>
+
+<dl><dt><a name="screen-clear_all_tabs"><strong>clear_all_tabs</strong></a>(self)</dt><dd><tt>Clears&nbsp;all&nbsp;tabs.</tt></dd></dl>
+
+<dl><dt><a name="screen-clear_tab"><strong>clear_tab</strong></a>(self)</dt><dd><tt>Clears&nbsp;tab&nbsp;at&nbsp;the&nbsp;current&nbsp;position.</tt></dd></dl>
+
+<dl><dt><a name="screen-cr"><strong>cr</strong></a>(self)</dt><dd><tt>This&nbsp;moves&nbsp;the&nbsp;cursor&nbsp;to&nbsp;the&nbsp;beginning&nbsp;(col&nbsp;1)&nbsp;of&nbsp;the&nbsp;current&nbsp;row.</tt></dd></dl>
+
+<dl><dt><a name="screen-crlf"><strong>crlf</strong></a>(self)</dt><dd><tt>This&nbsp;advances&nbsp;the&nbsp;cursor&nbsp;with&nbsp;CRLF&nbsp;properties.<br>
+The&nbsp;cursor&nbsp;will&nbsp;line&nbsp;wrap&nbsp;and&nbsp;the&nbsp;<a href="#screen">screen</a>&nbsp;may&nbsp;scroll.</tt></dd></dl>
+
+<dl><dt><a name="screen-cursor_back"><strong>cursor_back</strong></a>(self, count<font color="#909090">=1</font>)</dt></dl>
+
+<dl><dt><a name="screen-cursor_constrain"><strong>cursor_constrain</strong></a>(self)</dt><dd><tt>This&nbsp;keeps&nbsp;the&nbsp;cursor&nbsp;within&nbsp;the&nbsp;<a href="#screen">screen</a>&nbsp;area.</tt></dd></dl>
+
+<dl><dt><a name="screen-cursor_down"><strong>cursor_down</strong></a>(self, count<font color="#909090">=1</font>)</dt></dl>
+
+<dl><dt><a name="screen-cursor_force_position"><strong>cursor_force_position</strong></a>(self, r, c)</dt><dd><tt>Identical&nbsp;to&nbsp;Cursor&nbsp;Home.</tt></dd></dl>
+
+<dl><dt><a name="screen-cursor_forward"><strong>cursor_forward</strong></a>(self, count<font color="#909090">=1</font>)</dt></dl>
+
+<dl><dt><a name="screen-cursor_home"><strong>cursor_home</strong></a>(self, r<font color="#909090">=1</font>, c<font color="#909090">=1</font>)</dt></dl>
+
+<dl><dt><a name="screen-cursor_restore_attrs"><strong>cursor_restore_attrs</strong></a>(self)</dt><dd><tt>Restores&nbsp;cursor&nbsp;position&nbsp;after&nbsp;a&nbsp;Save&nbsp;Cursor.</tt></dd></dl>
+
+<dl><dt><a name="screen-cursor_save"><strong>cursor_save</strong></a>(self)</dt><dd><tt>Save&nbsp;current&nbsp;cursor&nbsp;position.</tt></dd></dl>
+
+<dl><dt><a name="screen-cursor_save_attrs"><strong>cursor_save_attrs</strong></a>(self)</dt><dd><tt>Save&nbsp;current&nbsp;cursor&nbsp;position.</tt></dd></dl>
+
+<dl><dt><a name="screen-cursor_unsave"><strong>cursor_unsave</strong></a>(self)</dt><dd><tt>Restores&nbsp;cursor&nbsp;position&nbsp;after&nbsp;a&nbsp;Save&nbsp;Cursor.</tt></dd></dl>
+
+<dl><dt><a name="screen-cursor_up"><strong>cursor_up</strong></a>(self, count<font color="#909090">=1</font>)</dt></dl>
+
+<dl><dt><a name="screen-cursor_up_reverse"><strong>cursor_up_reverse</strong></a>(self)</dt></dl>
+
+<dl><dt><a name="screen-dump"><strong>dump</strong></a>(self)</dt><dd><tt>This&nbsp;returns&nbsp;a&nbsp;copy&nbsp;of&nbsp;the&nbsp;<a href="#screen">screen</a>&nbsp;as&nbsp;a&nbsp;string.<br>
+This&nbsp;is&nbsp;similar&nbsp;to&nbsp;__str__&nbsp;except&nbsp;that&nbsp;lines<br>
+are&nbsp;not&nbsp;terminated&nbsp;with&nbsp;line&nbsp;feeds.</tt></dd></dl>
+
+<dl><dt><a name="screen-erase_down"><strong>erase_down</strong></a>(self)</dt><dd><tt>Erases&nbsp;the&nbsp;<a href="#screen">screen</a>&nbsp;from&nbsp;the&nbsp;current&nbsp;line&nbsp;down&nbsp;to<br>
+the&nbsp;bottom&nbsp;of&nbsp;the&nbsp;<a href="#screen">screen</a>.</tt></dd></dl>
+
+<dl><dt><a name="screen-erase_end_of_line"><strong>erase_end_of_line</strong></a>(self)</dt><dd><tt>Erases&nbsp;from&nbsp;the&nbsp;current&nbsp;cursor&nbsp;position&nbsp;to<br>
+the&nbsp;end&nbsp;of&nbsp;the&nbsp;current&nbsp;line.</tt></dd></dl>
+
+<dl><dt><a name="screen-erase_line"><strong>erase_line</strong></a>(self)</dt><dd><tt>Erases&nbsp;the&nbsp;entire&nbsp;current&nbsp;line.</tt></dd></dl>
+
+<dl><dt><a name="screen-erase_screen"><strong>erase_screen</strong></a>(self)</dt><dd><tt>Erases&nbsp;the&nbsp;<a href="#screen">screen</a>&nbsp;with&nbsp;the&nbsp;background&nbsp;color.</tt></dd></dl>
+
+<dl><dt><a name="screen-erase_start_of_line"><strong>erase_start_of_line</strong></a>(self)</dt><dd><tt>Erases&nbsp;from&nbsp;the&nbsp;current&nbsp;cursor&nbsp;position&nbsp;to<br>
+the&nbsp;start&nbsp;of&nbsp;the&nbsp;current&nbsp;line.</tt></dd></dl>
+
+<dl><dt><a name="screen-erase_up"><strong>erase_up</strong></a>(self)</dt><dd><tt>Erases&nbsp;the&nbsp;<a href="#screen">screen</a>&nbsp;from&nbsp;the&nbsp;current&nbsp;line&nbsp;up&nbsp;to<br>
+the&nbsp;top&nbsp;of&nbsp;the&nbsp;<a href="#screen">screen</a>.</tt></dd></dl>
+
+<dl><dt><a name="screen-fill"><strong>fill</strong></a>(self, ch<font color="#909090">=' '</font>)</dt></dl>
+
+<dl><dt><a name="screen-fill_region"><strong>fill_region</strong></a>(self, rs, cs, re, ce, ch<font color="#909090">=' '</font>)</dt></dl>
+
+<dl><dt><a name="screen-get"><strong>get</strong></a>(self)</dt></dl>
+
+<dl><dt><a name="screen-get_abs"><strong>get_abs</strong></a>(self, r, c)</dt></dl>
+
+<dl><dt><a name="screen-get_region"><strong>get_region</strong></a>(self, rs, cs, re, ce)</dt><dd><tt>This&nbsp;returns&nbsp;a&nbsp;list&nbsp;of&nbsp;lines&nbsp;representing&nbsp;the&nbsp;region.</tt></dd></dl>
+
+<dl><dt><a name="screen-insert"><strong>insert</strong></a>(self, ch)</dt></dl>
+
+<dl><dt><a name="screen-insert_abs"><strong>insert_abs</strong></a>(self, r, c, ch)</dt><dd><tt>This&nbsp;inserts&nbsp;a&nbsp;character&nbsp;at&nbsp;(r,c).&nbsp;Everything&nbsp;under<br>
+and&nbsp;to&nbsp;the&nbsp;right&nbsp;is&nbsp;shifted&nbsp;right&nbsp;one&nbsp;character.<br>
+The&nbsp;last&nbsp;character&nbsp;of&nbsp;the&nbsp;line&nbsp;is&nbsp;lost.</tt></dd></dl>
+
+<dl><dt><a name="screen-lf"><strong>lf</strong></a>(self)</dt><dd><tt>This&nbsp;moves&nbsp;the&nbsp;cursor&nbsp;down&nbsp;with&nbsp;scrolling.</tt></dd></dl>
+
+<dl><dt><a name="screen-newline"><strong>newline</strong></a>(self)</dt><dd><tt>This&nbsp;is&nbsp;an&nbsp;alias&nbsp;for&nbsp;<a href="#screen-crlf">crlf</a>().</tt></dd></dl>
+
+<dl><dt><a name="screen-put"><strong>put</strong></a>(self, ch)</dt><dd><tt>This&nbsp;puts&nbsp;a&nbsp;characters&nbsp;at&nbsp;the&nbsp;current&nbsp;cursor&nbsp;position.</tt></dd></dl>
+
+<dl><dt><a name="screen-put_abs"><strong>put_abs</strong></a>(self, r, c, ch)</dt><dd><tt>Screen&nbsp;array&nbsp;starts&nbsp;at&nbsp;1&nbsp;index.</tt></dd></dl>
+
+<dl><dt><a name="screen-scroll_constrain"><strong>scroll_constrain</strong></a>(self)</dt><dd><tt>This&nbsp;keeps&nbsp;the&nbsp;scroll&nbsp;region&nbsp;within&nbsp;the&nbsp;<a href="#screen">screen</a>&nbsp;region.</tt></dd></dl>
+
+<dl><dt><a name="screen-scroll_down"><strong>scroll_down</strong></a>(self)</dt><dd><tt>Scroll&nbsp;display&nbsp;down&nbsp;one&nbsp;line.</tt></dd></dl>
+
+<dl><dt><a name="screen-scroll_screen"><strong>scroll_screen</strong></a>(self)</dt><dd><tt>Enable&nbsp;scrolling&nbsp;for&nbsp;entire&nbsp;display.</tt></dd></dl>
+
+<dl><dt><a name="screen-scroll_screen_rows"><strong>scroll_screen_rows</strong></a>(self, rs, re)</dt><dd><tt>Enable&nbsp;scrolling&nbsp;from&nbsp;row&nbsp;{start}&nbsp;to&nbsp;row&nbsp;{end}.</tt></dd></dl>
+
+<dl><dt><a name="screen-scroll_up"><strong>scroll_up</strong></a>(self)</dt><dd><tt>Scroll&nbsp;display&nbsp;up&nbsp;one&nbsp;line.</tt></dd></dl>
+
+<dl><dt><a name="screen-set_tab"><strong>set_tab</strong></a>(self)</dt><dd><tt>Sets&nbsp;a&nbsp;tab&nbsp;at&nbsp;the&nbsp;current&nbsp;position.</tt></dd></dl>
+
+</td></tr></table></td></tr></table><p>
+<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
+<tr bgcolor="#eeaa77">
+<td colspan=3 valign=bottom>&nbsp;<br>
+<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
+    
+<tr><td bgcolor="#eeaa77"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
+<td width="100%"><dl><dt><a name="-constrain"><strong>constrain</strong></a>(n, min, max)</dt><dd><tt>This&nbsp;returns&nbsp;n&nbsp;constrained&nbsp;to&nbsp;the&nbsp;min&nbsp;and&nbsp;max&nbsp;bounds.</tt></dd></dl>
+</td></tr></table><p>
+<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
+<tr bgcolor="#55aa55">
+<td colspan=3 valign=bottom>&nbsp;<br>
+<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
+    
+<tr><td bgcolor="#55aa55"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
+<td width="100%"><strong>BEL</strong> = 7<br>
+<strong>BS</strong> = 8<br>
+<strong>CAN</strong> = 24<br>
+<strong>CR</strong> = 13<br>
+<strong>DEL</strong> = 127<br>
+<strong>ENQ</strong> = 5<br>
+<strong>ESC</strong> = 27<br>
+<strong>FF</strong> = 12<br>
+<strong>HT</strong> = 9<br>
+<strong>LF</strong> = 10<br>
+<strong>NUL</strong> = 0<br>
+<strong>SI</strong> = 15<br>
+<strong>SO</strong> = 14<br>
+<strong>SPACE</strong> = ' '<br>
+<strong>SUB</strong> = 26<br>
+<strong>VT</strong> = 11<br>
+<strong>XOFF</strong> = 19<br>
+<strong>XON</strong> = 17</td></tr></table>
+</body></html>

Added: packages/pexpect/branches/upstream/current/examples/README
URL: http://svn.debian.org/wsvn/python-modules/packages/pexpect/branches/upstream/current/examples/README?rev=929&op=file
==============================================================================
--- packages/pexpect/branches/upstream/current/examples/README (added)
+++ packages/pexpect/branches/upstream/current/examples/README Mon Jun 19 10:53:24 2006
@@ -1,0 +1,61 @@
+This directory contains scripts that give examples of using Pexpect.
+
+script.py
+    This implements a command similar to the classic BSD "script" command.
+    This will start a subshell and log all input and output to a file.
+    This demonstrates the interact() method of Pexpect.
+
+fix_cvs_files.py
+    This is for cleaning up binary files improperly added to CVS.
+    This script scans the given path to find binary files;
+    checks with CVS to see if the sticky options are set to -kb;
+    finally if sticky options are not -kb then uses 'cvs admin' to
+    set the -kb option. 
+
+ftp.py
+    This demonstrates an FTP "bookmark".
+    This connects to an ftp site; does a few ftp stuff; and then gives the user
+    interactive control over the session. In this case the "bookmark" is to a
+    directory on the OpenBSD ftp server. It puts you in the i386 packages
+    directory. You can easily modify this for other sites.
+    This demonstrates the interact() method of Pexpect.
+
+monitor.py
+    This runs a sequence of commands on a remote host using SSH.
+    It runs a simple system checks such as uptime and free to monitor
+    the state of the remote host.
+
+passmass.py
+    This will login to each given server and change the password of the
+    given user. This demonstrates scripting logins and 
+
+python.py
+    This starts the python interpreter and prints the greeting message backwards.
+    It then gives the user iteractive control of Python. It's pretty useless!
+
+rippy.py
+    This is a wizard for mencoder. It greatly simplifies the process of
+    ripping a DVD to Divx (mpeg4) format. It can transcode from any
+    video file to another. It has options for resampling the audio stream;
+    removing interlace artifacts, fitting to a target file size, etc.
+    There are lots of options, but the process is simple and easy to use.
+
+sshls.py
+    This lists a directory on a remote machine.
+
+ssh_tunnel.py
+    This starts an SSH tunnel to a remote machine. It monitors the connection
+    and restarts the tunnel if it goes down.
+
+uptime.py
+    This will run the uptime command and parse the output into variables.
+    This demonstrates using a single regular expression to match the output
+    of a command and capturing different variable in match groups.
+    The regular expression takes into account a wide variety of different
+    formats for uptime output.
+
+df.py
+    This collects filesystem capacity info using the 'df' command.
+    Tuples of filesystem name and percentage are stored in a list.
+    A simple report is printed. Filesystems over 95% capacity are highlighted.
+

Added: packages/pexpect/branches/upstream/current/examples/bd_client.py
URL: http://svn.debian.org/wsvn/python-modules/packages/pexpect/branches/upstream/current/examples/bd_client.py?rev=929&op=file
==============================================================================
--- packages/pexpect/branches/upstream/current/examples/bd_client.py (added)
+++ packages/pexpect/branches/upstream/current/examples/bd_client.py Mon Jun 19 10:53:24 2006
@@ -1,0 +1,31 @@
+#!/usr/bin/env python
+import socket
+import sys, time, select
+
+def recv_wrapper(s):
+    r,w,e = select.select([s.fileno()],[],[], 2)
+    if not r:
+        return ''
+    cols = int(s.recv(4))
+    rows = int(s.recv(4))
+    packet_size = cols * rows 
+    return s.recv(packet_size)
+
+HOST = '' #'localhost'    # The remote host
+PORT = 1664 # The same port as used by the server
+s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+s.connect((HOST, PORT))
+time.sleep(1)
+#s.setblocking(0)
+s.send('COMMAND' + '\x01' + sys.argv[1])
+print recv_wrapper(s)
+s.close()
+sys.exit()
+#while True:
+#    data = recv_wrapper(s)
+#    if data == '':
+#        break
+#    sys.stdout.write (data)
+#    sys.stdout.flush()
+#s.close()
+

Propchange: packages/pexpect/branches/upstream/current/examples/bd_client.py
------------------------------------------------------------------------------
    svn:executable = *

Added: packages/pexpect/branches/upstream/current/examples/bd_client_web.py
URL: http://svn.debian.org/wsvn/python-modules/packages/pexpect/branches/upstream/current/examples/bd_client_web.py?rev=929&op=file
==============================================================================
--- packages/pexpect/branches/upstream/current/examples/bd_client_web.py (added)
+++ packages/pexpect/branches/upstream/current/examples/bd_client_web.py Mon Jun 19 10:53:24 2006
@@ -1,0 +1,148 @@
+#!/usr/bin/env python
+# #sys.path.insert (0,"/var/www/cgi-bin")
+
+import sys
+import os
+import commands
+import cgi
+import traceback
+import string
+import re
+import socket
+
+ROOTPATH="/tmp"
+CGISH_HTML="""<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<title>Untitled Document</title>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<style type=text/css>
+body 
+{
+	font-family: "Courier New", Courier, mono; 
+	font-size: 10pt; 
+	color: #00cc00;
+	background-color: #002000; 
+}
+.headline {font-size: 18pt}
+a {color: #99ff99; text-decoration: none}
+a:hover {color: #00FF00}
+hr {color: #00ff00}
+.cursor {color:#002000;background-color:#00cc00}
+form {
+	font-family: "Courier New", Courier, mono;
+	color: #00CC00;
+	background-color: #003300;
+}
+input {
+	font-family: "Courier New", Courier, mono;
+	color: #00CC00;
+	background-color: #003300;
+	padding: 3px;
+	border: 0;
+}
+textarea {
+	font-family: "Courier New", Courier, mono;
+	color: #00CC00;
+	background-color: #003300;
+}
+</style>
+<script language="JavaScript">
+function firstFocus()
+{if (document.forms.length > 0)
+{var TForm = document.forms[0];
+for (i=0;i<TForm.length;i++){
+if ((TForm.elements[i].type=="text")||
+(TForm.elements[i].type=="textarea")||
+(TForm.elements[i].type.toString().charAt(0)=="s"))
+{document.forms[0].elements[i].focus();break;}}}}
+</script>
+</head>
+
+<body onLoad="firstFocus()">
+<pre>%(SHELL_OUTPUT)s</pre>
+<form action="http://www.chocho.org/cgi-bin/bd_client_web.py" method="POST">
+<input name="command" type="text" size="80"><br>
+<hr noshade="1">
+<input name="submit" type="submit" value="Enter">
+<input name="ctrl_c" type="submit" value="CTRL-C">
+<input name="ctrl_d" type="submit" value="CTRL-D">
+<input name="ctrl_z" type="submit" value="CTRL-Z">
+<input name="esc" type="submit" value="ESC">
+<input name="refresh" type="submit" value="REFRESH">
+
+</form>
+
+</body>
+</html>
+"""
+def page (result = ''):
+	"""Return the main form"""
+	return CGISH_HTML % {'SHELL_OUTPUT':result}
+
+def bd_client (command, host='localhost', port = 1666):
+	HOST = 'localhost'    # The remote host
+	PORT = 1666              # The same port as used by the server
+	s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+	s.connect((HOST, PORT))
+	s.send(command)
+        data = s.recv (1920)
+	s.close()
+	return data
+
+	#fout = file ('/tmp/log2','w')
+	#fout.write (command)
+	#fout.write ('\n')
+#	s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+#	s.connect((host, port))
+#	s.send(command)
+#	data = s.recv(1024)
+	#fout.write (data)
+	#fout.write ('\n')
+#	s.close()
+	#fout.close()
+#	return data
+
+#def link (matchobject):
+#	"""Used in re.sub calls to replace a matched object with an HTML link."""
+#	path = matchobject.group(0)
+#	l = "<a href=\"http://63.199.26.227/cgi-bin/ls.py?root=%s&path=%s\">%s</a>" % \
+#		(ROOTPATH+"/"+path, ROOTPATH+"/"+path, path)
+#	return l
+
+def escape_shell_meta_chars(s):
+         """Escape shell meta characters. This is done for security."""
+         s = string.replace(s, "\\", "\\\\")
+         s = string.replace(s, "`", "\\`")
+         s = string.replace(s, " ", "\\ ",)
+         s = string.replace(s, "&", "\\&",)
+         s = string.replace(s, ";", "\\;",)
+         s = string.replace(s, "\"", "\\\"",)
+         s = string.replace(s, "\'", "\\'",)
+         s = string.replace(s, "|", "\\|",)
+         s = string.replace(s, "*", "\\*",)
+         s = string.replace(s, "<", "\\<",)
+         s = string.replace(s, ">", "\\>",)
+         return s
+
+sys.path.insert (0,"/usr/local/apache/cgi-bin")
+sys.stderr = sys.stdout
+
+print "Content-type: text/html"
+print
+
+try:
+	form = cgi.FieldStorage()
+	if form.has_key("command"):
+		command = form["command"].value
+		result = bd_client (command)
+		print page(result)
+	else:
+		print page()
+
+except:
+	print "\n\n<pre>"
+	traceback.print_exc()
+	print "</pre>"
+
+

Propchange: packages/pexpect/branches/upstream/current/examples/bd_client_web.py
------------------------------------------------------------------------------
    svn:executable = *

Added: packages/pexpect/branches/upstream/current/examples/bd_serv.py
URL: http://svn.debian.org/wsvn/python-modules/packages/pexpect/branches/upstream/current/examples/bd_serv.py?rev=929&op=file
==============================================================================
--- packages/pexpect/branches/upstream/current/examples/bd_serv.py (added)
+++ packages/pexpect/branches/upstream/current/examples/bd_serv.py Mon Jun 19 10:53:24 2006
@@ -1,0 +1,247 @@
+#!/usr/bin/env python
+"""Back door shell server
+
+This exposes a shell terminal emulator on a socket.
+
+    --hostname : sets the remote host name to open an ssh connection to.
+    --username : sets the user name to login with
+    --password : (optional) sets the password to login with
+    --port     : set the local port for the server to listen on
+"""
+# Having the password on the command line is not a good idea, but
+# then this entire project is probably not the most security concious thing
+# I've ever built. This should be considered an experimental tool.
+import pxssh, pexpect, ANSI
+import socket
+import time, sys, os, getopt, getpass
+import threading
+
+def exit_with_usage(exit_code=1):
+    print globals()['__doc__']
+    os._exit(exit_code)
+
+class roller (threading.Thread):
+    """This runs a function in a loop in a thread."""
+    def __init__(self, interval, function, args=[], kwargs={}):
+        """The interval parameter defines time between each call to the function.
+        """
+        threading.Thread.__init__(self)
+        self.interval = interval
+        self.function = function
+        self.args = args
+        self.kwargs = kwargs
+        self.finished = threading.Event()
+    def cancel(self):
+        """Stop the roller."""
+        self.finished.set()
+    def run(self):
+        while not self.finished.isSet():
+            # self.finished.wait(self.interval)
+            self.function(*self.args, **self.kwargs)
+
+def daemonize (stdin='/dev/null', stdout='/dev/null', stderr='/dev/null'):
+    '''This forks the current process into a daemon.
+    Almost none of this is necessary (or advisable) if your daemon 
+    is being started by inetd. In that case, stdin, stdout and stderr are 
+    all set up for you to refer to the network connection, and the fork()s 
+    and session manipulation should not be done (to avoid confusing inetd). 
+    Only the chdir() and umask() steps remain as useful. 
+
+    References:
+        UNIX Programming FAQ
+        1.7 How do I get my program to act like a daemon?
+        http://www.erlenstar.demon.co.uk/unix/faq_2.html#SEC16
+
+        Advanced Programming in the Unix Environment
+        W. Richard Stevens, 1992, Addison-Wesley, ISBN 0-201-56317-7.
+
+    The stdin, stdout, and stderr arguments are file names that
+    will be opened and be used to replace the standard file descriptors
+    in sys.stdin, sys.stdout, and sys.stderr.
+    These arguments are optional and default to /dev/null.
+    Note that stderr is opened unbuffered, so
+    if it shares a file with stdout then interleaved output
+    may not appear in the order that you expect.
+    '''
+
+    # Do first fork.
+    try: 
+        pid = os.fork() 
+        if pid > 0:
+            sys.exit(0)   # Exit first parent.
+    except OSError, e: 
+        sys.stderr.write ("fork #1 failed: (%d) %s\n" % (e.errno, e.strerror) )
+        sys.exit(1)
+
+    # Decouple from parent environment.
+    os.chdir("/") 
+    os.umask(0) 
+    os.setsid() 
+
+    # Do second fork.
+    try: 
+        pid = os.fork() 
+        if pid > 0:
+            sys.exit(0)   # Exit second parent.
+    except OSError, e: 
+        sys.stderr.write ("fork #2 failed: (%d) %s\n" % (e.errno, e.strerror) )
+        sys.exit(1)
+
+    # Now I am a daemon!
+    
+    # Redirect standard file descriptors.
+    si = open(stdin, 'r')
+    so = open(stdout, 'a+')
+    se = open(stderr, 'a+', 0)
+    os.dup2(si.fileno(), sys.stdin.fileno())
+    os.dup2(so.fileno(), sys.stdout.fileno())
+    os.dup2(se.fileno(), sys.stderr.fileno())
+
+    # I now return as the daemon
+    return 0
+
+def add_cursor_blink (response, row, col):
+    i = (row-1) * 80 + col
+    return response[:i]+'<img src="http://www.noah.org/cursor.gif">'+response[i:]
+
+def endless_poll (child, prompt, screen, refresh_timeout=1):
+    """This keeps the screen updated with the output of the child.
+        This runs in a separate thread.
+    """
+    child.logfile = screen
+    while True:
+        child.prompt (timeout=refresh_timeout)
+        #i = child.expect ([prompt, pexpect.TIMEOUT], timeout=refresh_timeout)
+
+def main ():
+    try:
+        optlist, args = getopt.getopt(sys.argv[1:], 'h?d', ['help','h','?', 'hostname', 'username', 'password', 'port'])
+    except Exception, e:
+        print str(e)
+        exit_with_usage()
+
+    command_line_options = dict(optlist)
+    options = dict(optlist)
+    # There are a million ways to cry for help. These are but a few of them.
+    if [elem for elem in command_line_options if elem in ['-h','--h','-?','--?','--help']]:
+        exit_with_usage(0)
+  
+    hostname = "127.0.0.1"
+    port = 1664
+    username = os.getenv('USER')
+    password = ""
+
+    if '-d' in options:
+        daemon_mode = True
+    else:
+        daemon_mode = False
+
+    if '--hostname' in options:
+        hostname = options['--hostname']
+    if '--port' in options:
+        port = int(options['--port'])
+    if '--username' in options:
+        username = options['--username']
+    print "Login for %s@%s:%s" % (username, hostname, port)
+    if '--password' in options:
+        password = options['--password']
+    else:
+        password = getpass.getpass('password: ')
+   
+    #if daemon_mode: 
+    #    print "daemonizing server"
+    #    daemonize ()
+    #daemonize('/dev/null','/tmp/daemon.log','/tmp/daemon.log')
+    
+    sys.stdout.write ('server started with pid %d\n' % os.getpid() )
+
+    virtual_screen = ANSI.ANSI (24,80) 
+    child = pxssh.pxssh()
+    child.login (hostname, username, password)
+    print 'created shell. command line prompt is', child.PROMPT
+    #child.sendline ('stty -echo')
+    virtual_screen.write (child.before)
+    virtual_screen.write (child.after)
+
+    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+    localhost = '127.0.0.1'
+    s.bind((localhost, port))
+    print 'Listen'
+    s.listen(1)
+    print 'Accept'
+
+    r = roller (0.01, endless_poll, (child, child.PROMPT, virtual_screen))
+    r.start()
+    print "screen poll updater started in background thread"
+    sys.stdout.flush()
+
+    try:
+        while True:
+            conn, addr = s.accept()
+            print 'Connected by', addr
+            data = conn.recv(1024)
+            request = data.split(' ', 1)
+            if len(request) < 2:
+                conn.send(error_response('request did not have enough arguments.'))
+                conn.close()
+                continue   
+            cmd = request[0].strip()
+            arg = request[1].strip()
+
+            if cmd == 'command' or cmd == 'pretty':
+                child.sendline (arg)
+                child.prompt(timeout=1)
+            elif cmd == 'refresh':
+                pass
+                shell_window = pretty_box(virtual_screen.rows,virtual_screen.cols,str(virtual_screen))
+            elif cmd == 'skip':
+            # Wait until the TIMEOUT then throw away all data from the child.
+            # Use to catch up the screen with the shell if state gets out of sync.
+                child.expect (pexpect.TIMEOUT)
+                sh_response = child.before.replace ('\r', '')
+                virtual_screen.write (sh_response)
+            if cmd == 'command':
+                shell_window = virtual_screen.dump()
+            elif cmd == 'pretty':
+                shell_window = pretty_box(virtual_screen.rows,virtual_screen.cols,str(virtual_screen))
+            response = []
+            response.append ('%03d' % virtual_screen.rows)
+            response.append ('%03d' % virtual_screen.cols)
+            response.append (shell_window)
+            #response = add_cursor_blink (response, row, col)
+            sent = conn.send('\n'.join(response))
+            if sent < len (response):
+                print "Sent is too short. Some data was cut off."
+            conn.close()
+            if arg == 'exit':
+                s.close()
+                break
+    finally:
+        print "cleaning up socket"
+        s.close()
+
+def pretty_box (rows, cols, s):
+    """This puts an ASCII text box around the given string, s.
+    """
+    top_bot = '+' + '-'*cols + '+\n'
+    return top_bot + '\n'.join(['|'+line+'|' for line in s.split('\n')]) + '\n' + top_bot
+    
+def error_response (msg):
+    response = []
+    response.append ('000')
+    response.append ('000')
+    response.append ("""{REQUEST} {ARGUMENT}
+{REQUEST} may be one of the following:
+    command : Run the ARGUMENT as a shell command. Returns raw screen array.
+    pretty  : Like 'command', but formats the screen array for printing.
+    skip    : Use to catch up the screen with the shell if state gets out of sync.
+Example:
+    pretty ls -l
+""")
+    response.append (msg)
+    return '\n'.join(response)
+     
+if __name__ == "__main__":
+#    daemonize('/dev/null','/tmp/daemon.log','/tmp/daemon.log')
+    main()
+

Propchange: packages/pexpect/branches/upstream/current/examples/bd_serv.py
------------------------------------------------------------------------------
    svn:executable = *

Added: packages/pexpect/branches/upstream/current/examples/chess.py
URL: http://svn.debian.org/wsvn/python-modules/packages/pexpect/branches/upstream/current/examples/chess.py?rev=929&op=file
==============================================================================
--- packages/pexpect/branches/upstream/current/examples/chess.py (added)
+++ packages/pexpect/branches/upstream/current/examples/chess.py Mon Jun 19 10:53:24 2006
@@ -1,0 +1,129 @@
+#!/usr/bin/env python
+'''This demonstrates controlling a screen oriented application (curses).
+It starts two instances of gnuchess and then pits them against each other.
+'''
+import pexpect
+import string
+import ANSI
+
+REGEX_MOVE = '(?:[a-z]|\x1b\[C)(?:[0-9]|\x1b\[C)(?:[a-z]|\x1b\[C)(?:[0-9]|\x1b\[C)'
+REGEX_MOVE_PART = '(?:[0-9]|\x1b\[C)(?:[a-z]|\x1b\[C)(?:[0-9]|\x1b\[C)'
+
+class Chess:
+
+	def __init__(self, engine = "/usr/local/bin/gnuchess -a -h 1"):
+		self.child = pexpect.spawn (engine)
+                self.term = ANSI.ANSI ()
+             
+		self.child.expect ('Chess')
+		if self.child.after != 'Chess':
+			raise IOError, 'incompatible chess program'
+                self.term.process_list (self.before)
+                self.term.process_list (self.after)
+		self.last_computer_move = ''
+        def read_until_cursor (self, r,c)
+            while 1:
+                self.child.read(1, 60)
+                self.term.process (c)
+                if self.term.cur_r == r and self.term.cur_c == c:
+                    return 1
+
+	def do_first_move (self, move):
+		self.child.expect ('Your move is')
+		self.child.sendline (move)
+                self.term.process_list (self.before)
+                self.term.process_list (self.after)
+		return move
+
+	def do_move (self, move):
+                read_until_cursor (19,60)
+		#self.child.expect ('\[19;60H')
+		self.child.sendline (move)
+		print 'do_move' move
+		return move
+
+	def get_first_computer_move (self):
+		self.child.expect ('My move is')
+		self.child.expect (REGEX_MOVE)
+#		print '', self.child.after
+		return self.child.after
+	
+	def get_computer_move (self):
+		print 'Here'
+		i = self.child.expect (['\[17;59H', '\[17;58H'])
+		print i
+		if i == 0:
+			self.child.expect (REGEX_MOVE)
+			if len(self.child.after) < 4:
+				self.child.after = self.child.after + self.last_computer_move[3]
+		if i == 1:
+			self.child.expect (REGEX_MOVE_PART)
+			self.child.after = self.last_computer_move[0] + self.child.after
+		print '', self.child.after
+		self.last_computer_move = self.child.after
+		return self.child.after
+
+	def switch (self):
+		self.child.sendline ('switch')
+
+	def set_depth (self, depth):
+		self.child.sendline ('depth')
+		self.child.expect ('depth=')
+		self.child.sendline ('%d' % depth)
+
+	def quit(self):
+		self.child.sendline ('quit')
+import sys, os
+print 'Starting...'
+white = Chess()
+white.child.echo = 1
+white.child.expect ('Your move is')
+white.set_depth(2)
+white.switch()
+
+move_white = white.get_first_computer_move()
+print 'first move white:', move_white
+
+white.do_move ('e7e5')
+move_white = white.get_computer_move()
+print 'move white:', move_white
+white.do_move ('f8c5')
+move_white = white.get_computer_move()
+print 'move white:', move_white
+white.do_move ('b8a6')
+move_white = white.get_computer_move()
+print 'move white:', move_white
+
+sys.exit(1)
+
+
+
+black = Chess()
+white = Chess()
+white.child.expect ('Your move is')
+white.switch()
+
+move_white = white.get_first_computer_move()
+print 'first move white:', move_white
+
+black.do_first_move (move_white)
+move_black = black.get_first_computer_move()
+print 'first move black:', move_black
+
+white.do_move (move_black)
+
+done = 0
+while not done:
+    move_white = white.get_computer_move()
+    print 'move white:', move_white
+
+    black.do_move (move_white)
+    move_black = black.get_computer_move()
+    print 'move black:', move_black
+   
+    white.do_move (move_black)
+    print 'tail of loop'
+
+g.quit()
+
+

Propchange: packages/pexpect/branches/upstream/current/examples/chess.py
------------------------------------------------------------------------------
    svn:executable = *

Added: packages/pexpect/branches/upstream/current/examples/chess2.py
URL: http://svn.debian.org/wsvn/python-modules/packages/pexpect/branches/upstream/current/examples/chess2.py?rev=929&op=file
==============================================================================
--- packages/pexpect/branches/upstream/current/examples/chess2.py (added)
+++ packages/pexpect/branches/upstream/current/examples/chess2.py Mon Jun 19 10:53:24 2006
@@ -1,0 +1,129 @@
+#!/usr/bin/env python
+'''This demonstrates controlling a screen oriented application (curses).
+It starts two instances of gnuchess and then pits them against each other.
+'''
+import pexpect
+import string
+import ANSI
+import sys, os, time
+
+class Chess:
+
+        def __init__(self, engine = "/usr/local/bin/gnuchess -a -h 1"):
+                self.child = pexpect.spawn (engine)
+                self.term = ANSI.ANSI ()
+             
+                #self.child.expect ('Chess')
+                #if self.child.after != 'Chess':
+                #        raise IOError, 'incompatible chess program'
+                #self.term.process_list (self.child.before)
+                #self.term.process_list (self.child.after)
+
+                self.last_computer_move = ''
+
+        def read_until_cursor (self, r,c, e=0):
+            '''Eventually something like this should move into the screen class or
+            a subclass. Maybe a combination of pexpect and screen...
+            '''
+            fout = open ('log','a')
+            while self.term.cur_r != r or self.term.cur_c != c:
+                try:
+                    k = self.child.read(1, 10)
+                except Exception, e:
+                    print 'EXCEPTION, (r,c):(%d,%d)\n' %(self.term.cur_r, self.term.cur_c)
+                    sys.stdout.flush()
+                self.term.process (k)
+                fout.write ('(r,c):(%d,%d)\n' %(self.term.cur_r, self.term.cur_c))
+                fout.flush()
+                if e:
+                    sys.stdout.write (k)
+                    sys.stdout.flush()
+                if self.term.cur_r == r and self.term.cur_c == c:
+                    fout.close()
+                    return 1
+            print 'DIDNT EVEN HIT.'
+            fout.close()
+            return 1
+
+        def expect_region (self):
+            '''This is another method that would be moved into the
+            screen class.
+            '''
+            pass
+        def do_scan (self):
+            fout = open ('log','a')
+            while 1:
+                c = self.child.read(1,10)
+                self.term.process (c)
+                fout.write ('(r,c):(%d,%d)\n' %(self.term.cur_r, self.term.cur_c))
+                fout.flush()
+                sys.stdout.write (c)
+                sys.stdout.flush()
+
+        def do_move (self, move, e = 0):
+                time.sleep(1)
+                self.read_until_cursor (19,60, e)
+                self.child.sendline (move)
+
+        def wait (self, color):
+            while 1:
+                r = self.term.get_region (14,50,14,60)[0]
+                r = r.strip()
+                if r == color:
+                    return
+                time.sleep (1)
+
+        def parse_computer_move (self, s):
+                i = s.find ('is: ')
+                cm = s[i+3:i+9]        
+                return cm
+        def get_computer_move (self, e = 0):
+                time.sleep(1)
+                self.read_until_cursor (19,60, e)
+                time.sleep(1)
+                r = self.term.get_region (17,50,17,62)[0]
+                cm = self.parse_computer_move (r)
+                return cm
+
+        def switch (self):
+                print 'switching'
+                self.child.sendline ('switch')
+
+        def set_depth (self, depth):
+                self.child.sendline ('depth')
+                self.child.expect ('depth=')
+                self.child.sendline ('%d' % depth)
+
+        def quit(self):
+                self.child.sendline ('quit')
+
+def LOG (s):
+    print s
+    sys.stdout.flush ()
+    fout = open ('moves.log', 'a')
+    fout.write (s + '\n')
+    fout.close()
+
+print 'Starting...'
+
+black = Chess()
+white = Chess()
+white.read_until_cursor (19,60,1)
+white.switch()
+
+done = 0
+while not done:
+    white.wait ('Black')
+    move_white = white.get_computer_move(1)
+    LOG ( 'move white:'+ move_white )
+
+    black.do_move (move_white)
+    black.wait ('White')
+    move_black = black.get_computer_move()
+    LOG ( 'move black:'+ move_black )
+   
+    white.do_move (move_black, 1)
+
+g.quit()
+
+

Propchange: packages/pexpect/branches/upstream/current/examples/chess2.py
------------------------------------------------------------------------------
    svn:executable = *

Added: packages/pexpect/branches/upstream/current/examples/chess3.py
URL: http://svn.debian.org/wsvn/python-modules/packages/pexpect/branches/upstream/current/examples/chess3.py?rev=929&op=file
==============================================================================
--- packages/pexpect/branches/upstream/current/examples/chess3.py (added)
+++ packages/pexpect/branches/upstream/current/examples/chess3.py Mon Jun 19 10:53:24 2006
@@ -1,0 +1,136 @@
+#!/usr/bin/env python
+'''This demonstrates controlling a screen oriented application (curses).
+It starts two instances of gnuchess and then pits them against each other.
+'''
+import pexpect
+import string
+import ANSI
+
+REGEX_MOVE = '(?:[a-z]|\x1b\[C)(?:[0-9]|\x1b\[C)(?:[a-z]|\x1b\[C)(?:[0-9]|\x1b\[C)'
+REGEX_MOVE_PART = '(?:[0-9]|\x1b\[C)(?:[a-z]|\x1b\[C)(?:[0-9]|\x1b\[C)'
+
+class Chess:
+
+	def __init__(self, engine = "/usr/local/bin/gnuchess -a -h 1"):
+		self.child = pexpect.spawn (engine)
+                self.term = ANSI.ANSI ()
+             
+#		self.child.expect ('Chess')
+	#	if self.child.after != 'Chess':
+	#		raise IOError, 'incompatible chess program'
+        #        self.term.process_list (self.before)
+        #        self.term.process_list (self.after)
+		self.last_computer_move = ''
+        def read_until_cursor (self, r,c):
+            fout = open ('log','a')
+            while 1:
+                k = self.child.read(1, 10)
+                self.term.process (k)
+                fout.write ('(r,c):(%d,%d)\n' %(self.term.cur_r, self.term.cur_c))
+                fout.flush()
+                if self.term.cur_r == r and self.term.cur_c == c:
+                    fout.close()
+                    return 1
+                sys.stdout.write (k)
+                sys.stdout.flush()
+
+	def do_scan (self):
+            fout = open ('log','a')
+            while 1:
+                c = self.child.read(1,10)
+                self.term.process (c)
+                fout.write ('(r,c):(%d,%d)\n' %(self.term.cur_r, self.term.cur_c))
+                fout.flush()
+                sys.stdout.write (c)
+                sys.stdout.flush()
+
+	def do_move (self, move):
+                self.read_until_cursor (19,60)
+		self.child.sendline (move)
+		return move
+	
+	def get_computer_move (self):
+		print 'Here'
+		i = self.child.expect (['\[17;59H', '\[17;58H'])
+		print i
+		if i == 0:
+			self.child.expect (REGEX_MOVE)
+			if len(self.child.after) < 4:
+				self.child.after = self.child.after + self.last_computer_move[3]
+		if i == 1:
+			self.child.expect (REGEX_MOVE_PART)
+			self.child.after = self.last_computer_move[0] + self.child.after
+		print '', self.child.after
+		self.last_computer_move = self.child.after
+		return self.child.after
+
+	def switch (self):
+		self.child.sendline ('switch')
+
+	def set_depth (self, depth):
+		self.child.sendline ('depth')
+		self.child.expect ('depth=')
+		self.child.sendline ('%d' % depth)
+
+	def quit(self):
+		self.child.sendline ('quit')
+import sys, os
+print 'Starting...'
+white = Chess()
+white.do_move('b2b4')
+white.read_until_cursor (19,60)
+c1 = white.term.get_abs(17,58)
+c2 = white.term.get_abs(17,59)
+c3 = white.term.get_abs(17,60)
+c4 = white.term.get_abs(17,61)
+fout = open ('log','a')
+fout.write ('Computer:%s%s%s%s\n' %(c1,c2,c3,c4))
+fout.close()
+white.do_move('c2c4')
+white.read_until_cursor (19,60)
+c1 = white.term.get_abs(17,58)
+c2 = white.term.get_abs(17,59)
+c3 = white.term.get_abs(17,60)
+c4 = white.term.get_abs(17,61)
+fout = open ('log','a')
+fout.write ('Computer:%s%s%s%s\n' %(c1,c2,c3,c4))
+fout.close()
+white.do_scan ()
+
+#white.do_move ('b8a6')
+#move_white = white.get_computer_move()
+#print 'move white:', move_white
+
+sys.exit(1)
+
+
+
+black = Chess()
+white = Chess()
+white.child.expect ('Your move is')
+white.switch()
+
+move_white = white.get_first_computer_move()
+print 'first move white:', move_white
+
+black.do_first_move (move_white)
+move_black = black.get_first_computer_move()
+print 'first move black:', move_black
+
+white.do_move (move_black)
+
+done = 0
+while not done:
+    move_white = white.get_computer_move()
+    print 'move white:', move_white
+
+    black.do_move (move_white)
+    move_black = black.get_computer_move()
+    print 'move black:', move_black
+   
+    white.do_move (move_black)
+    print 'tail of loop'
+
+g.quit()
+
+

Propchange: packages/pexpect/branches/upstream/current/examples/chess3.py
------------------------------------------------------------------------------
    svn:executable = *

Added: packages/pexpect/branches/upstream/current/examples/df.py
URL: http://svn.debian.org/wsvn/python-modules/packages/pexpect/branches/upstream/current/examples/df.py?rev=929&op=file
==============================================================================
--- packages/pexpect/branches/upstream/current/examples/df.py (added)
+++ packages/pexpect/branches/upstream/current/examples/df.py Mon Jun 19 10:53:24 2006
@@ -1,0 +1,33 @@
+#!/usr/bin/env python
+"""This collects filesystem capacity info using the 'df' command.
+Tuples of filesystem name and percentage are stored in a list.
+A simple report is printed. Filesystems over 95% capacity are highlighted.
+Note that this does not parse filesystem names after the first space, so
+names with spaces in them will be truncated. This will produce ambiguous
+results for automount filesystems on Apple OSX.
+"""
+import pexpect
+
+child = pexpect.spawn ('df')
+
+# parse 'df' output into a list.
+pattern = "\n(\S+).*?([0-9]+)%"
+filesystem_list = []
+for dummy in range (0, 1000):
+    i = child.expect ([pattern, pexpect.EOF])
+    if i == 0:
+        filesystem_list.append (child.match.groups())
+    else:
+        break
+
+# Print report
+print
+for m in filesystem_list:
+    s = "Filesystem %s is at %s%%" % (m[0], m[1])
+    # highlight filesystems over 95% capacity
+    if int(m[1]) > 95:
+        s = '! ' + s
+    else:
+        s = '  ' + s
+    print s
+

Propchange: packages/pexpect/branches/upstream/current/examples/df.py
------------------------------------------------------------------------------
    svn:executable = *

Added: packages/pexpect/branches/upstream/current/examples/fix_cvs_files.py
URL: http://svn.debian.org/wsvn/python-modules/packages/pexpect/branches/upstream/current/examples/fix_cvs_files.py?rev=929&op=file
==============================================================================
--- packages/pexpect/branches/upstream/current/examples/fix_cvs_files.py (added)
+++ packages/pexpect/branches/upstream/current/examples/fix_cvs_files.py Mon Jun 19 10:53:24 2006
@@ -1,0 +1,91 @@
+#!/usr/bin/env python
+"""This is for cleaning up binary files improperly added to CVS.
+This script scans the given path to find binary files; 
+checks with CVS to see if the sticky options are set to -kb;
+finally if sticky options are not -kb then uses 'cvs admin' to
+set the -kb option.
+
+This script ignores CVS directories, symbolic links,
+and files not known under CVS control (cvs status is 'Unknown').
+
+Run this on a CHECKED OUT module sandbox, not on the repository itself.
+After if fixes the sticky options on any files you should manually do
+a 'cvs commit' to accept the changes. Then be sure to have all users do
+a 'cvs up -A' to update the Sticky Option status.
+
+Noah Spurrier
+20030426
+"""
+import os, sys, time
+import pexpect
+
+VERBOSE = 1
+
+def is_binary (filename):
+	"""Assume that any file with a character where 
+	the 8th bit is set is binary.
+	"""
+	fin = open(filename, 'rb')
+	wholething = fin.read()
+	fin.close()
+	for c in wholething:
+		if ord(c) & 0x80:
+			return 1
+	return 0
+
+def is_kb_sticky (filename):
+	"""This checks if 'cvs status' reports '-kb' for Sticky options.
+	    If the Sticky Option status is '-ks' then this returns 1.
+	    If the status is 'Unknown' then it returns 1.
+            Otherwise 0 is returned.
+	"""
+	try:
+		s = pexpect.spawn ('cvs status %s' % filename)
+		i = s.expect (['Sticky Options:\s*(.*)\r\n',  'Status: Unknown'])
+		if i==1 and VERBOSE:
+			print 'File not part of CVS repository:', filename
+			return 1 # Pretend it's OK.
+		if s.match.group(1) == '-kb':
+			return 1
+		s = None
+	except:
+		print 'Something went wrong trying to run external cvs command.'
+		print '    cvs status %s' % filename
+		print 'The cvs command returned:'
+		print s.before
+	return 0
+
+def cvs_admin_kb (filename):
+	"""This uses 'cvs admin' to set the '-kb' sticky option.
+	"""
+	s = pexpect.run ('cvs admin -kb %s' % filename)
+	# There is a timing issue. If I run 'cvs admin' too quickly
+	# cvs sometimes has trouble obtaining the directory lock.
+	time.sleep(1)
+	
+def walk_and_clean_cvs_binaries (arg, dirname, names):
+	"""This contains the logic for processing files.
+	This is the os.path.walk callback.
+	This skips dirnames that end in CVS.
+	"""
+	if len(dirname)>3 and dirname[-3:]=='CVS':
+		return
+	for n in names:
+		fullpath = os.path.join (dirname, n)
+		if os.path.isdir(fullpath) or os.path.islink(fullpath):
+			continue
+		if is_binary(fullpath):
+			if not is_kb_sticky (fullpath):
+				if VERBOSE: print fullpath
+				cvs_admin_kb (fullpath)
+
+def main ():
+	if len(sys.argv) == 1:
+		root = '.'
+	else:
+		root = sys.argv[1]
+	os.path.walk (root, walk_and_clean_cvs_binaries, None)
+
+if __name__ == '__main__':
+	main ()
+

Propchange: packages/pexpect/branches/upstream/current/examples/fix_cvs_files.py
------------------------------------------------------------------------------
    svn:executable = *

Added: packages/pexpect/branches/upstream/current/examples/ftp.py
URL: http://svn.debian.org/wsvn/python-modules/packages/pexpect/branches/upstream/current/examples/ftp.py?rev=929&op=file
==============================================================================
--- packages/pexpect/branches/upstream/current/examples/ftp.py (added)
+++ packages/pexpect/branches/upstream/current/examples/ftp.py Mon Jun 19 10:53:24 2006
@@ -1,0 +1,48 @@
+#!/usr/bin/env python
+"""This demonstrates an FTP "bookmark".
+This connects to an ftp site; does a few ftp stuff; and then gives the user
+interactive control over the session. In this case the "bookmark" is to a
+directory on the OpenBSD ftp server. It puts you in the i386 packages
+directory. You can easily modify this for other sites.
+"""
+import pexpect
+import sys
+
+child = pexpect.spawn('ftp ftp.openbsd.org')
+child.expect('(?i)name .*: ')
+child.sendline('anonymous')
+child.expect('(?i)password')
+child.sendline('pexpect at sourceforge.net')
+child.expect('ftp> ')
+child.sendline('cd /pub/OpenBSD/3.7/packages/i386')
+child.expect('ftp> ')
+child.sendline('bin')
+child.expect('ftp> ')
+child.sendline('prompt')
+child.expect('ftp> ')
+child.sendline('pwd')
+child.expect('ftp> ')
+print("Escape character is '^]'.\n")
+sys.stdout.write (child.after)
+sys.stdout.flush()
+child.interact() # Escape character defaults to ^]
+# At this point this script blocks until the user presses the escape character
+# or until the child exits. The human user and the child should be talking
+# to each other now.
+
+# At this point the script is running again.
+print 'Left interactve mode.'
+
+#
+# The rest is not strictly necessary. This just demonstrates a few functions.
+# This makes sure the child is dead; although it would be killed when Python exits.
+if child.isalive():
+    child.sendline('bye') # Try to ask ftp child to exit.
+    child.close()
+# Print the final state of the child. Normally isalive() should be FALSE.
+if child.isalive():
+    print 'Child did not exit gracefully.'
+else:
+    print 'Child exited gracefully.'
+
+

Propchange: packages/pexpect/branches/upstream/current/examples/ftp.py
------------------------------------------------------------------------------
    svn:executable = *

Added: packages/pexpect/branches/upstream/current/examples/monitor.py
URL: http://svn.debian.org/wsvn/python-modules/packages/pexpect/branches/upstream/current/examples/monitor.py?rev=929&op=file
==============================================================================
--- packages/pexpect/branches/upstream/current/examples/monitor.py (added)
+++ packages/pexpect/branches/upstream/current/examples/monitor.py Mon Jun 19 10:53:24 2006
@@ -1,0 +1,204 @@
+#!/usr/bin/env python
+""" monitor.py
+    This runs a sequence of commands on a remote host using SSH.
+    It runs a simple system checks such as uptime and free to monitor
+    the state of the remote host.
+
+./monitor.py [-s server_hostname] [-u username] [-p password]
+    -s : hostname of the remote server to login to.
+    -u : username to user for login.
+    -p : Password to user for login.
+
+Example:
+    This will print information about the given host:
+        ./monitor.py -s www.example.com -u mylogin -p mypassword
+
+It works like this:
+    Login via SSH (This is the hardest part).
+    Run and parse 'uptime'.
+    Run 'iostat'.
+    Run 'vmstat'.
+    Run 'netstat'
+    Run 'free'.
+    Exit the remote host.
+"""
+import os, sys, time, re, getopt, getpass
+import traceback
+import pexpect
+
+#
+# Some constants.
+#
+COMMAND_PROMPT = '[#$] ' ### This is way too simple for industrial use -- we will change is ASAP.
+TERMINAL_PROMPT = '(?i)terminal type\?'
+TERMINAL_TYPE = 'vt100'
+# This is the prompt we get if SSH does not have the remote host's public key stored in the cache.
+SSH_NEWKEY = '(?i)are you sure you want to continue connecting'
+
+def exit_with_usage():
+    print globals()['__doc__']
+    os._exit(1)
+
+def main():
+    global COMMAND_PROMPT, TERMINAL_PROMPT, TERMINAL_TYPE, SSH_NEWKEY
+    ######################################################################
+    ## Parse the options, arguments, get ready, etc.
+    ######################################################################
+    try:
+        optlist, args = getopt.getopt(sys.argv[1:], 'h?s:u:p:', ['help','h','?'])
+    except Exception, e:
+        print str(e)
+        exit_with_usage()
+    options = dict(optlist)
+    if len(args) > 1:
+        exit_with_usage()
+
+    if [elem for elem in options if elem in ['-h','--h','-?','--?','--help']]:
+        print "Help:"
+        exit_with_usage()
+
+    if '-s' in options:
+        host = options['-s']
+    else:
+        host = raw_input('hostname: ')
+    if '-u' in options:
+        user = options['-u']
+    else:
+        user = raw_input('username: ')
+    if '-p' in options:
+        password = options['-p']
+    else:
+        password = getpass.getpass('password: ')
+
+    #
+    # Login via SSH
+    #
+    child = pexpect.spawn('ssh -l %s %s'%(user, host))
+    i = child.expect([pexpect.TIMEOUT, SSH_NEWKEY, COMMAND_PROMPT, '(?i)password'])
+    if i == 0: # Timeout
+        print 'ERROR! could not login with SSH. Here is what SSH said:'
+        print child.before, child.after
+        print str(child)
+        sys.exit (1)
+    if i == 1: # In this case SSH does not have the public key cached.
+        child.sendline ('yes')
+        child.expect ('(?i)password')
+    if i == 2:
+        # This may happen if a public key was setup to automatically login.
+        # But beware, the COMMAND_PROMPT at this point is very trivial and
+        # could be fooled by some output in the MOTD or login message.
+        pass
+    if i == 3:
+        child.sendline(password)
+        # Now we are either at the command prompt or
+        # the login process is asking for our terminal type.
+        i = child.expect ([COMMAND_PROMPT, TERMINAL_PROMPT])
+        if i == 1:
+            child.sendline (TERMINAL_TYPE)
+            child.expect (COMMAND_PROMPT)
+    #
+    # Set command prompt to something more unique.
+    #
+    COMMAND_PROMPT = "\[PEXPECT\]\$ "
+    child.sendline ("PS1='[PEXPECT]\$ '") # In case of sh-style
+    i = child.expect ([pexpect.TIMEOUT, COMMAND_PROMPT], timeout=10)
+    if i == 0:
+        print "# Couldn't set sh-style prompt -- trying csh-style."
+        child.sendline ("set prompt='[PEXPECT]\$ '")
+        i = child.expect ([pexpect.TIMEOUT, COMMAND_PROMPT], timeout=10)
+        if i == 0:
+            print "Failed to set command prompt using sh or csh style."
+            print "Response was:"
+            print child.before
+            sys.exit (1)
+
+    # Now we should be at the command prompt and ready to run some commands.
+    print '---------------------------------------'
+    print 'Report of commands run on remote host.'
+    print '---------------------------------------'
+
+    # Run uname.
+    child.sendline ('uname -a')
+    child.expect (COMMAND_PROMPT)
+    print child.before
+    if 'linux' in child.before.lower():
+        LINUX_MODE = 1
+    else:
+        LINUX_MODE = 0
+
+    # Run and parse 'uptime'.
+    child.sendline ('uptime')
+    child.expect('up\s+(.*?),\s+([0-9]+) users?,\s+load averages?: ([0-9]+\.[0-9][0-9]),?\s+([0-9]+\.[0-9][0-9]),?\s+([0-9]+\.[0-9][0-9])')
+    duration, users, av1, av5, av15 = child.match.groups()
+    days = '0'
+    hours = '0'
+    mins = '0'
+    if 'day' in duration:
+        child.match = re.search('([0-9]+)\s+day',duration)
+        days = str(int(child.match.group(1)))
+    if ':' in duration:
+        child.match = re.search('([0-9]+):([0-9]+)',duration)
+        hours = str(int(child.match.group(1)))
+        mins = str(int(child.match.group(2)))
+    if 'min' in duration:
+        child.match = re.search('([0-9]+)\s+min',duration)
+        mins = str(int(child.match.group(1)))
+    print
+    print 'Uptime: %s days, %s users, %s (1 min), %s (5 min), %s (15 min)' % (
+        duration, users, av1, av5, av15)
+    child.expect (COMMAND_PROMPT)
+
+    # Run iostat.
+    child.sendline ('iostat')
+    child.expect (COMMAND_PROMPT)
+    print child.before
+
+    # Run vmstat.
+    child.sendline ('vmstat')
+    child.expect (COMMAND_PROMPT)
+    print child.before
+
+    # Run free.
+    if LINUX_MODE:
+        child.sendline ('free') # Linux systems only.
+        child.expect (COMMAND_PROMPT)
+        print child.before
+
+    # Run df.
+    child.sendline ('df')
+    child.expect (COMMAND_PROMPT)
+    print child.before
+    
+    # Run lsof.
+    child.sendline ('lsof')
+    child.expect (COMMAND_PROMPT)
+    print child.before
+
+#    # Run netstat
+#    child.sendline ('netstat')
+#    child.expect (COMMAND_PROMPT)
+#    print child.before
+
+#    # Run MySQL show status.
+#    child.sendline ('mysql -p -e "SHOW STATUS;"')
+#    child.expect (PASSWORD_PROMPT_MYSQL)
+#    child.sendline (password_mysql)
+#    child.expect (COMMAND_PROMPT)
+#    print
+#    print child.before
+
+    # Now exit the remote host.
+    child.sendline ('exit')
+    index = child.expect([pexpect.EOF, "(?i)there are stopped jobs"])
+    if index==1:
+        child.sendline("exit")
+        child.expect(EOF)
+
+if __name__ == "__main__":
+    try:
+        main()
+    except Exception, e:
+        print str(e)
+        traceback.print_exc()
+        os._exit(1)
+

Propchange: packages/pexpect/branches/upstream/current/examples/monitor.py
------------------------------------------------------------------------------
    svn:executable = *

Added: packages/pexpect/branches/upstream/current/examples/passmass.py
URL: http://svn.debian.org/wsvn/python-modules/packages/pexpect/branches/upstream/current/examples/passmass.py?rev=929&op=file
==============================================================================
--- packages/pexpect/branches/upstream/current/examples/passmass.py (added)
+++ packages/pexpect/branches/upstream/current/examples/passmass.py Mon Jun 19 10:53:24 2006
@@ -1,0 +1,87 @@
+#!/usr/bin/env python
+'''Change passwords on the named machines.
+    passmass host1 host2 host3 . . .
+Note that login shell prompt on remote machine must end in # or $.
+'''
+
+import pexpect
+import sys, getpass
+
+USAGE = '''passmass host1 host2 host3 . . .'''
+COMMAND_PROMPT = '[$#] '
+TERMINAL_PROMPT = r'Terminal type\?'
+TERMINAL_TYPE = 'vt100'
+SSH_NEWKEY = r'Are you sure you want to continue connecting \(yes/no\)\?'
+def login(host, user, password):
+    child = pexpect.spawn('ssh -l %s %s'%(user, host))
+    fout = file ("LOG.TXT","wb")
+    child.setlog (fout)
+
+    i = child.expect([pexpect.TIMEOUT, SSH_NEWKEY, '[Pp]assword: '])
+    if i == 0: # Timeout
+        print 'ERROR!'
+        print 'SSH could not login. Here is what SSH said:'
+        print child.before, child.after
+        sys.exit (1)
+    if i == 1: # SSH does not have the public key. Just accept it.
+        child.sendline ('yes')
+        child.expect ('[Pp]assword: ')
+    child.sendline(password)
+    # Now we are either at the command prompt or
+    # the login process is asking for our terminal type.
+    i = child.expect (['Permission denied', TERMINAL_PROMPT, COMMAND_PROMPT])
+    if i == 0:
+        print 'Permission denied on host:', host
+        sys.exit (1)
+    if i == 1:
+        child.sendline (TERMINAL_TYPE)
+        child.expect (COMMAND_PROMPT)
+    return child
+
+# (current) UNIX password:
+def change_password(child, user, oldpassword, newpassword):
+    child.sendline('passwd') 
+    i = child.expect(['[Oo]ld [Pp]assword', '.current.*password', '[Nn]ew [Pp]assword'])
+    # Root does not require old password, so it gets to bypass the next step.
+    if i == 0 or i == 1:
+        child.sendline(oldpassword)
+        child.expect('[Nn]ew [Pp]assword')
+    child.sendline(newpassword)
+    i = child.expect(['[Nn]ew [Pp]assword', '[Rr]etype', '[Rr]e-enter'])
+    if i == 0:
+        print 'Host did not like new password. Here is what it said...'
+        print child.before
+	child.send (chr(3)) # Ctrl-C
+        child.sendline('') # This should tell remote passwd command to quit.
+        return
+    child.sendline(newpassword)
+
+def main():
+    if len(sys.argv) <= 1:
+        print USAGE
+        return 1
+
+    user = raw_input('Username: ')
+    password = getpass.getpass('Current Password: ')
+    newpassword = getpass.getpass('New Password: ')
+    newpasswordconfirm = getpass.getpass('Confirm New Password: ')
+    if newpassword != newpasswordconfirm:
+        print 'New Passwords do not match.'
+        return 1
+
+    for host in sys.argv[1:]:
+        child = login(host, user, password)
+        if child == None:
+            print 'Could not login to host:', host
+            continue
+        print 'Changing password on host:', host
+        change_password(child, user, password, newpassword)
+        child.expect(COMMAND_PROMPT)
+        child.sendline('exit')
+
+if __name__ == '__main__':
+    try:
+        main()
+    except pexpect.ExceptionPexpect, e:
+        print str(e)
+

Propchange: packages/pexpect/branches/upstream/current/examples/passmass.py
------------------------------------------------------------------------------
    svn:executable = *

Added: packages/pexpect/branches/upstream/current/examples/python.py
URL: http://svn.debian.org/wsvn/python-modules/packages/pexpect/branches/upstream/current/examples/python.py?rev=929&op=file
==============================================================================
--- packages/pexpect/branches/upstream/current/examples/python.py (added)
+++ packages/pexpect/branches/upstream/current/examples/python.py Mon Jun 19 10:53:24 2006
@@ -1,0 +1,22 @@
+#!/usr/bin/env python
+'''This starts the python interpreter; captures the startup message; then gives the user interactive control over the session.
+Why?
+'''
+
+# Don't do this unless you like being John Malkovich
+# c = pexpect.spawn ('/usr/bin/env python ./python.py')
+
+import pexpect
+c = pexpect.spawn ('/usr/bin/env python')
+c.expect ('>>>')
+print 'And now for something completely different...'
+f = lambda s:s and f(s[1:])+s[0] # Makes a function to reverse a string.
+print f(c.before)
+print 'Yes, it\'s python, but it\'s backwards.'
+print
+print 'Escape character is \'^]\'.'
+print c.after,
+c.interact()
+c.kill(1)
+print 'is alive:', c.isalive()
+

Propchange: packages/pexpect/branches/upstream/current/examples/python.py
------------------------------------------------------------------------------
    svn:executable = *

Added: packages/pexpect/branches/upstream/current/examples/rippy.py
URL: http://svn.debian.org/wsvn/python-modules/packages/pexpect/branches/upstream/current/examples/rippy.py?rev=929&op=file
==============================================================================
--- packages/pexpect/branches/upstream/current/examples/rippy.py (added)
+++ packages/pexpect/branches/upstream/current/examples/rippy.py Mon Jun 19 10:53:24 2006
@@ -1,0 +1,599 @@
+#!/usr/bin/env python
+"""Rippy!
+
+This script helps to convert video from one format to another.
+It is useful for ripping DVDs to DivX videos.
+
+Run the script with no arguments to start with interactive prompts:
+    rippy.py
+Run the script with the filename of a options config to start automatic mode:
+    rippy.py rippy.conf
+
+After Rippy is finished it saves the current configuation in
+a file called 'rippy.conf' in the local directoy. This can be used to
+rerun process using the exact same settings by passing the filename
+of the conf file as an argument to Rippy. Rippy will read the options
+from the file instead of asking you for options interactively.
+So if you run rippy with 'dry_run=1' then you can run the process again
+later using the 'rippy.conf' file. Don't forget to edit 'rippy.conf'
+to set 'dry_run=0'!
+
+If you run rippy with dry_run and verbose true then the output generated
+is valid command line commands. You might need to tweak some values
+such as crop area or bit rate, but otherwise you could cut-and-paste
+the commands to a shell prompt.
+
+Note that mplayer has poor handling of mixing MP3 files to AVI format.
+I have had better luck with Metroshka (MKV) format containers.
+Currently only MKV format is supported. Hopefully I can fix AVI later.
+
+2005 Noah Spurrier
+"""
+import sys, os, re, math, stat, getopt, pickle, traceback, types
+from pexpect import *
+
+##############################################################################
+# This defines the prompts and defaults used for interactive mode.
+##############################################################################
+# Dictionaries are unordered, so I have this list that maintains the order of the keys.
+prompts_key_order = ('verbose_flag','dry_run_flag','video_source_filename','video_final_filename','video_transcoded_filename',
+'audio_raw_filename','audio_compressed_filename','video_length','video_scale','video_codec','video_encode_passes',
+'video_key_interval','video_bitrate','video_target_size','video_bitrate_fudge_factor','video_crop_area',
+'video_container_format','video_deinterlace_flag','video_gray_flag','audio_id','audio_sample_rate','audio_bitrate',
+'audio_lowpass_filter','delete_tmp_files_flag')
+
+# key : ( default value, prompt, help string, level of difficulty )
+prompts = {
+'video_source_filename':("dvd://1", 'Video source filename?', """This is the filename of the video that you want to convert from.
+It can be any file that mencoder supports.
+You can also choose a DVD device using the dvd://1 syntax.
+Title 1 is usually the main title on a DVD.""",0),
+'video_transcoded_filename':("~video.avi", 'Video transcoded filename?', """This is the temporary file where the video will be stored in the new format.
+This is before the audio track is mixed into the final video container.""",2),
+'video_final_filename':("video_final", "Video final filename?", """This is the name of the final video.""",0),
+'audio_raw_filename':("audiodump.wav", "Audio raw filename?", """This is the audio raw PCM filename. This is prior to compression.
+Note that mplayer automatically names this audiodump.wav, so
+normally you should not change this.""",2),
+'audio_compressed_filename':("audiodump.mp3","Audio compressed filename?", """This is the name of the compressed audio that will be mixed
+into the final video. Normally you don't need to change this.""",2),
+'video_length':("calc","Video length in seconds?","""This sets the length of the video in seconds. Set to 'calc' to calculate the length from the
+raw audio stream. That's a hack because mplayer cannot get the length of
+the video from the source video file. Normally you don't need to change this.""",1),
+'video_scale':("none","Video scale?","""This scales the video to the given output size. The default is to do no scaling.
+You may type in a resolution such as 320x240 or you may use presets.
+    qntsc: 352x240 (NTSC quarter screen)
+    qpal:  352x288 (PAL quarter screen)
+    ntsc:  720x480 (standard NTSC)
+    pal:   720x576 (standard PAL)
+    sntsc: 640x480 (square pixel NTSC)
+    spal:  768x576 (square pixel PAL)""",1),
+'video_codec':("mpeg4","Video codec?","""This is the video compression to use. This is passed directly to mencoded, so
+any format that it recognizes will work. For DivX use 'mpeg4'.
+Some common codecs include:
+mjpeg, h263, h263p, h264, mpeg4, msmpeg4, wmv1, wmv2, mpeg1video, mpeg2video, huffyuv, ffv1.
+See mencoder manual for details.""",1),
+'video_encode_passes':("2","Encode passes?","""This sets how many passes to use to encode the video. You can choose 1 or 2.
+Using two pases takes twice as long as one pass, but produces a better
+quality video. I found that the effect is not that noticable.""",1),
+'video_key_interval':("12","Video key-frame interval?","""This sets how often a key-frame is inserted into the stream.
+Normally you don't need to change this.""",2),
+'verbose_flag':("Y","Verbose output?","""This sets verbose output. If true then all commands and arguments are printed
+before they are run. This is useful to see exactly how commands are run.""",1),
+'dry_run_flag':("N","Dry run?","""This sets 'dry run' mode. If true then commands are not run. This is useful
+if you want to see what would happen by running the script.""",1),
+'video_bitrate':("calc","Video bitrate?","""This sets the video bitrate. This over-rides video_target_size.
+Set to 'calc' to automatically estimate the bitrate based on the
+video final target size.""",1),
+'video_target_size':("700","Video final target size in MB?","""This sets the target video size that you want to end up with.
+This is over-ridden by video_bitrate. In other words, if you specify
+video_bitrate then video_target_size is ignored.
+Due to the unpredictable nature of compression the final video size may not
+exactly match. The following are common CDR sizes:
+    180MB CDR (21 minutes) holds 193536000 bytes
+    550MB CDR (63 minutes) holds 580608000 bytes
+    650MB CDR (74 minutes) holds 681984000 bytes
+    700MB CDR (80 minutes) holds 737280000 bytes""",0),
+'video_bitrate_fudge_factor':("1.2","Bitrate fudge factor?","""Mencoder overestimates the bitrate.
+Again, bitrate calculations are unpredictable. I found that a factor of 1.2
+produces video files that are just under the target size. If you specify
+video_bitrate then the fudge factor is ignored.""",2),
+'video_crop_area':("detect","Crop area?","""This sets the crop area to remove black bars from the top and sides of the video.
+This helps save space. Set to 'detect' to automatically detect the crop area.
+Set to 'none' to not crop the video. Normally you don't need to change this.""",1),
+'video_container_format':('mkv',"Final video format (avi or mkv)?","""This sets the final video container format. Metroshka is 'mkv' format.
+Currently 'avi' format doesn't work due to a bug in mencoder.""",1),
+'video_deinterlace_flag':("N","Is the video interlaced?","""This sets the deinterlace flag. If set then mencoder will be instructed
+to filter out interlace artifacts.""",0),
+'video_gray_flag':("N","Is the video black and white (gray)?","""This improves output for black and white video.""",0),
+'audio_id':("128","Audio ID stream?","""This selects the audio stream to extract from the source video.
+If your source is a VOB file (DVD) then stream IDs start at 128.
+Normally, 128 is the main audio track for a DVD.
+Tracks with higher numbers may be other language dubs or audio commentary.""",0),
+'audio_sample_rate':("32","Audio sample rate (kHz) 48, 44.1, 32, 24, 12","""This sets the rate at which the compressed audio will be resampled.
+DVD audio is 48 kHz whereas music CDs use 44.1 kHz. The higher the sample rate
+the more space the audio track will take. That will leave less space for video.
+32 kHz is a good trade-off if you are trying to fit a video onto a CD.""",1),
+'audio_bitrate':("96","Audio bitrate (kbit/s) 192, 128, 96?","""This sets the bitrate for MP3 audio compression.
+The higher the bitrate the more space the audio track will take.
+That will leave less space for video. Most people find music to be acceptable
+at 128 kBitS. 96 kBitS is a good trade-off if you are trying to fit a video onto a CD.""",1),
+'audio_lowpass_filter':("16","Audio lowpass filter (kHz)?","""This sets the low-pass filter for the audio.
+Normally this should be half of the audio sample rate.
+This improves audio compression and quality.
+Normally you don't need to change this.""",1),
+'delete_tmp_files_flag':("Y","Delete temporary files when finished?","""If Y then video_transcoded_filename, audio_raw_filename, audio_compressed_filename,
+and 'divx2pass.log' will be deleted at the end.""",1)
+}
+
+##############################################################################
+# This is the main convert control function
+##############################################################################
+def convert (options):
+    """This is the heart of it all -- this performs an end-to-end conversion of
+    a video from one format to another. It requires a dictionary of options.
+    The conversion process will also add some keys to the dictionary
+    such as length of the video and crop area. The dictionary is returned.
+    """
+    print "# Extract audio to %s" % (options['audio_raw_filename'])
+    apply_smart (extract_audio, options)
+
+    if options['video_length']=='calc':
+        options['video_length'] = apply_smart (get_length, options)
+        print "# Length of raw audio file : %d seconds (%0.2f minutes)" % (options['video_length'], float(options['video_length'])/60.0)
+
+    print "# Compress raw audio"
+    apply_smart (compress_audio, options)
+
+    if options['video_bitrate']=='calc':
+        options['video_bitrate'] = options['video_bitrate_fudge_factor'] * apply_smart (calc_video_bitrate, options) 
+    print "# video bitrate : " + str(options['video_bitrate'])
+
+    if options['video_crop_area']=='detect':
+        options['video_crop_area'] = apply_smart (crop_detect, options)
+    print "# crop area : " + str(options['video_crop_area'])
+
+    print "# Transcode video"
+    apply_smart (compress_video, options)
+
+    print "# Mix video and audio together to final video container"
+    apply_smart (mux, options)
+
+    print "# Delete temporary files"
+    if options['delete_tmp_files_flag']:
+        apply_smart (delete_tmp_files, options)
+
+    o = ["# options used to create video\n"]
+    for k,v in options.iteritems():
+        o.append (" %30s : %s\n" % (k, v))
+    print '# '.join(o)
+    fout = open("rippy.conf","wb").write(''.join(o))
+    
+    return options
+
+##############################################################################
+
+def exit_with_usage(exit_code=1):
+    print globals()['__doc__']
+    os._exit(exit_code)
+
+def check_missing_requirements ():
+    """This list of missing requirements (mencoder, mplayer, lame, and mkvmerge).
+    Returns None if all requirements are in the execution path.
+    """
+    missing = []
+    if which("mencoder") is None:
+        missing.append("mencoder")
+    if which("mplayer") is None:
+        missing.append("mplayer")
+    if which("lame") is None:
+        missing.append("lame")
+    if which("mkvmerge") is None:
+        missing.append("mkvmerge")
+    if len(missing)==0:
+        return None
+    return missing
+
+def input_option (message, default_value="", help=None, level=0, max_level=0):
+    """This is a fancy raw_input function.
+    If the user enters '?' then the contents of help is printed.
+    
+    The 'level' and 'max_level' are used to adjust which advanced options
+    are printed. 'max_level' is the level of options that the user wants
+    to see. 'level' is the level of difficulty for this particular option.
+    If this level is <= the max_level the user wants then the
+    message is printed and user input is allowed; otherwise, the
+    default value is returned automatically without user input.
+    """
+    if default_value != '':
+        message = "%s [%s] " % (message, default_value)
+    if level > max_level:
+        return default_value
+    while 1:
+        user_input = raw_input (message)
+        if user_input=='?':
+            print help
+        elif user_input=='':
+            return default_value
+        else:
+            break
+    return user_input
+
+def progress_callback (d=None):
+    """This callback simply prints a dot to show activity.
+    This is used when running external commands with pexpect.run.
+    """
+    print ".",
+
+def apply_smart (func, args):
+    """This is similar to func(**args), but this won't complain about 
+    extra keys in 'args'. This ignores keys in 'args' that are 
+    not required by 'func'. This passes None to arguments that are
+    not defined in 'args'. That's fine for arguments with a default valeue, but
+    that's a bug for required arguments. I should probably raise a TypeError.
+    """
+    if hasattr(func,'im_func'): # Handle case when func is a class method.
+        func = func.im_func
+    argcount = func.func_code.co_argcount
+    required_args = dict([(k,args.get(k)) for k in func.func_code.co_varnames[:argcount]])
+    return func(**required_args)
+
+def count_unique (items):
+    """This takes a list and returns a sorted list of tuples with a count of each unique item in the list.
+    Example 1:
+        count_unique(['a','b','c','a','c','c','a','c','c'])
+    returns:
+        [(5,'c'), (3,'a'), (1,'b')]
+    Example 2 -- get the most frequent item in a list:
+        count_unique(['a','b','c','a','c','c','a','c','c'])[0][1]
+    returns:
+        'c'
+    """
+    stats = {}
+    for i in items:
+        if i in stats:
+            stats[i] = stats[i] + 1
+        else:
+            stats[i] = 1
+    stats = [(v, k) for k, v in stats.items()]
+    stats.sort()
+    stats.reverse()
+    return stats
+
+def get_aid_list (video_source_filename):
+    """This returns a list of audio ids in the source video file.
+    """
+    result = run ("mplayer %s -vo null -ao null -frames 0 -identify" % video_source_filename)
+    idl = re.findall("ID_AUDIO_ID=([0-9]*)", result)
+    idl.sort()
+    return idl
+    
+def extract_audio (video_source_filename, audio_id=128, verbose_flag=0, dry_run_flag=0):
+    """This extracts the given audio_id track as uncompressed PCM from the given source video.
+        Note that mplayer always saves this to audiodump.wav.
+        At this time there is no way to set the output audio name.
+    """
+    cmd = "mplayer %(video_source_filename)s -vo null -aid %(audio_id)s -ao pcm -noframedrop -vc dummy" % locals()
+    if verbose_flag: print cmd
+    if not dry_run_flag:
+        run(cmd, timeout=5, events={TIMEOUT:progress_callback})
+        print
+
+def get_length (audio_raw_filename):
+    """This attempts to get the length of the media file (length is time in seconds).
+    Not to be confused with size (in bytes) of the file data.
+    This is best used on a PCM AUDIO file because mplayer cannot get an accurate
+    time for many compressed video and audio formats -- notably MPEG4 and MP3.
+    Weird...
+    This returns -1 if it cannot get the length of the given file.
+    """
+    result = run ("mplayer %s -vo null -ao null -frames 0 -identify" % audio_raw_filename)
+    idl = re.findall("ID_LENGTH=([0-9]*)", result)
+    idl.sort()
+    if len(idl) != 1:
+        return -1
+    return int(idl[0])
+
+def calc_video_bitrate (video_target_size, audio_compressed_filename, video_length, extra_space=0, dry_run_flag=0):
+    """This gives an estimate of the video bitrate necessary to
+    fit the final target size.  This will take into account room to
+    fit the audio_compressed_filename and extra space if given.
+    video_target_size is in MB,
+    audio_compressed_filename is a string, 
+    video_length is in seconds,
+    extra_space is in bytes.
+    a 180MB CDR (21 minutes) holds 193536000 bytes.
+    a 550MB CDR (63 minutes) holds 580608000 bytes.
+    a 650MB CDR (74 minutes) holds 681984000 bytes.
+    a 700MB CDR (80 minutes) holds 737280000 bytes.
+    """
+    if dry_run_flag:
+        return -1
+    if extra_space is None: extra_space = 0
+    audio_size = os.stat(audio_compressed_filename)[stat.ST_SIZE]
+    video_target_size = video_target_size - audio_size - extra_space
+    return (int)(calc_video_kbitrate (video_target_size, video_length))
+
+def calc_video_kbitrate (target_size, length_secs):
+    """Given a target byte size free for video data, this returns the bitrate in kBit/S.
+    For mencoder vbitrate 1 kBit = 1000 Bits -- not 1024 bits.
+        target_size = bitrate * 1000 * length_secs / 8
+        target_size = bitrate * 125 * length_secs
+        bitrate     = target_size/(125*length_secs)
+    """
+    return int(target_size / (125.0 * length_secs))
+
+def crop_detect (video_source_filename, video_length, dry_run_flag=0):
+    """This attempts to figure out the best crop for the given video file.
+    Basically it runs crop detect for 5 seconds on three different places in the video.
+    It picks the crop area that was most often detected.
+    """
+    skip = int(video_length/9)
+    sample_length = 5
+    cmd1 = "mencoder %s -quiet -ss %d -endpos %d -o /dev/null -nosound -ovc lavc -vf cropdetect" % (video_source_filename,   skip, sample_length)
+    cmd2 = "mencoder %s -quiet -ss %d -endpos %d -o /dev/null -nosound -ovc lavc -vf cropdetect" % (video_source_filename, 2*skip, sample_length)
+    cmd3 = "mencoder %s -quiet -ss %d -endpos %d -o /dev/null -nosound -ovc lavc -vf cropdetect" % (video_source_filename, 3*skip, sample_length)
+    if dry_run_flag:
+        return "0:0:0:0"
+    result1 = run(cmd1)
+    result2 = run(cmd2)
+    result3 = run(cmd3)
+    idl = re.findall("-vf crop=([0-9]+:[0-9]+:[0-9]+:[0-9]+)", result1)
+    idl = idl + re.findall("-vf crop=([0-9]+:[0-9]+:[0-9]+:[0-9]+)", result2)
+    idl = idl + re.findall("-vf crop=([0-9]+:[0-9]+:[0-9]+:[0-9]+)", result3)
+    items_count = count_unique(idl)
+    return items_count[0][1]
+
+def compress_video (video_source_filename, video_transcoded_filename, video_bitrate=1000, video_codec='mpeg4', video_gray_flag=0, video_key_interval=0, video_crop_area=None, video_scale=None, video_encode_passes=2, video_deinterlace_flag=0, verbose_flag=0, dry_run_flag=0):
+    """This compresses the given source video filename to the transcoded filename.
+        This does a two-pass compression (I'm assuming mpeg4, I should probably make this smarter for other formats).
+    """
+    # build filter expression
+    filter = ''
+    if video_crop_area and video_crop_area.lower()!='none':
+        filter = filter + "crop=%s" % video_crop_area
+    if video_deinterlace_flag:
+        if filter != '':
+            filter = filter + ','
+        filter = filter + 'pp=md'
+    if video_scale and video_scale.lower()!='none':
+        if filter != '':
+            filter = filter + ','
+        filter = filter + "scale=%s" % video_scale
+    if filter != '':
+        filter = '-vf ' + filter
+
+    # build lavcopts expression
+    if video_encode_passes=='2':
+        lavcopts1 = '-lavcopts vcodec=%s:vbitrate=%d:mbd=2:vpass=1' % (video_codec,video_bitrate)
+        lavcopts2 = '-lavcopts vcodec=%s:vbitrate=%d:mbd=2:vpass=2' % (video_codec,video_bitrate)
+    else:
+        lavcopts1 = '-lavcopts vcodec=%s:vbitrate=%d:mbd=2:vpass=1' % (video_codec,video_bitrate)
+        lavcopts2 = ''
+    if video_key_interval:
+        lavcopts1 = lavcopts1 + ":keyint=%d" % int(video_key_interval)
+        lavcopts2 = lavcopts2 + ":keyint=%d" % int(video_key_interval)
+    if video_gray_flag:
+        lavcopts1 = lavcopts1 + ":gray"
+        lavcopts2 = lavcopts2 + ":gray"
+    
+    cmd = "mencoder %s -o %s -oac copy -ovc lavc -nosound %s %s" % (video_source_filename, video_transcoded_filename, lavcopts1, filter)
+    if verbose_flag: print cmd
+    if not dry_run_flag:
+        run(cmd, timeout=5, events={TIMEOUT:progress_callback})
+        print
+    # If not doing two passes then return early.
+    if video_encode_passes!='2':
+        return
+    cmd = "mencoder %s -o %s -oac copy -ovc lavc -nosound %s %s" % (video_source_filename, video_transcoded_filename, lavcopts2, filter)
+    if verbose_flag: print cmd
+    if not dry_run_flag:
+        run(cmd, timeout=5, events={TIMEOUT:progress_callback})
+        print
+
+def compress_audio (audio_raw_filename, audio_compressed_filename, audio_lowpass_filter=None, audio_sample_rate=None, audio_bitrate=None, verbose_flag=0, dry_run_flag=0):
+    """This compresses the raw audio file to the compressed audio filename.
+    """
+    cmd = "lame -h --athaa-sensitivity 1 --cwlimit 11"
+    if audio_lowpass_filter:
+        cmd = cmd + " --lowpass " + audio_lowpass_filter
+    if audio_bitrate:
+        cmd = cmd + " --abr " + audio_bitrate
+    if audio_sample_rate:
+        cmd = cmd + " --resample " + audio_sample_rate
+    cmd = cmd + " " + audio_raw_filename + " " + audio_compressed_filename
+    if verbose_flag: print cmd
+    if not dry_run_flag:
+        run(cmd, timeout=5, events={TIMEOUT:progress_callback})
+        print
+
+def mux (video_final_filename, video_transcoded_filename, audio_compressed_filename, video_container_format, verbose_flag=0, dry_run_flag=0):
+    if video_container_format.lower() == "mkv":
+        mux_mkv (video_final_filename, video_transcoded_filename, audio_compressed_filename, verbose_flag, dry_run_flag)
+    if video_container_format.lower() == "avi":
+        mux_avi (video_final_filename, video_transcoded_filename, audio_compressed_filename, verbose_flag, dry_run_flag)
+
+def mux_mkv (video_final_filename, video_transcoded_filename, audio_compressed_filename, verbose_flag=0, dry_run_flag=0):
+    cmd = "mkvmerge -o %s --noaudio %s %s" % (video_final_filename, video_transcoded_filename, audio_compressed_filename)
+    if verbose_flag: print cmd
+    if not dry_run_flag:
+        run(cmd, timeout=5, events={TIMEOUT:progress_callback})
+        print
+
+def mux_avi (video_final_filename, video_transcoded_filename, audio_compressed_filename, verbose_flag=0, dry_run_flag=0):
+    print "NOT IMPLEMENTED YET"
+    return
+    cmd = "mkvmerge -o %s --noaudio %s %s" % (video_final_filename, video_transcoded_filename, audio_compressed_filename)
+    if verbose_flag: print cmd
+    if not dry_run_flag:
+        run(cmd, timeout=5, events={TIMEOUT:progress_callback})
+        print
+
+def delete_tmp_files (video_transcoded_filename, audio_raw_filename, audio_compressed_filename, verbose_flag=0, dry_run_flag=0):
+    file_list = ' '.join(['divx2pass.log', video_transcoded_filename, audio_raw_filename, audio_compressed_filename])
+    cmd = "rm -f " + file_list
+    if verbose_flag: print cmd
+    if not dry_run_flag:
+        run(cmd, timeout=5, events={TIMEOUT:progress_callback})
+        print
+    
+##############################################################################
+# This is the interactive Q&A that is used if no conf file was given.
+##############################################################################
+def interactive_convert ():
+    global prompts, prompts_key_order
+
+    print globals()['__doc__']
+    print "============================================"
+    print "Enter '?' for any question to get extra help"
+    print "============================================"
+  
+    # Ask for the level of options the user wants. 
+    # A lot of code just to print a string!
+    level_sort = {0:'', 1:'', 2:''} 
+    for k in prompts:
+        level = prompts[k][3]
+        if level < 0 or level > 2:
+            continue
+        level_sort[level] += "    " + prompts[k][1] + "\n"
+    level_sort_string = "This the level for advanced options prompts. Set 0 for simple, 1 for advanced, or 2 for expert.\n"
+    level_sort_string += "[0] Basic options:\n" + str(level_sort[0]) + "\n"
+    level_sort_string += "[1] Advanced options:\n" + str(level_sort[1]) + "\n"
+    level_sort_string += "[2] Expert options:\n" + str(level_sort[2])
+    c = input_option("Prompt level (0, 1, or 2)?", "0", level_sort_string)
+    MAX_PROMPT_LEVEL = int(c)
+
+    options = {}
+    for k in prompts_key_order:
+        if k == 'audio_id':
+            aid_list = get_aid_list (options['video_source_filename'])
+            if len(aid_list) > 1:
+                print "This video has more than one audio stream. The following stream audio IDs were found:"
+                for aid in aid_list:
+                    print "    " + aid
+            else:
+                print "WARNING!"
+                print "Unable to get the list of audio streams from the video (is the DVD busy?)."
+                print "Setting default to 128."
+                aid_list=["128"]
+            options[k] = input_option (prompts[k][1], aid_list[0], prompts[k][2], prompts[k][3], MAX_PROMPT_LEVEL)
+        elif k == 'audio_lowpass_filter':
+            lowpass_default =  "%.1f" % (math.floor(float(options['audio_sample_rate']) / 2.0))
+            options[k] = input_option (prompts[k][1], lowpass_default, prompts[k][2], prompts[k][3], MAX_PROMPT_LEVEL)
+        else:
+            # Don't bother asking for video_target_size or video_bitrate_fudge_factor if bitrate was set
+            if (k=='video_target_size' or k=='video_bitrate_fudge_factor') and options['video_bitrate']!='calc':
+                continue
+            options[k] = input_option (prompts[k][1], prompts[k][0], prompts[k][2], prompts[k][3], MAX_PROMPT_LEVEL)
+
+    options['video_final_filename'] = options['video_final_filename'] + "." + options['video_container_format']
+
+    print "=========================================================================="
+    print "Ready to Rippy!"
+    print
+    print "The following options will be used:"
+    for k,v in options.iteritems():
+        print "%27s : %s" % (k, v)
+
+    print
+    c = input_option("Continue?", "Y")
+    c = c.strip().lower()
+    if c[0] != 'y':
+        print "Exiting..."
+        os._exit(1)
+    return options
+
+def clean_options (d):
+    """This validates and cleans up the options dictionary.
+    After reading options interactively or from a conf file
+    we need to make sure that the values are converted or make sense.
+    Values are normalized "No", "None", "none" all become "none".
+    "Calcluate", "c", "CALC" all become "calc".
+    Any key with "_flag" in it becomes a boolean True or False.
+    This is a rather annoying function, but then so it most cleanup work.
+    """
+    for k in d:
+        d[k] = d[k].strip()
+        if '_flag' in k:
+            if type(d[k]) is types.StringType:
+                if d[k].strip().lower()[0] in 'yt1': #Yes, True, 1
+                    d[k] = 1
+                else:
+                    d[k] = 0
+    d['video_bitrate'] = d['video_bitrate'].lower()
+    if d['video_bitrate'][0]=='c':
+        d['video_bitrate']='calc'
+    else:
+        d['video_bitrate'] = int(d['video_bitrate'])
+    try:
+        d['video_target_size'] = int(d['video_target_size'])
+    except:
+        d['video_target_size'] = 'none'
+    try:
+        d['video_bitrate_fudge_factor'] = float(d['video_bitrate_fudge_factor'])
+    except:
+        d['video_bitrate_fudge_factor'] = -1.0
+
+    assert (d['video_bitrate']=='calc' and d['video_target_size']!='none') or (d['video_bitrate']!='calc' and d['video_target_size']=='none')
+
+    d['video_scale'] = d['video_scale'].lower()
+    if d['video_scale'][0]=='n':
+        d['video_scale']='none'
+    else:
+        al = re.findall("([0-9]+).*?([0-9]+)", d['video_scale'])
+        d['video_scale']=al[0][0]+':'+al[0][1]
+    d['video_crop_area'] = d['video_crop_area'].lower()
+    if d['video_crop_area'][0]=='n':
+        d['video_crop_area']='none'
+    d['video_length'] = d['video_length'].lower()
+    if d['video_length'][0]=='c':
+        d['video_length']='calc'
+    return d
+
+def main ():
+    try:
+        optlist, args = getopt.getopt(sys.argv[1:], 'h?', ['help','h','?'])
+    except Exception, e:
+        print str(e)
+        exit_with_usage()
+    command_line_options = dict(optlist)
+    # There are a million ways to cry for help. These are but a few of them.
+    if [elem for elem in command_line_options if elem in ['-h','--h','-?','--?','--help']]:
+        exit_with_usage(0)
+
+    missing = check_missing_requirements()
+    if missing is not None:
+        print
+        print "=========================================================================="
+        print "ERROR!"
+        print "Some required external commands are missing."
+        print "please install the following packages:"
+        print str(missing)
+        print "=========================================================================="
+        print
+        c = input_option("Continue?", "Y")
+        c = c.strip().lower()
+        if c[0] != 'y':
+            print "Exiting..."
+            os._exit(1)
+
+    if len(args) > 0:
+        options = dict(re.findall('([^: \t\n]*)\s*:\s*(".*"|[^ \t\n]*)', file(args[0]).read()))
+        options = clean_options(options)
+        convert (options)
+    else:
+        options = interactive_convert ()
+        options = clean_options(options)
+        convert (options)
+    print "# Done!"
+    
+if __name__ == "__main__":
+    try:
+        main ()
+    except Exception, e:
+        print "=========================================================================="
+        print "ERROR -- Unexpected exception in script."
+        print str(e)
+        traceback.print_exc()
+        print "=========================================================================="
+        exit_with_usage(3)
+

Propchange: packages/pexpect/branches/upstream/current/examples/rippy.py
------------------------------------------------------------------------------
    svn:executable = *

Added: packages/pexpect/branches/upstream/current/examples/script.py
URL: http://svn.debian.org/wsvn/python-modules/packages/pexpect/branches/upstream/current/examples/script.py?rev=929&op=file
==============================================================================
--- packages/pexpect/branches/upstream/current/examples/script.py (added)
+++ packages/pexpect/branches/upstream/current/examples/script.py Mon Jun 19 10:53:24 2006
@@ -1,0 +1,93 @@
+#!/usr/bin/env python
+"""script.py
+This spawns a sub-shell (bash) and gives the user interactive control.
+The entire shell session is logged to a file called script.log.
+This behaves much like the classic BSD command "script".
+
+./script.py [-a] [-c command] {logfilename}
+    logfilename : This is the name of the log file. Default is script.log.
+    -a : Append to log file. Default is to overwrite log file.
+    -c : spawn command. Default is to spawn the sh shell.
+
+Example:
+    This will start a bash shell and append to the log named my_session.log
+        ./script.py -a -c bash my_session.log
+"""
+import os, sys, time, getopt
+import signal, fcntl, termios, struct
+import traceback
+import pexpect
+
+global_pexpect_instance = None # Used by signal handler
+
+def exit_with_usage():
+    print globals()['__doc__']
+    os._exit(1)
+
+def main():
+    ######################################################################
+    # Parse the options, arguments, get ready, etc.
+    ######################################################################
+    try:
+        optlist, args = getopt.getopt(sys.argv[1:], 'h?ac:', ['help','h','?'])
+    except Exception, e:
+        print str(e)
+        exit_with_usage()
+    options = dict(optlist)
+    if len(args) > 1:
+        exit_with_usage()
+        
+    if [elem for elem in options if elem in ['-h','--h','-?','--?','--help']]:
+        print "Help:"
+        exit_with_usage()
+
+    if len(args) == 1:
+        script_filename = args[0]
+    else:
+        script_filename = "script.log"
+    if '-a' in options:
+        fout = file (script_filename, "ab")
+    else:
+        fout = file (script_filename, "wb")
+    if '-c' in options:
+        command = options['-c']
+    else:
+        command = "sh"
+
+    # Begin log with date/time in the form CCCCyymm.hhmmss
+    fout.write ('# %4d%02d%02d.%02d%02d%02d \n' % time.localtime()[:-3])
+    
+    ######################################################################
+    # Start the interactive session
+    ######################################################################
+    p = pexpect.spawn(command)
+    p.logfile = fout
+    global global_pexpect_instance
+    global_pexpect_instance = p
+    signal.signal(signal.SIGWINCH, sigwinch_passthrough)
+
+    print "Script recording started. Type ^] (ASCII 29) to escape from the script shell."
+    p.interact(chr(29))
+    fout.close()
+    return 0
+
+def sigwinch_passthrough (sig, data):
+    # Check for buggy platforms (see pexpect.setwinsize()).
+    if 'TIOCGWINSZ' in dir(termios):
+        TIOCGWINSZ = termios.TIOCGWINSZ
+    else:
+        TIOCGWINSZ = 1074295912 # assume
+    s = struct.pack ("HHHH", 0, 0, 0, 0)
+    a = struct.unpack ('HHHH', fcntl.ioctl(sys.stdout.fileno(), TIOCGWINSZ , s))
+    global global_pexpect_instance
+    global_pexpect_instance.setwinsize(a[0],a[1])
+
+if __name__ == "__main__":
+    try:
+        main()
+    except Exception, e:
+        print "ERROR"
+        print str(e)
+        traceback.print_exc()
+        os._exit(1)
+

Propchange: packages/pexpect/branches/upstream/current/examples/script.py
------------------------------------------------------------------------------
    svn:executable = *

Added: packages/pexpect/branches/upstream/current/examples/ssh_session.py
URL: http://svn.debian.org/wsvn/python-modules/packages/pexpect/branches/upstream/current/examples/ssh_session.py?rev=929&op=file
==============================================================================
--- packages/pexpect/branches/upstream/current/examples/ssh_session.py (added)
+++ packages/pexpect/branches/upstream/current/examples/ssh_session.py Mon Jun 19 10:53:24 2006
@@ -1,0 +1,86 @@
+#
+# Eric S. Raymond
+#
+# Greatly modified by Nigel W. Moriarty
+# April 2003
+#
+from pexpect import *
+import os, sys
+import getpass
+import time
+    
+class ssh_session:
+    "Session with extra state including the password to be used."
+    def __init__(self, user, host, password=None, verbose=0):
+        self.user = user
+        self.host = host
+        self.verbose = verbose
+        self.password = password
+        self.keys = [
+            'authenticity',
+            'assword:',
+            '@@@@@@@@@@@@',
+            'Command not found.',
+            EOF,
+            ]
+        
+        self.f = open('ssh.out','w')
+            
+    def __repr__(self):
+        outl = 'class :'+self.__class__.__name__
+        for attr in self.__dict__:
+            if attr == 'password':
+                outl += '\n\t'+attr+' : '+'*'*len(self.password)
+            else:
+                outl += '\n\t'+attr+' : '+str(getattr(self, attr))
+        return outl
+
+    def __exec(self, command):
+        "Execute a command on the remote host.    Return the output."
+        child = spawn(command,
+                                    #timeout=10,
+                                    )
+        if self.verbose:
+            sys.stderr.write("-> " + command + "\n")
+        seen = child.expect(self.keys)
+        self.f.write(str(child.before) + str(child.after)+'\n')
+        if seen == 0:
+            child.sendline('yes')
+            seen = child.expect(self.keys)
+        if seen == 1:
+            if not self.password:
+                self.password = getpass.getpass('Remote password: ')
+            child.sendline(self.password)
+            child.readline()
+            time.sleep(5)
+            # Added to allow the background running of remote process
+            if not child.isalive():
+                seen = child.expect(self.keys)
+        if seen == 2: 
+            lines = child.readlines()
+            self.f.write(lines)
+        if self.verbose:
+            sys.stderr.write("<- " + child.before + "|\n")
+        try:
+            self.f.write(str(child.before) + str(child.after)+'\n')
+        except:
+            pass
+        self.f.close()
+        return child.before
+
+    def ssh(self, command):
+        return self.__exec("ssh -l %s %s \"%s\"" \
+                                             % (self.user,self.host,command))
+
+    def scp(self, src, dst):
+        return self.__exec("scp %s %s@%s:%s" \
+                                             % (src, session.user, session.host, dst))
+
+    def exists(self, file):
+        "Retrieve file permissions of specified remote file."
+        seen = self.ssh("/bin/ls -ld %s" % file)
+        if string.find(seen, "No such file") > -1:
+            return None # File doesn't exist
+        else:
+            return seen.split()[0] # Return permission field of listing.
+

Propchange: packages/pexpect/branches/upstream/current/examples/ssh_session.py
------------------------------------------------------------------------------
    svn:executable = *

Added: packages/pexpect/branches/upstream/current/examples/ssh_tunnel.py
URL: http://svn.debian.org/wsvn/python-modules/packages/pexpect/branches/upstream/current/examples/ssh_tunnel.py?rev=929&op=file
==============================================================================
--- packages/pexpect/branches/upstream/current/examples/ssh_tunnel.py (added)
+++ packages/pexpect/branches/upstream/current/examples/ssh_tunnel.py Mon Jun 19 10:53:24 2006
@@ -1,0 +1,68 @@
+#!/usr/bin/env python
+"""This starts an SSH tunnel to a given host.
+If the SSH process ever dies then this script will detect that and restart it.
+I use this under Cygwin to keep open encrypted tunnels to
+port 25 (SMTP), port 143 (IMAP4), and port 110 (POP3). I set my mail client to talk to
+localhost and I keep this script running in the background.
+
+Note that this is a rather stupid script at the moment because it
+just looks to see if any ssh process is running. It should really
+make sure that our specific ssh process is running.
+ssh is missing a very useful feature. It has no way to report the
+process id of the background daemon that it creates with the -f command.
+This would be a really useful script if I could figure a way around this problem.
+"""
+import pexpect
+import getpass
+import time
+
+# SMTP:25 IMAP4:143 POP3:110
+tunnel_command = 'ssh -C -N -f -L 25:127.0.0.1:25 -L 143:127.0.0.1:143 -L 110:127.0.0.1:110 %(user)@%(host)'
+host = raw_input('Hostname: ')
+user = raw_input('Username: ')
+X = getpass.getpass('Password: ')
+
+def get_process_info ():
+    # This seems to work on both Linux and BSD, but should otherwise be considered highly UNportable.
+    ps = pexpect.run ('ps ax -O ppid')
+    pass
+def start_tunnel ():
+    try:
+        ssh_tunnel = pexpect.spawn (tunnel_command % globals())
+        ssh_tunnel.expect ('password:')
+        time.sleep (0.1)
+        ssh_tunnel.sendline (X)
+        time.sleep (60) # Cygwin is slow to update process status.
+        ssh_tunnel.expect (pexpect.EOF)
+
+    except Exception, e:
+        print str(e)
+
+def main ():
+    while 1:
+        ps = pexpect.spawn ('ps')
+        time.sleep (1)
+        index = ps.expect (['/usr/bin/ssh', pexpect.EOF, pexpect.TIMEOUT])
+        if index == 2:
+            print 'TIMEOUT in ps command...'
+            print str(ps)
+            time.sleep (13)
+        if index == 1:
+            print time.asctime(),
+            print 'restarting tunnel'
+            start_tunnel ()
+            time.sleep (11)
+	        print 'tunnel OK'
+        else:
+            # print 'tunnel OK'
+            time.sleep (7)
+
+if __name__ == '__main__':
+    main ()
+
+# This was for older SSH versions that didn't have -f option
+#tunnel_command = 'ssh -C -n -L 25:%(host)s:25 -L 110:%(host)s:110 %(user)s@%(host)s -f nothing.sh'
+#nothing_script = """#!/bin/sh
+#while true; do sleep 53; done
+#"""
+

Propchange: packages/pexpect/branches/upstream/current/examples/ssh_tunnel.py
------------------------------------------------------------------------------
    svn:executable = *

Added: packages/pexpect/branches/upstream/current/examples/sshls.py
URL: http://svn.debian.org/wsvn/python-modules/packages/pexpect/branches/upstream/current/examples/sshls.py?rev=929&op=file
==============================================================================
--- packages/pexpect/branches/upstream/current/examples/sshls.py (added)
+++ packages/pexpect/branches/upstream/current/examples/sshls.py Mon Jun 19 10:53:24 2006
@@ -1,0 +1,41 @@
+#!/usr/bin/env python
+'''This runs "ls -l" on a remote host using SSH.
+    At the prompts enter hostname, user, and password.
+'''
+import pexpect
+import getpass
+
+def ssh_command (user, host, password, command):
+    """This runs a command on the remote host. This returns a
+    pexpect.spawn object. This handles the case when you try
+    to connect to a new host and ssh asks you if you want to
+    accept the public key fingerprint and continue connecting.
+    """
+    ssh_newkey = 'Are you sure you want to continue connecting'
+    child = pexpect.spawn('ssh -l %s %s %s'%(user, host, command))
+    i = child.expect([pexpect.TIMEOUT, ssh_newkey, 'password: '])
+    if i == 0: # Timeout
+        print 'ERROR!'
+        print 'SSH could not login. Here is what SSH said:'
+        print child.before, child.after
+        return None
+    if i == 1: # SSH does not have the public key. Just accept it.
+        child.sendline ('yes')
+        child.expect ('password: ')
+        i = child.expect([pexpect.TIMEOUT, 'password: '])
+        if i == 0: # Timeout
+            print 'ERROR!'
+            print 'SSH could not login. Here is what SSH said:'
+            print child.before, child.after
+            return None       
+    child.sendline(password)
+    return child
+
+host = raw_input('Hostname: ')
+user = raw_input('User: ')
+password = getpass.getpass('Password: ')
+
+child = ssh_command (user, host, password, '/bin/ls -l')
+child.expect(pexpect.EOF)
+print child.before
+

Propchange: packages/pexpect/branches/upstream/current/examples/sshls.py
------------------------------------------------------------------------------
    svn:executable = *

Added: packages/pexpect/branches/upstream/current/examples/uptime.py
URL: http://svn.debian.org/wsvn/python-modules/packages/pexpect/branches/upstream/current/examples/uptime.py?rev=929&op=file
==============================================================================
--- packages/pexpect/branches/upstream/current/examples/uptime.py (added)
+++ packages/pexpect/branches/upstream/current/examples/uptime.py Mon Jun 19 10:53:24 2006
@@ -1,0 +1,55 @@
+#!/usr/bin/env python
+"""This displays uptime information using uptime.
+This is redundant perhaps, but it demonstrates expecting for a
+regular expression that uses subgroups.
+"""
+
+import pexpect
+import re
+
+# There are many different styles of uptime results. I try to parse them all. Yeee!
+# Examples from different machines:
+# [x86] Linux 2.4 (Redhat 7.3)
+#  2:06pm  up 63 days, 18 min,  3 users,  load average: 0.32, 0.08, 0.02
+# [x86] Linux 2.4.18-14 (Redhat 8.0)
+#  3:07pm  up 29 min,  1 user,  load average: 2.44, 2.51, 1.57
+# [PPC - G4] MacOS X 10.1 SERVER Edition
+# 2:11PM  up 3 days, 13:50, 3 users, load averages: 0.01, 0.00, 0.00
+# [powerpc] Darwin v1-58.corefa.com 8.2.0 Darwin Kernel Version 8.2.0
+# 10:35  up 18:06, 4 users, load averages: 0.52 0.47 0.36
+# [Sparc - R220] Sun Solaris (8)
+#  2:13pm  up 22 min(s),  1 user,  load average: 0.02, 0.01, 0.01
+# [x86] Linux 2.4.18-14 (Redhat 8)
+# 11:36pm  up 4 days, 17:58,  1 user,  load average: 0.03, 0.01, 0.00
+# AIX jwdir 2 5 0001DBFA4C00
+#  09:43AM   up  23:27,  1 user,  load average: 0.49, 0.32, 0.23
+# OpenBSD box3 2.9 GENERIC#653 i386
+#  6:08PM  up 4 days, 22:26, 1 user, load averages: 0.13, 0.09, 0.08
+
+# This parses uptime output into the major groups using regex group matching.
+p = pexpect.spawn ('uptime')
+p.expect('up\s+(.*?),\s+([0-9]+) users?,\s+load averages?: ([0-9]+\.[0-9][0-9]),?\s+([0-9]+\.[0-9][0-9]),?\s+([0-9]+\.[0-9][0-9])')
+duration, users, av1, av5, av15 = p.match.groups()
+
+# The duration is a little harder to parse because of all the different
+# styles of uptime. I'm sure there is a way to do this all at once with
+# one single regex, but I bet it would be hard to read and maintain.
+# If anyone wants to send me a version using a single regex I'd be happy to see it.
+days = '0'
+hours = '0'
+mins = '0'
+if 'day' in duration:
+    p.match = re.search('([0-9]+)\s+day',duration)
+    days = str(int(p.match.group(1)))
+if ':' in duration:
+    p.match = re.search('([0-9]+):([0-9]+)',duration)
+    hours = str(int(p.match.group(1)))
+    mins = str(int(p.match.group(2)))
+if 'min' in duration:
+    p.match = re.search('([0-9]+)\s+min',duration)
+    mins = str(int(p.match.group(1)))
+
+# Print the parsed fields in CSV format.
+print 'days, hours, minutes, users, cpu avg 1 min, cpu avg 5 min, cpu avg 15 min'
+print '%s, %s, %s, %s, %s, %s, %s' % (days, hours, mins, users, av1, av5, av15)
+

Propchange: packages/pexpect/branches/upstream/current/examples/uptime.py
------------------------------------------------------------------------------
    svn:executable = *

Added: packages/pexpect/branches/upstream/current/fdpexpect.py
URL: http://svn.debian.org/wsvn/python-modules/packages/pexpect/branches/upstream/current/fdpexpect.py?rev=929&op=file
==============================================================================
--- packages/pexpect/branches/upstream/current/fdpexpect.py (added)
+++ packages/pexpect/branches/upstream/current/fdpexpect.py Mon Jun 19 10:53:24 2006
@@ -1,0 +1,73 @@
+"""
+TODO: This is BETA. When it gets stable I will move it into the pexpect.py file.
+"""
+
+from pexpect import *
+import os
+
+__all__ = ['fdspawn']
+
+class fdspawn (spawn):
+    """This is like pexpect.spawn but allows you to supply your own,
+    already open file descriptor. For example, you could use it to
+    read through a file looking for patterns, or to control a modem or
+    serial device.
+    """
+    def __init__ (self, fd, args=[], timeout=30, maxread=2000, searchwindowsize=None, logfile=None):
+        """This takes a file descriptor (an int) or an object that support the fileno() method
+            (returning an int). All Python file-like objects support fileno().
+        """
+        ### TODO: Add better handling of trying to use fdspawn in place of spawn
+        ### TODO: (overload to allow fdspawn to also handle commands as spawn does.
+
+        if type(fd) != type(0) and hasattr(fd, 'fileno'):
+            fd = fd.fileno()
+
+        if type(fd) != type(0):
+            raise ExceptionPexpect ('The fd argument is not an int. If this is a command string then maybe you want to use pexpect.spawn.')
+
+        try: # make sure fd is a valid file descriptor
+            os.fstat(fd)
+        except OSError:
+            raise ExceptionPexpect, 'The fd argument is not a valid file descriptor.'
+
+        self.args = None
+        self.command = None
+        spawn.__init__(self, None, args, timeout, maxread, searchwindowsize, logfile)
+        self.child_fd = fd
+        self.own_fd = False
+        self.closed = False
+        self.name = '<file descriptor %d>' % fd
+
+    def __del__ (self):
+        return
+
+    def close (self):
+        if super(fdspawn, self).child_fd == -1:
+            return
+        if self.own_fd:
+            super(fdspawn, self).close (self)
+        else:
+            self.flush()
+            os.close(super(fdspawn, self).child_fd)
+            self.child_fd = -1
+            self.closed = True
+
+    def isalive (self):
+        """This checks if the file descriptor is still valid.
+            If os.fstat() does not raise an exception then we assume it is alive.
+        """
+        if self.child_fd == -1:
+            return False
+        try:
+            os.fstat(self.child_fd)
+            return True
+        except:
+            return False
+
+    def terminate (self, force=False):
+        raise ExceptionPexpect ('This method is not valid for file descriptors.')
+
+    def kill (self, sig):
+        return
+

Modified: packages/pexpect/branches/upstream/current/pexpect.py
URL: http://svn.debian.org/wsvn/python-modules/packages/pexpect/branches/upstream/current/pexpect.py?rev=929&op=diff
==============================================================================
--- packages/pexpect/branches/upstream/current/pexpect.py (original)
+++ packages/pexpect/branches/upstream/current/pexpect.py Mon Jun 19 10:53:24 2006
@@ -1,55 +1,67 @@
-"""Pexpect is a Python module for spawning child applications;
-controlling them; and responding to expected patterns in their output.
-Pexpect can be used for automating interactive applications such as
-ssh, ftp, passwd, telnet, etc. It can be used to a automate setup scripts
-for duplicating software package installations on different servers.
-It can be used for automated software testing. Pexpect is in the spirit of
-Don Libes' Expect, but Pexpect is pure Python. Other Expect-like
-modules for Python require TCL and Expect or require C extensions to
-be compiled. Pexpect does not use C, Expect, or TCL extensions. It
-should work on any platform that supports the standard Python pty
-module. The Pexpect interface focuses on ease of use so that simple
-tasks are easy.
-
-There are two main interfaces to Pexpect. You can call the function:
-        pexpect.run()
-to execute a command and return the output.
-Do no use this on interactive commands that expect input.
-This is a handy replacment for os.system().
-The more useful interface is the class:
-        pexpect.spawn()
-This creates a spawn instance. This will start the command that you specify.
-You can then interact with the child command through the spawn instance.
-Most commands, including ssh, cannot tell that they are being run inside
-of a script. This works even for commands that ask for passwords or
-other input outside of the normal stdio streams.
-
-Pexpect is Open Source, Free, and all that good stuff.
-License: Python Software Foundation License
-         http://www.opensource.org/licenses/PythonSoftFoundation.html
-
-Noah Spurrier
-Richard Holden
-Marco Molteni
-Kimberley Burchett 
-Robert Stone
-Mike Snitzer
-Marti Raudsepp
-Matt <matt (*) corvil.com>
-Hartmut Goebel
-Chad Schroeder
-Erick Tryzelaar
-Dave Kirby
-Ids vander Molen
-George Todd
-Noel Taylor
-Nicolas D. Cesar
+"""Pexpect is a Python module for spawning child applications and controlling
+them automatically. Pexpect can be used for automating interactive applications
+such as ssh, ftp, passwd, telnet, etc. It can be used to a automate setup
+scripts for duplicating software package installations on different servers. It
+can be used for automated software testing. Pexpect is in the spirit of Don
+Libes' Expect, but Pexpect is pure Python. Other Expect-like modules for Python
+require TCL and Expect or require C extensions to be compiled. Pexpect does not
+use C, Expect, or TCL extensions. It should work on any platform that supports
+the standard Python pty module. The Pexpect interface focuses on ease of use so
+that simple tasks are easy.
+
+There are two main interfaces to Pexpect -- the function, run() and the class,
+spawn. You can call the run() function to execute a command and return the
+output. This is a handy replacement for os.system().
+
+For example:
+    pexpect.run('ls -la')
+
+The more powerful interface is the spawn class. You can use this to spawn an
+external child command and then interact with the child by sending lines and
+expecting responses.
+
+For example:
+    child = pexpect.spawn('scp foo myname at host.example.com:.')
+    child.expect ('Password:')
+    child.sendline (mypassword)
+
+This works even for commands that ask for passwords or other input outside of
+the normal stdio streams.
+
+Credits:
+Noah Spurrier, Richard Holden, Marco Molteni, Kimberley Burchett, Robert Stone,
+Hartmut Goebel, Chad Schroeder, Erick Tryzelaar, Dave Kirby, Ids vander Molen,
+George Todd, Noel Taylor, Nicolas D. Cesar, Alexander Gattin,
+Geoffrey Marshall, Francisco Lourenco, Glen Mabey, Karthik Gurusamy,
+Fernando Perez 
 (Let me know if I forgot anyone.)
 
-$Revision: 1.151 $
-$Date: 2005/11/17 01:19:42 $
+Free, open source, and all that good stuff.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
+Pexpect Copyright (c) 2006 Noah Spurrier
+http://pexpect.sourceforge.net/
+
+$Revision: 395 $
+$Date: 2006-05-31 20:07:18 -0700 (Wed, 31 May 2006) $
 """
-
 try:
     import os, sys, time
     import select
@@ -70,8 +82,8 @@
 A critical module was not found. Probably this operating system does not support it.
 Pexpect is intended for UNIX-like operating systems.""")
 
-__version__ = '2.0'
-__revision__ = '$Revision: 1.151 $'
+__version__ = '2.1'
+__revision__ = '$Revision: 395 $'
 __all__ = ['ExceptionPexpect', 'EOF', 'TIMEOUT', 'spawn', 'run', 'which', 'split_command_line',
     '__version__', '__revision__']
 
@@ -93,9 +105,9 @@
         return ''.join(tblist)
     def __filter_not_pexpect(self, trace_list_item):
         if trace_list_item[0].find('pexpect.py') == -1:
-            return 1
+            return True
         else:
-            return 0
+            return False
 class EOF(ExceptionPexpect):
     """Raised when EOF is read from a child.
     """
@@ -111,7 +123,7 @@
 ##class MAXBUFFER(ExceptionPexpect):
 ##    """Raised when a scan buffer fills before matching an expected pattern."""
 
-def run (command, timeout=-1, withexitstatus=0, events=None, extra_args=None):
+def run (command, timeout=-1, withexitstatus=False, events=None, extra_args=None, logfile=None):
     """This function runs the given command; waits for it to finish;
     then returns all output as a string. STDERR is included in output.
     If the full path to the command is not given then the path is searched.
@@ -121,6 +133,17 @@
     If you set withexitstatus to true, then run will return a tuple of
     (command_output, exitstatus). If withexitstatus is false then this
     returns just command_output.
+
+    The run() function can often be used instead of creating a spawn instance.
+    For example, the following code uses spawn:
+        from pexpect import *
+        child = spawn('scp foo myname at host.example.com:.')
+        child.expect ('(?i)password')
+        child.sendline (mypassword)
+    The previous code can be replace with the following, which you may
+    or may not find simpler:
+        from pexpect import *
+        run ('scp foo myname at host.example.com:.', events={'(?i)password': mypassword})
 
     Examples:
     Start the apache daemon on the local machine:
@@ -161,9 +184,9 @@
     a callback function through run() through the locals dictionary passed to a callback.
     """
     if timeout == -1:
-        child = spawn(command, maxread=2000)
+        child = spawn(command, maxread=2000, logfile=logfile)
     else:
-        child = spawn(command, timeout=timeout, maxread=2000)
+        child = spawn(command, timeout=timeout, maxread=2000, logfile=logfile)
     if events is not None:
         patterns = events.keys()
         responses = events.values()
@@ -204,12 +227,12 @@
     else:
         return child_result
 
-class spawn:
+class spawn (object):
     """This is the main class interface for Pexpect.
     Use this class to start and control child applications.
     """
 
-    def __init__(self, command, args=[], timeout=30, maxread=2000, searchwindowsize=None, logfile=None):
+    def __init__(self, command, args=[], timeout=30, maxread=2000, searchwindowsize=None, logfile=None, env=None):
         """This is the constructor. The command parameter may be a string
         that includes a command and any arguments to the command. For example:
             p = pexpect.spawn ('/usr/bin/ftp')
@@ -224,9 +247,11 @@
         send() and sendline().
 
         The maxread attribute sets the read buffer size.
-        This is maximum number of bytes that Pexpect will try to read from a TTY at one time.
-        The default buffer size is 1 (unbuffered). Setting this value higher
-        will help performance in cases where large amounts of output are read back from the child.
+        This is maximum number of bytes that Pexpect will try to read
+        from a TTY at one time.
+        Seeting the maxread size to 1 will turn off buffering.
+        Setting the maxread value higher may help performance in cases
+        where large amounts of output are read back from the child.
         This feature is useful in conjunction with searchwindowsize.
         
         The searchwindowsize attribute sets the how far back in
@@ -252,10 +277,10 @@
             child = pexpect.spawn('some_command')
             child.logfile = sys.stdout
             
-        The delaybeforesend helps overcome weird behavior that many users were experiencing.
+        The delaybeforesend helps overcome a weird behavior that many users were experiencing.
         The typical problem was that a user would expect() a "Password:" prompt and
         then immediately call sendline() to send the password. The user would then
-        see that their password was echoed back to them. Of course, passwords don't
+        see that their password was echoed back to them. Passwords don't
         normally echo. The problem is caused by the fact that most applications
         print out the "Password" prompt and then turn off stdin echo, but if you
         send your password before the application turned off echo, then you get
@@ -289,15 +314,16 @@
         self.stderr = sys.stderr
 
         self.patterns = None
+        self.ignorecase = False
         self.before = None
         self.after = None
         self.match = None
         self.match_index = None
-        self.terminated = 1
+        self.terminated = True
         self.exitstatus = None
         self.signalstatus = None
-        self.status = None
-        self.flag_eof = 0
+        self.status = None # status returned by os.waitpid 
+        self.flag_eof = False
         self.pid = None
         self.child_fd = -1 # initially closed
         self.timeout = timeout
@@ -307,13 +333,29 @@
         self.buffer = '' # This is the read buffer. See maxread.
         self.searchwindowsize = searchwindowsize # Anything before searchwindowsize point is preserved, but not searched.
         self.delaybeforesend = 0.1 # Sets sleep time used just before sending data to child.
-        self.softspace = 0 # File-like object.
+        self.delayafterclose = 0.1 # Sets delay in close() method to allow kernel time to update process status.
+        self.delayafterterminate = 0.1 # Sets delay in terminate() method to allow kernel time to update process status.
+        self.softspace = False # File-like object.
         self.name = '<' + repr(self) + '>' # File-like object.
         self.encoding = None # File-like object.
-        self.closed = 1 # File-like object.
-        
+        self.closed = True # File-like object.
+        self.env = env
+        self.__irix_hack = sys.platform.lower().find('irix') >= 0 # This flags if we are running on irix
+        self.use_native_pty_fork = not (sys.platform.lower().find('solaris') >= 0) # Solaris uses internal __fork_pty(). All other use pty.fork().
+
+        # allow dummy instances for subclasses that may not use command or args.
+        if command is None:
+            self.command = None
+            self.args = None
+            self.name = '<pexpect factory incomplete>'
+            return
+
+        # If command is an int type then it may represent a file descriptor.
+        if type(command) == type(0):
+            raise ExceptionPexpect ('Command is an int type. If this is a file descriptor then maybe you want to use fdpexpect.fdspawn which takes an existing file descriptor instead of a command string.')
+
         if type (args) != type([]):
-            raise TypeError ('The second argument, args, must be a list.')
+            raise TypeError ('The argument, args, must be a list.')
 
         if args == []:
             self.args = split_command_line(command)
@@ -324,7 +366,7 @@
             self.command = command
 
         command_with_path = which(self.command)
-        if command_with_path == None:
+        if command_with_path is None:
             raise ExceptionPexpect ('The command was not found or was not executable: %s.' % self.command)
         self.command = command_with_path
         self.args[0] = self.command
@@ -339,9 +381,8 @@
         If the child file descriptor was opened outside of this class
         (passed to the constructor) then this does not close it.
         """
-        if self.closed:
-            return
-        self.close()
+        if not self.closed:
+            self.close()
 
     def __str__(self):
         """This returns the current state of the pexpect object as a string.
@@ -369,12 +410,16 @@
         s.append('flag_eof: ' + str(self.flag_eof))
         s.append('pid: ' + str(self.pid))
         s.append('child_fd: ' + str(self.child_fd))
+        s.append('closed: ' + str(self.closed))
         s.append('timeout: ' + str(self.timeout))
         s.append('delimiter: ' + str(self.delimiter))
         s.append('logfile: ' + str(self.logfile))
         s.append('maxread: ' + str(self.maxread))
+        s.append('ignorecase: ' + str(self.ignorecase))
         s.append('searchwindowsize: ' + str(self.searchwindowsize))
         s.append('delaybeforesend: ' + str(self.delaybeforesend))
+        s.append('delayafterclose: ' + str(self.delayafterclose))
+        s.append('delayafterterminate: ' + str(self.delayafterterminate))
         return '\n'.join(s)
 
     def __spawn(self):
@@ -391,19 +436,26 @@
         # That may not necessarily be bad because you may haved spawned a child
         # that performs some task; creates no stdout output; and then dies.
 
-        assert self.pid == None, 'The pid member should be None.'
-        assert self.command != None, 'The command member should not be None.'
-
-        try:
-            self.pid, self.child_fd = pty.fork()
-        except OSError, e:
-            raise ExceptionPexpect('Pexpect: pty.fork() failed: ' + str(e))
+        assert self.pid is None, 'The pid member should be None.'
+        assert self.command is not None, 'The command member should not be None.'
+
+        if self.use_native_pty_fork:
+            try:
+                self.pid, self.child_fd = pty.fork()
+            except OSError, e:
+                raise ExceptionPexpect('Error! pty.fork() failed: ' + str(e))
+        else: # Use internal __fork_pty
+            self.pid, self.child_fd = self.__fork_pty() 
 
         if self.pid == 0: # Child
-            try: # Some platforms do not like setwinsize (Cygwin).
+            try: 
                 self.child_fd = sys.stdout.fileno() # used by setwinsize()
                 self.setwinsize(24, 80)
-            except:
+            except: 
+                # Some platforms do not like setwinsize (Cygwin).
+                # This will cause problem when running applications that
+                # are very picky about window size.
+                # This is a serious limitation, but not a show stopper.
                 pass
             # Do not allow child to inherit open file descriptors from parent.
             max_fd = resource.getrlimit(resource.RLIMIT_NOFILE)[0]
@@ -418,30 +470,106 @@
             # (specifically, Tomcat).
             signal.signal(signal.SIGHUP, signal.SIG_IGN)
 
-            os.execv(self.command, self.args)
+            if self.env is None:
+                os.execv(self.command, self.args)
+            else:
+                os.execvpe(self.command, self.args, self.env)
 
         # Parent
-        self.terminated = 0
-        self.closed = 0
-
+        self.terminated = False
+        self.closed = False
+
+    def __fork_pty(self):
+        """This implements a substitute for the forkpty system call.
+        This should be more portable than the pty.fork() function.
+        Specifically, this should work on Solaris.
+        
+        Modified 10.06.05 by Geoff Marshall:
+            Implemented __fork_pty() method to resolve the issue with Python's 
+            pty.fork() not supporting Solaris, particularly ssh.
+        Based on patch to posixmodule.c authored by Noah Spurrier:
+            http://mail.python.org/pipermail/python-dev/2003-May/035281.html
+        """
+        parent_fd, child_fd = os.openpty()
+        if parent_fd < 0 or child_fd < 0:
+            raise ExceptionPexpect, "Error! Could not open pty with os.openpty()."
+        
+        pid = os.fork()
+        if pid < 0:
+            raise ExceptionPexpect, "Error! Failed os.fork()."
+        elif pid == 0:
+            # Child.
+            os.close(parent_fd)
+            self.__pty_make_controlling_tty(child_fd)
+            
+            os.dup2(child_fd, 0)
+            os.dup2(child_fd, 1)
+            os.dup2(child_fd, 2)
+            
+            if child_fd > 2:
+                os.close(child_fd)
+        else:
+            # Parent.
+            os.close(child_fd)
+        
+        return pid, parent_fd
+                
+    def __pty_make_controlling_tty(self, tty_fd):
+        """This makes the pseudo-terminal the controlling tty.
+        This should be more portable than the pty.fork() function.
+        Specifically, this should work on Solaris.
+        """
+        child_name = os.ttyname(tty_fd)
+        
+        # Disconnect from controlling tty if still connected.
+        fd = os.open("/dev/tty", os.O_RDWR | os.O_NOCTTY);
+        if fd >= 0:
+            os.close(fd)
+            
+        os.setsid()
+        
+        # Verify we are disconnected from controlling tty
+        try:
+            fd = os.open("/dev/tty", os.O_RDWR | os.O_NOCTTY);
+            if fd >= 0:
+                os.close(fd)
+                raise ExceptionPexpect, "Error! We are not disconnected from a controlling tty."
+        except:
+            # Good! We are disconnected from a controlling tty.
+            pass
+        
+        # Verify we can open child pty.
+        fd = os.open(child_name, os.O_RDWR);
+        if fd < 0:
+            raise ExceptionPexpect, "Error! Could not open child pty, " + child_name
+        else:
+            os.close(fd)
+
+        # Verify we now have a controlling tty.
+        fd = os.open("/dev/tty", os.O_WRONLY)
+        if fd < 0:
+            raise ExceptionPexpect, "Error! Could not open controlling tty, /dev/tty"
+        else:
+            os.close(fd)
+         
     def fileno (self):   # File-like object.
         """This returns the file descriptor of the pty for the child.
         """
         return self.child_fd
 
-    def close (self, force=0):   # File-like object.
+    def close (self, force=True):   # File-like object.
         """This closes the connection with the child application.
         Note that calling close() more than once is valid.
         This emulates standard Python behavior with files.
-        Set force to 1 if you want to make sure that the child is terminated
+        Set force to True if you want to make sure that the child is terminated
         (SIGKILL is sent if the child ignores SIGHUP and SIGINT).
         """
-        if self.child_fd != -1:
+        if not self.closed:
             self.flush()
             os.close (self.child_fd)
             self.child_fd = -1
-            self.closed = 1
-            time.sleep(0.1) # Give kernel time to update process status.
+            self.closed = True
+            time.sleep(self.delayafterclose) # Give kernel time to update process status.
             if self.isalive():
                 if not self.terminate(force):
                     raise ExceptionPexpect ('close() could not terminate the child using terminate()')
@@ -452,11 +580,11 @@
         pass
 
     def isatty (self):   # File-like object.
-        """This returns 1 if the file descriptor is open and connected to a tty(-like) device, else 0.
+        """This returns True if the file descriptor is open and connected to a tty(-like) device, else False.
         """
         return os.isatty(self.child_fd)
 
-    def setecho (self, on):
+    def setecho (self, state):
         """This sets the terminal echo mode on or off.
         Note that anything the child sent before the echo will be lost, so
         you should be sure that your input buffer is empty before you setecho.
@@ -465,7 +593,7 @@
             p.sendline ('1234') # We will see this twice (once from tty echo and again from cat).
             p.expect (['1234'])
             p.expect (['1234'])
-            p.setecho(0) # Turn off tty echo
+            p.setecho(False) # Turn off tty echo
             p.sendline ('abcd') # We will set this only once (echoed by cat).
             p.sendline ('wxyz') # We will set this only once (echoed by cat)
             p.expect (['abcd'])
@@ -474,7 +602,7 @@
         will be lost:
             p = pexpect.spawn('cat')
             p.sendline ('1234') # We will see this twice (once from tty echo and again from cat).
-            p.setecho(0) # Turn off tty echo
+            p.setecho(False) # Turn off tty echo
             p.sendline ('abcd') # We will set this only once (echoed by cat).
             p.sendline ('wxyz') # We will set this only once (echoed by cat)
             p.expect (['1234'])
@@ -484,14 +612,14 @@
         """
         self.child_fd
         new = termios.tcgetattr(self.child_fd)
-        if on:
+        if state:
             new[3] = new[3] | termios.ECHO
         else:
             new[3] = new[3] & ~termios.ECHO
         # I tried TCSADRAIN and TCSAFLUSH, but these were inconsistent
         # and blocked on some platforms. TCSADRAIN is probably ideal if it worked.
         termios.tcsetattr(self.child_fd, termios.TCSANOW, new)
-
+    
     def read_nonblocking (self, size = 1, timeout = -1):
         """This reads at most size characters from the child application.
         It includes a timeout. If the read does not complete within the
@@ -514,7 +642,7 @@
         This is a wrapper around os.read().
         It uses select.select() to implement a timeout. 
         """
-        if self.child_fd == -1:
+        if self.closed:
             raise ValueError ('I/O operation on closed file in read_nonblocking().')
 
         if timeout == -1:
@@ -526,24 +654,25 @@
         # For this case, I test isalive() before doing any reading.
         # If isalive() is false, then I pretend that this is the same as EOF.
         if not self.isalive():
-            r, w, e = select.select([self.child_fd], [], [], 0) # timeout of 0 means "poll"
+            r,w,e = self.__select([self.child_fd], [], [], 0) # timeout of 0 means "poll"
             if not r:
-                self.flag_eof = 1
+                self.flag_eof = True
                 raise EOF ('End Of File (EOF) in read_nonblocking(). Braindead platform.')
-        elif sys.platform.lower().find('irix') >= 0:
+        elif self.__irix_hack:
             # This is a hack for Irix. It seems that Irix requires a long delay before checking isalive.
-            # This adds a 2 second delay, but only when the child is terminated
-            r, w, e = select.select([self.child_fd], [], [], 2)
+            # This adds a 2 second delay, but only when the child is terminated.
+            r, w, e = self.__select([self.child_fd], [], [], 2)
             if not r and not self.isalive():
-                self.flag_eof = 1
+                self.flag_eof = True
                 raise EOF ('End Of File (EOF) in read_nonblocking(). Pokey platform.')
             
-        r, w, e = select.select([self.child_fd], [], [], timeout)
+        r,w,e = self.__select([self.child_fd], [], [], timeout)
+        
         if not r:
             if not self.isalive():
                 # Some platforms, such as Irix, will claim that their processes are alive;
                 # then timeout on the select; and then finally admit that they are not alive.
-                self.flag_eof = 1
+                self.flag_eof = True
                 raise EOF ('End of File (EOF) in read_nonblocking(). Very pokey platform.')
             else:
                 raise TIMEOUT ('Timeout exceeded in read_nonblocking().')
@@ -552,13 +681,13 @@
             try:
                 s = os.read(self.child_fd, size)
             except OSError, e: # Linux does this
-                self.flag_eof = 1
+                self.flag_eof = True
                 raise EOF ('End Of File (EOF) in read_nonblocking(). Exception style platform.')
             if s == '': # BSD style
-                self.flag_eof = 1
+                self.flag_eof = True
                 raise EOF ('End Of File (EOF) in read_nonblocking(). Empty string style platform.')
 
-            if self.logfile != None:
+            if self.logfile is not None:
                 self.logfile.write (s)
                 self.logfile.flush()
 
@@ -596,12 +725,13 @@
     def readline (self, size = -1):    # File-like object.
         """This reads and returns one entire line. A trailing newline is kept in
         the string, but may be absent when a file ends with an incomplete line. 
-        Note: This readline() looks for a \\r\\n pair even on UNIX because this is 
-        what the pseudo tty device returns. So contrary to what you may be used to
-        you will receive a newline as \\r\\n.
+        Note: This readline() looks for a \\r\\n pair even on UNIX because
+        this is what the pseudo tty device returns. So contrary to what you
+        may expect you will receive the newline as \\r\\n.
         An empty string is returned when EOF is hit immediately.
         Currently, the size agument is mostly ignored, so this behavior is not
-        standard for a file-like object. If size is 0 then an empty string is returned.
+        standard for a file-like object. If size is 0 then an empty string
+        is returned.
         """
         if size == 0:
             return ''
@@ -612,7 +742,7 @@
             return self.before
 
     def __iter__ (self):    # File-like object.
-        """This is to support interators over a file-like object.
+        """This is to support iterators over a file-like object.
         """
         return self
 
@@ -629,7 +759,7 @@
         the lines thus read. The optional "sizehint" argument is ignored.
         """        
         lines = []
-        while 1:
+        while True:
             line = self.readline()
             if not line:
                 break
@@ -656,7 +786,7 @@
         If a log file was set then the data is also written to the log.
         """
         time.sleep(self.delaybeforesend)
-        if self.logfile != None:
+        if self.logfile is not None:
             self.logfile.write (str)
             self.logfile.flush()
         c = os.write(self.child_fd, str)
@@ -698,50 +828,76 @@
             termios.tcsetattr(fd, termios.TCSADRAIN, old)
 
     def eof (self):
-        """This returns 1 if the EOF exception was raised at some point.
+        """This returns True if the EOF exception was ever raised.
         """
         return self.flag_eof
 
-    def terminate(self, force=0):
+    def terminate(self, force=False):
         """This forces a child process to terminate.
-        It starts nicely with SIGHUP and SIGINT. If "force" is 1 then
+        It starts nicely with SIGHUP and SIGINT. If "force" is True then
         moves onto SIGKILL.
-        This returns true if the child was terminated.
-        This returns false if the child could not be terminated.
+        This returns True if the child was terminated.
+        This returns False if the child could not be terminated.
         """
         if not self.isalive():
-            return 1
+            return True
         self.kill(signal.SIGHUP)
-        time.sleep(0.1)
+        time.sleep(self.delayafterterminate)
         if not self.isalive():
-            return 1
+            return True
         self.kill(signal.SIGCONT)
-        time.sleep(0.1)
+        time.sleep(self.delayafterterminate)
         if not self.isalive():
-            return 1
+            return True
         self.kill(signal.SIGINT)
-        time.sleep(0.1)
+        time.sleep(self.delayafterterminate)
         if not self.isalive():
-            return 1
+            return True
         if force:
             self.kill(signal.SIGKILL)
-            time.sleep(0.1)
+            time.sleep(self.delayafterterminate)
             if not self.isalive():
-                return 1
+                return True
             else:
-                return 0
-        return 0
-        #raise ExceptionPexpect ('terminate() could not terminate child process. Try terminate(force=1)?')
-        
+                return False
+        return False
+        #raise ExceptionPexpect ('terminate() could not terminate child process. Try terminate(force=True)?')
+     
+    def wait(self):
+        """This waits until the child exits. This is a blocking call.
+            This will not read any data from the child, so this will block forever
+            if the child has unread output and has terminated. In other words, the child
+            may have printed output then called exit(); but, technically, the child is
+            still alive until its output is read.
+        """
+        if self.isalive():
+            pid, status = os.waitpid(self.pid, 0)
+        else:
+            raise ExceptionPexpect ('Cannot wait for dead child process.')
+        self.exitstatus = os.WEXITSTATUS(status)
+        if os.WIFEXITED (status):
+            self.status = status
+            self.exitstatus = os.WEXITSTATUS(status)
+            self.signalstatus = None
+            self.terminated = True
+        elif os.WIFSIGNALED (status):
+            self.status = status
+            self.exitstatus = None
+            self.signalstatus = os.WTERMSIG(status)
+            self.terminated = True
+        elif os.WIFSTOPPED (status):
+            raise ExceptionPexpect ('Wait was called for a child process that is stopped. This is not supported. Is some other process attempting job control with our child pid?')
+        return self.exitstatus
+   
     def isalive(self):
         """This tests if the child process is running or not.
         This is non-blocking. If the child was terminated then this
         will read the exitstatus or signalstatus of the child.
-        This returns 1 if the child process appears to be running or 0 if not.
+        This returns True if the child process appears to be running or False if not.
         It can take literally SECONDS for Solaris to return the right status.
         """
         if self.terminated:
-            return 0
+            return False
 
         if self.flag_eof:
             # This is for Linux, which requires the blocking form of waitpid to get
@@ -776,28 +932,24 @@
             # for Irix which seems to require a blocking call on waitpid or select, so I let read_nonblocking
             # take care of this situation (unfortunately, this requires waiting through the timeout).
             if pid == 0:
-                return 1
+                return True
 
         if pid == 0:
-            return 1
+            return True
 
         if os.WIFEXITED (status):
             self.status = status
             self.exitstatus = os.WEXITSTATUS(status)
             self.signalstatus = None
-            self.terminated = 1
-            return 0
+            self.terminated = True
         elif os.WIFSIGNALED (status):
             self.status = status
             self.exitstatus = None
             self.signalstatus = os.WTERMSIG(status)
-            self.terminated = 1
-            return 0
+            self.terminated = True
         elif os.WIFSTOPPED (status):
             raise ExceptionPexpect ('isalive() encountered condition where child process is stopped. This is not supported. Is some other process attempting job control with our child pid?')
-
-        raise ExceptionPexpect ('isalive() reached unexpected condition where waitpid matched child pid, but status was not matched by WIFEXITED, WIFSIGNALED, or WIFSTOPPED.')
-
+        return False
 
     def kill(self, sig):
         """This sends the given signal to the child application.
@@ -834,10 +986,13 @@
         if type(patterns) is not types.ListType:
             patterns = [patterns]
 
+        compile_flags = re.DOTALL # Allow dot to match \n
+        if self.ignorecase:
+            compile_flags = compile_flags | re.IGNORECASE
         compiled_pattern_list = []
         for p in patterns:
             if type(p) is types.StringType:
-                compiled_pattern_list.append(re.compile(p, re.DOTALL))
+                compiled_pattern_list.append(re.compile(p, compile_flags))
             elif p is EOF:
                 compiled_pattern_list.append(EOF)
             elif p is TIMEOUT:
@@ -850,15 +1005,15 @@
         return compiled_pattern_list
  
     def expect(self, pattern, timeout = -1, searchwindowsize=None):
+
         """This seeks through the stream until a pattern is matched.
         The pattern is overloaded and may take several types including a list.
-        The pattern can be a StringType, EOF, a compiled re, or
-        a list of those types. Strings will be compiled to re types.
-        This returns the index into the pattern list. If the pattern was
-        not a list this returns index 0 on a successful match.
-        This may raise exceptions for EOF or TIMEOUT.
-        To avoid the EOF or TIMEOUT exceptions add EOF or TIMEOUT to
-        the pattern list.
+        The pattern can be a StringType, EOF, a compiled re, or a list of
+        those types. Strings will be compiled to re types. This returns the
+        index into the pattern list. If the pattern was not a list this
+        returns index 0 on a successful match. This may raise exceptions for
+        EOF or TIMEOUT. To avoid the EOF or TIMEOUT exceptions add
+        EOF or TIMEOUT to the pattern list.
 
         After a match is found the instance attributes
         'before', 'after' and 'match' will be set.
@@ -910,7 +1065,7 @@
 
     def expect_list(self, pattern_list, timeout = -1, searchwindowsize = -1):
         """This takes a list of compiled regular expressions and returns 
-        the index into the pattern_list that matched the child's output.
+        the index into the pattern_list that matched the child output.
         The list may also contain EOF or TIMEOUT (which are not
         compiled regular expressions). This method is similar to
         the expect() method except that expect_list() does not
@@ -920,18 +1075,19 @@
         If timeout==-1 then the self.timeout value is used.
         If searchwindowsize==-1 then the self.searchwindowsize value is used.
         """
+
         self.patterns = pattern_list
 
         if timeout == -1:
             timeout = self.timeout
-        if timeout != None:
+        if timeout is not None:
             end_time = time.time() + timeout 
         if searchwindowsize == -1:
             searchwindowsize = self.searchwindowsize
 
         try:
             incoming = self.buffer
-            while 1: # Keep reading until exception or return.
+            while True: # Keep reading until exception or return.
                 # Sequence through the list of patterns looking for a match.
                 first_match = -1
                 for cre in pattern_list:
@@ -958,6 +1114,7 @@
                     raise TIMEOUT ('Timeout exceeded in expect_list().')
                 # Still have time left, so read more data
                 c = self.read_nonblocking (self.maxread, timeout)
+                time.sleep (0.0001)
                 incoming = incoming + c
                 if timeout is not None:
                     timeout = end_time - time.time()
@@ -992,19 +1149,19 @@
             raise
 
     def getwinsize(self):
-        """This returns the window size of the child tty.
+        """This returns the terminal window size of the child tty.
         The return value is a tuple of (rows, cols).
         """
         if 'TIOCGWINSZ' in dir(termios):
             TIOCGWINSZ = termios.TIOCGWINSZ
         else:
-            TIOCGWINSZ = 1074295912L # Assume
+            TIOCGWINSZ = 1074295912L # assume if not defined
         s = struct.pack('HHHH', 0, 0, 0, 0)
         x = fcntl.ioctl(self.fileno(), TIOCGWINSZ, s)
         return struct.unpack('HHHH', x)[0:2]
 
     def setwinsize(self, r, c):
-        """This sets the window size of the child tty.
+        """This sets the terminal window size of the child tty.
         This will cause a SIGWINCH signal to be sent to the child.
         This does not change the physical window size.
         It changes the size reported to TTY-aware applications like
@@ -1028,15 +1185,25 @@
         s = struct.pack('HHHH', r, c, 0, 0)
         fcntl.ioctl(self.fileno(), TIOCSWINSZ, s)
 
-    def interact(self, escape_character = chr(29)):
+    def interact(self, escape_character = chr(29), input_filter = None, output_filter = None):
         """This gives control of the child process to the interactive user
         (the human at the keyboard).
         Keystrokes are sent to the child process, and the stdout and stderr
         output of the child process is printed.
-        When the user types the escape_character this method will stop.
-        The default for escape_character is ^] (ASCII 29).
         This simply echos the child stdout and child stderr to the real
         stdout and it echos the real stdin to the child stdin.
+        When the user types the escape_character this method will stop.
+        The default for escape_character is ^]. This should not be confused
+        with ASCII 27 -- the ESC character. ASCII 29 was chosen
+        for historical merit because this is the character used
+        by 'telnet' as the escape character. The escape_character will
+        not be sent to the child process.
+
+        You may pass in optional input and output filter functions.
+        These functions should take a string and return a string.
+        The output_filter will be passed all the output from the child process.
+        The input_filter will be passed all the keyboard input from the user.
+        The input_filter is run BEFORE the check for the escape_character.
 
         Note that if you change the window size of the parent
         the SIGWINCH signal will not be passed through to the child.
@@ -1048,7 +1215,7 @@
                 a = struct.unpack('hhhh', fcntl.ioctl(sys.stdout.fileno(), termios.TIOCGWINSZ , s))
                 global p
                 p.setwinsize(a[0],a[1])
-            p = pexpect.spawn('/bin/bash') # Note this is global
+            p = pexpect.spawn('/bin/bash') # Note this is global and used in sigwinch_passthrough.
             signal.signal(signal.SIGWINCH, sigwinch_passthrough)
             p.interact()
         """
@@ -1059,7 +1226,7 @@
         mode = tty.tcgetattr(self.STDIN_FILENO)
         tty.setraw(self.STDIN_FILENO)
         try:
-            self.__interact_copy(escape_character)
+            self.__interact_copy(escape_character, input_filter, output_filter)
         finally:
             tty.tcsetattr(self.STDIN_FILENO, tty.TCSAFLUSH, mode)
 
@@ -1073,26 +1240,49 @@
         """This is used by the interact() method.
         """
         return os.read(fd, 1000)
-    def __interact_copy(self, escape_character = None):
+    def __interact_copy(self, escape_character = None, input_filter = None, output_filter = None):
         """This is used by the interact() method.
         """
         while self.isalive():
-            try:
-                r, w, e = select.select([self.child_fd, self.STDIN_FILENO], [], [])
-            except select.errno, e:
-                if e[0] != errno.EINTR:
-                    raise
+            r,w,e = self.__select([self.child_fd, self.STDIN_FILENO], [], [])
             if self.child_fd in r:
                 data = self.__interact_read(self.child_fd)
-                if self.logfile != None:
+                if output_filter: data = output_filter(data)
+                if self.logfile is not None:
                     self.logfile.write (data)
                     self.logfile.flush()
                 os.write(self.STDOUT_FILENO, data)
             if self.STDIN_FILENO in r:
                 data = self.__interact_read(self.STDIN_FILENO)
+                if input_filter: data = input_filter(data)
+                i = data.rfind(escape_character)
+                if i != -1:
+                    data = data[:i]
+                    self.__interact_writen(self.child_fd, data)
+                    break
                 self.__interact_writen(self.child_fd, data)
-                if escape_character in data:
-                    break
+    def __select (self, iwtd, owtd, ewtd, timeout=None):
+        """This is a wrapper around select.select() that ignores signals.
+        If select.select raises a select.error exception and errno is an EINTR error then
+        it is ignored. Mainly this is used to ignore sigwinch (terminal resize).
+        """
+        # if select() is interrupted by a signal (errno==EINTR) then
+        # we loop back and enter the select() again.
+        if timeout is not None:
+            end_time = time.time() + timeout 
+        while True:
+            try:
+                return select.select (iwtd, owtd, ewtd, timeout)
+            except select.error, e:
+                if e[0] == errno.EINTR:
+                    # if we loop back we have to subtract the amount of time we already waited.
+                    if timeout is not None:
+                        timeout = end_time - time.time()
+                        if timeout < 0:
+                            return ([],[],[])
+                else: # something else caused the select.error, so this really is an exception
+                    raise
+
 ##############################################################################
 # The following methods are no longer supported or allowed..                
     def setmaxread (self, maxread):

Modified: packages/pexpect/branches/upstream/current/pxssh.py
URL: http://svn.debian.org/wsvn/python-modules/packages/pexpect/branches/upstream/current/pxssh.py?rev=929&op=diff
==============================================================================
--- packages/pexpect/branches/upstream/current/pxssh.py (original)
+++ packages/pexpect/branches/upstream/current/pxssh.py Mon Jun 19 10:53:24 2006
@@ -1,54 +1,59 @@
-"""This class extends pexpect.spawn to specialize setting up SSH connections.
-This adds methods for login, logout, and expecting the prompt.
-
-TODO: 
-* set_unique_prompt() is using a hard-coded constant for PROMPT.
-  That should be configurable.
-* login() needs a state machine or at least a clear flow chart of the login process.
-* login() needs some ability to fall-back to a fail-safe login method on timeout.
-  If he login is taking too long then I should 'punt' and try setting the prompt anyway.
-  Perhaps use some sort of prompt challange-response.
-"""
 from pexpect import *
-import os, sys, getopt, shutil
-from time import sleep
-
-
-# used to set shell command-line prompt to something more unique.
-PROMPT = "\[PEXPECT\]\$ "
-# SUBTLE HACK ALERT!
-# Note that the command to set the prompt uses a slightly different string
-# than the regular expression to match it. This is because when you set the
-# prompt the command will echo back, but we don't want to match the echoed
-# command. So if we make the set command slightly different than the regex
-# we eliminate the problem. To make the set command different we add a
-# backslash in front of $. The $ doesn't need to be escaped, but it doesn't
-# hurt and serves to make the set command different than the regex.
+#import os, sys, getopt, shutil
 
 class pxssh (spawn):
-    """This extends the spawn class to specialize for running 'ssh' command-line client.
-        This adds methods to login, logout, and expect_prompt.
+    """This class extends pexpect.spawn to specialize setting up SSH connections.
+    This adds methods for login, logout, and expecting the prompt.
+    It does various hacky things to handle any situation in the SSH login process.
+    For example, if the session is your first login, then it automatically
+    accepts the certificate; or if you have public key authentication setup
+    and you don't need a password then this is OK too.
+
+    Example usage that runs 'ls -l' on server and prints the result:
+        import pxssh
+        s = pxssh.pxssh()
+        if not s.login ('localhost', 'myusername', 'mypassword'):
+            print "SSH session failed on login."
+            print str(s)
+        else:
+            print "SSH session login successful"
+            s.sendline ('ls -l')
+            s.prompt()           # match the prompt
+            print s.before     # print everything before the prompt.
+            s.logout()
     """
-    def __init__(self):
-        self.PROMPT = "\[PEXPECT\]\$ "
-        pass
-    def logout(self):
-        """This sends exit. If there are stopped jobs then this sends exit twice.
+
+    def __init__ (self):
+        # SUBTLE HACK ALERT!
+        # Note that the command to set the prompt uses a slightly different string
+        # than the regular expression to match it. This is because when you set the
+        # prompt the command will echo back, but we don't want to match the echoed
+        # command. So if we make the set command slightly different than the regex
+        # we eliminate the problem. To make the set command different we add a
+        # backslash in front of $. The $ doesn't need to be escaped, but it doesn't
+        # hurt and serves to make the set command different than the regex.
+        self.PROMPT = "\[PEXPECT\][\$\#] " # used to match the command-line prompt.
+        # used to set shell command-line prompt to something more unique.
+        self.PROMPT_SET_SH = "PS1='[PEXPECT]\$ '"
+        self.PROMPT_SET_CSH = "set prompt='[PEXPECT]\$ '"
+
+    ### TODO: This is getting messy and I'm pretty sure this isn't perfect.
+    ### TODO: I need to draw a better flow chart for this.
+    def login (self,server,username,password='',terminal_type='ansi',original_prompts=r"][#$]|~[#$]|bash.*?[#$]|[#$] ",login_timeout=10):
+        """This logs the user into the given server. By default the prompt is
+        rather optimistic and should be considered more of an example. It's
+        better to try to match the prompt as exactly as possible to prevent
+        any false matches by server strings such as a "Message Of The Day" or
+        something. The closer you can make the original_prompt match your real prompt
+        then the better. A timeout will not necessarily cause the login to fail.
+        In the case of a timeout we assume that the prompt was so weird that
+        we could not match it. We still try to reset the prompt to something
+        more unique. If that still fails then we return False.
         """
-        self.sendline("exit")
-        index = self.expect([EOF, "(?i)there are stopped jobs"])
-        if index==1:
-            self.sendline("exit")
-            self.expect(EOF)
-
-    # I need to draw a better flow chart for this.
-    # This is getting messy and I'm pretty sure this isn't perfect.
-    def login(self,server,username,password,terminal_type='ansi'):
-        original_prompts = r"][#$]|~[#$]|bash.*?[#$]"
         cmd = "ssh -l %s %s" % (username, server)
-        self = spawn(cmd, timeout=300)
+        spawn.__init__(self, cmd, timeout=login_timeout)
         #, "(?i)no route to host"])
-        i = self.expect(["(?i)are you sure you want to continue connecting", original_prompts, "(?i)password", "(?i)permission denied", "(?i)terminal type", TIMEOUT])
+        i = self.expect(["(?i)are you sure you want to continue connecting", original_prompts, "(?i)password", "(?i)permission denied", "(?i)terminal type", TIMEOUT, "(?i)connection closed by remote host"])
         if i==0: # New certificate -- always accept it. This is what you if SSH does not have the remote host's public key stored in the cache.
             self.sendline("yes")
             i = self.expect(["(?i)are you sure you want to continue connecting", original_prompts, "(?i)password", "(?i)permission denied", "(?i)terminal type", TIMEOUT])
@@ -64,12 +69,13 @@
             self.close()
             return False
         elif i==1: # can occur if you have a public key pair set to authenticate. 
-            ### May NOT be OK if expect false matched a prompt.
+            ### TODO: May NOT be OK if expect() matched a false prompt.
             pass
         elif i==2: # password prompt again
-            # Some ssh servers will ask again for password, others print permission denied right away.
-            # If you get the password prompt again then it means we didn't get the password right
-            # the first time. 
+            # For incorrect passwords, some ssh servers will
+            # ask for the password again, others return 'denied' right away.
+            # If we get the password prompt again then this means
+            # we didn't get the password right the first time. 
             self.close()
             return False
         elif i==3: # permission denied -- password was bad.
@@ -82,30 +88,46 @@
             # This is tricky... presume that we are at the command-line prompt.
             # It may be that the prompt was so weird that we couldn't match it.
             pass
+        elif i==6: # Connection closed by remote host
+            self.close()
+            return False
         else: # Unexpected 
             self.close()
             return False
-        # We appear to have logged in -- reset command line prompt to something more unique.
+        # We appear to be in -- reset prompt to something more unique.
         if not self.set_unique_prompt():
             self.close()
             return False
         return True
 
-    def prompt (self):
-        """This expects the prompt.
+    def logout (self):
+        """This sends exit. If there are stopped jobs then this sends exit twice.
         """
-        i = self.expect(self.PROMPT)
+        self.sendline("exit")
+        index = self.expect([EOF, "(?i)there are stopped jobs"])
+        if index==1:
+            self.sendline("exit")
+            self.expect(EOF)
+
+    def prompt (self, timeout=20):
+        """This expects the prompt. This returns True if the prompt was matched.
+        This returns False if there was a timeout.
+        """
+        i = self.expect([self.PROMPT, TIMEOUT], timeout=timeout)
+        if i==1:
+            return False
+        return True
         
     def set_unique_prompt (self, optional_prompt=None):
         """This attempts to reset the shell prompt to something more unique.
-            This makes it easier to match in the future.
+            This makes it easier to match unambiguously.
         """
         if optional_prompt is not None:
             self.prompt = optional_prompt
-        self.sendline ("PS1='[PEXPECT]\$ '") # In case of sh-style
+        self.sendline (self.PROMPT_SET_SH) # sh-style
         i = self.expect ([TIMEOUT, self.PROMPT], timeout=10)
         if i == 0: # csh-style
-            self.sendline ("set prompt='[PEXPECT]\$ '")
+            self.sendline (self.PROMPT_SET_CSH)
             i = self.expect ([TIMEOUT, self.PROMPT], timeout=10)
             if i == 0:
                 return 0

Modified: packages/pexpect/branches/upstream/current/screen.py
URL: http://svn.debian.org/wsvn/python-modules/packages/pexpect/branches/upstream/current/screen.py?rev=929&op=diff
==============================================================================
--- packages/pexpect/branches/upstream/current/screen.py (original)
+++ packages/pexpect/branches/upstream/current/screen.py Mon Jun 19 10:53:24 2006
@@ -1,6 +1,6 @@
 '''
-$Revision: 1.4 $
-$Date: 2002/08/28 19:07:03 $
+$Revision: 372 $
+$Date: 2006-03-05 18:19:39 -0800 (Sun, 05 Mar 2006) $
 '''
 
 import copy
@@ -26,8 +26,8 @@
 SPACE = chr(32) # Space or blank character.
 
 def constrain (n, min, max):
-    '''This returns n constrained to the min and max bounds.
-    '''
+    """This returns n constrained to the min and max bounds.
+    """
     if n < min:
         return min
     if n > max:
@@ -35,6 +35,14 @@
     return n
 
 class screen:
+    """This maintains the state of a virtual text screen.
+        This maintains a cursor position and handles
+        scrolling as characters are added.
+        This supports most of the methods needed by an
+        ANSI text screen.
+        Row and column indexes are 1-based (not zero-based,
+        like arrays).
+    """
     def __init__ (self, r=24,c=80):
         self.rows = r
         self.cols = c
@@ -47,12 +55,14 @@
         self.w = [ [SPACE] * self.cols for c in range(self.rows)]
 
     def __str__ (self):
-        s = ''
-        for r in range (1, self.rows + 1):
-            for c in range (1, self.cols + 1):
-                s = s + self.get_abs(r,c)
-            s = s + '\n'
-        return s
+        return '\n'.join ([ ''.join(c) for c in self.w ])
+
+    def dump (self):
+        """This returns a copy of the screen as a string.
+            This is similar to __str__ except that lines
+            are not terminated with line feeds.
+        """
+        return ''.join ([ ''.join(c) for c in self.w ])
 
     def fill (self, ch=SPACE):
         self.fill_region (1,1,self.rows,self.cols, ch)
@@ -82,12 +92,18 @@
         if old_r == self.cur_r:
             self.scroll_up ()
             self.erase_line()
+
     def crlf (self):
         '''This advances the cursor with CRLF properties.
         The cursor will line wrap and the screen may scroll.
         '''
         self.cr ()
         self.lf ()
+
+    def newline (self):
+        """This is an alias for crlf().
+        """
+        self.crlf()
 
     def put_abs (self, r, c, ch):
         '''Screen array starts at 1 index.'''
@@ -96,6 +112,8 @@
         ch = str(ch)[0]
         self.w[r-1][c-1] = ch
     def put (self, ch):
+        """This puts a characters at the current cursor position.
+        """
         self.put_abs (self.cur_r, self.cur_c, ch)
 
     def insert_abs (self, r, c, ch):

Modified: packages/pexpect/branches/upstream/current/setup.py
URL: http://svn.debian.org/wsvn/python-modules/packages/pexpect/branches/upstream/current/setup.py?rev=929&op=diff
==============================================================================
--- packages/pexpect/branches/upstream/current/setup.py (original)
+++ packages/pexpect/branches/upstream/current/setup.py Mon Jun 19 10:53:24 2006
@@ -1,16 +1,16 @@
 '''
-$Revision: 1.18 $
-$Date: 2005/11/13 01:31:46 $
+$Revision: 393 $
+$Date: 2006-05-30 18:00:23 -0700 (Tue, 30 May 2006) $
 '''
 from distutils.core import setup
 setup (name='pexpect',
-    version='2.0',
-    py_modules=['pexpect'],
+    version='2.1',
+    py_modules=['pexpect', 'pxssh', 'fdpexpect'],
     description='Pexpect is a pure Python Expect. It allows easy control of other applications.',
     author='Noah Spurrier',
     author_email='noah at noah.org',
     url='http://pexpect.sourceforge.net/',
-    license='Python Software Foundation License',
+    license='MIT license',
     platforms='UNIX',
 )
 

Propchange: packages/pexpect/branches/upstream/current/setup.py
------------------------------------------------------------------------------
--- svn:executable (original)
+++ svn:executable Mon Jun 19 10:53:24 2006
@@ -1,0 +1,1 @@
+*




More information about the Python-modules-commits mailing list