wexpect icon indicating copy to clipboard operation
wexpect copied to clipboard

logfile parameter not working in version 4.0.0

Open Rexoen opened this issue 2 years ago • 1 comments

Describe the bug It seems that logfile parameter in wexpect.host.SpawnPipe does not work

To Reproduce

import wexpect
f = open("test.txt","w")
child = wexpect.spawn("cmd.exe",encoding="UTF-8",logfile=f)
child.expect(">")
child.send("dir")
child.sendeof()
f.close()

Expected behavior command output should be written to logfile open the file after running script only to get a blank logfile

Environment:

  • Windows 10
  • Python 3.10
  • wexpect 4.0.0

Rexoen avatar Aug 22 '22 16:08 Rexoen

Reproduced. I went though a few of the spawn classes and the logfile argument is actually not used. I am unsure what this argument should be. I think allowing passing on a object would not be easy.

Would it be acceptable to just pass on the name of the file? Then it can just update os.environ['WEXPECT_LOGGER_FILENAME'] and respawn the logger and then it should be good.

@raczben Do you have an opinion on this?

Stefanhg avatar Oct 01 '23 21:10 Stefanhg