[Python-Dev] Re: sf.net/708007: expectlib.py telnetlib.py split

Luke Kenneth Casson Leighton lkcl@samba-tng.org
Thu, 15 May 2003 08:59:27 +0000


raymond, regarding expect.py which you give a link to:

- expect.py is extremely basic, offering pretty much only read and
  write.

  what it _actually_ offers is an advantage over the python
  distribution's popen2/3 because it catches ptys (stdin)
  even on ssh and passwd.

- expectlib.py [new] _is_ telnetlib.py [old] - with over-rideable
  read, write, open and close methods.

- pexpect is like... an independently developed version of the above,
  with all of the above functionality And Then Some - including
  an ANSI screen emulator should an application developer choose to
  use it.

what i figure is a sensible roadmap to suggest / propose to people:

- telnetlib.py [old] gets split into telnetlib.py [patched] plus
  expectlib.py [patched].

- noah investigates expectlib.py and a) works some magic on it
  b) uses it in pexpect.

- someone independently investigates expect.py's popen2 c-code
  capability to see if it can be merged into the python distribution.


i do not know if it is a "bug" that python's popen functions cannot
capture ssh / passwd but it would certainly appear to be sensible
to have an option to allow ALL user input to be captured.

certainly i found it a total pain two years ago to have to patch
ssh to allow a user password to be accepted on the command-line!

[i didn't know about expect.py then]


last time i spoke to guido about the telnetlib.py/expectlib.py patch,
he a) wasn't so madly busy as he is now, b) rejected the then-patch
because it wasn't clean c) acknowledged that telnetlib.py is a mess
and needed a complete rewrite.

since that time, i notice that telnetlib.py has had a control-char
handling function, which alleviates some of the need for a complete
rewrite.

l.

On Tue, May 13, 2003 at 10:57:40PM +0000, Luke Kenneth Casson Leighton wrote:

> [i am not on the python-dev list but i check the archives, please cc me]
> 
> approximately two years ago i needed the functionality outlined
> in the present telnetlib.py for several other remote protocols,
> most notably commands (including ssh and bash) and also HTTP.
> 
> i figure that this functionality should be more than invaluable
> to other python developers.