python - pexpect: How to interact() over file object using newer version of pexpect library -


pexpect has gone through big changes since version provided ubuntu 15.04 (3.2). when installing newest version of pexpect using pip3, minimal program gave terminal emulation on serial console not work more:

#!/usr/bin/python3  import serial import pexpect.fdpexpect  ser = serial.serial("/dev/ttys0", baudrate=115200) spawn = pexpect.fdpexpect.fdspawn(ser) spawn.interact() 

the newer api missing interact() method in class pexpect.fdpexpect.fdspawn used there.

question: how newer version of pexpect (currently 4.2.1) supposed used provide free manual interaction file object (serial port in case)?

alternatively, question/work-around: recognize using bit heavy machinery such simple use case, suggestions other python libraries can same earlier version of pexpect could?


code reading: examples use pexpect.spawn(command_str) spawn object has interact() method; pexpect.spawn() same directly creating pexpect.pty_spawn.spawn object has method. on other hand, pexpect.fdpexpect.fdspawn() construct pexpect.fdpexpect.fdspawn class missing interact() method. both of these spawn classes derive pexpect.spawnbase.spawnbase class. based on quick reading, looks regression resulted refactoring on way version 4.x.

browsing pexpect issues, found #351, #356, , newly submitted #377. quick reading, seems regression brought uncompleted refactoring along way towards new major release version 4. there 3 possible avenues:

  1. make sure install older version:

    $ pip3 install "pexpect<3"

    (or make sure version installed other system 3.x).

  2. fix pexpect yourself.

  3. use other python library.

these avenues more or less hinted github user @takluyver, apparently maintainer of pexpect in comment issue #351:

@jquast thoughts on (and #356)? feel bad we've broken things people doing fdspawn, don't want make inherit pty spawn class, , works on windows, think it's important preserve too.

maybe should say:

  • if have legacy code broke pexpect 4, downgrade pexpect 3.x (pip install pexpect<4)
  • if you're writing new code, use streamexpect instead of pexpect.

Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -