0

Folks, I would like to know if there is an issue w/ wexpect. Is this module working as expected?

things seem to work as expected in pexpect on linux

import wexpect
child = wexpect.spawn('cmd')
child.expect('>')  #instantaneous response
child.sendline('python3')
child.expect('>')  #this stays stuck here for 15 seconds before returning with success (pexpect is instantaneous)
child.sendline('import os')
child.expect('>') #instantaneous response
child.sendline('os.curdir')
child.expect('>') #instantaneous response
child.sendline()
child.expect('>') #raises TIMEOUT
child.before() 
# Traceback (most recent call last):
#File "<stdin>", line 1, in <module>
#TypeError: 'str' object is not callable
#contrast this to pexpect: b">>> os.curdir\r\n'.'\r\n>>> os.curdir\r\n'.'\r\n>>> "
Sblu
  • 43
  • 8

1 Answers1

0

I found that I could just use pexpect directly: pexpect windows support starting version 4.0

import pexpect
from pexpect.popen_spawn import PopenSpawn
child = pexpect.popen_spawn.PopenSpawn('cmd')
child.sendline('py -3 -i')
child.expect('>{2,}')
child.before #gives the string before the match
child.after #gives the match string
Sblu
  • 43
  • 8