pexpect PopenSpawn не выполняет команды и ничего не выводит - PullRequest
0 голосов
/ 20 февраля 2019

Я пытаюсь запустить файл .exe, используя pexpect.popen_spawn.PopenSpawn.Но функция работает до ВРЕМЕНИ.Даже после этого он не принимает и не выводит ничего.

Вот код и вывод

КОД:

from pexpect import EOF, TIMEOUT
from pexpect.popen_spawn import PopenSpawn

child = PopenSpawn("xfoil.exe")
child.logfile = open("child.log", "wb")

def cmdin(expect, cmd, timelimit):
    outputs = [expect, TIMEOUT, EOF]
    result = child.expect(outputs, timeout=timelimit) 
    child.sendline(cmd)
    print(f"expect inputted: {expect}\n" + 
          f"expect outputted is: {outputs[result]}\n" + 
          f"sendline: {cmd}\n" + 
          f"stdout: {child.before.decode()}\n")

timelimit = 10
cmdin(b"\s*XFOIL\s*c>\s*", "naca0012", timelimit)

Вывод

expect inputted: b'\\s*XFOIL\\s*c>\\s*'
expect outputted is: <class 'pexpect.exceptions.TIMEOUT'>
sendline: naca0012
stdout: 

Ожидаемый результат -

 expect inputted: b'\\s*XFOIL\\s*c>\\s*'
 expect outputted is: b'\\s*XFOIL\\s*c>\\s*'
 sendline: naca0012
 stdout:      XFOIL   c>  naca0012
 Max thickness =     0.120035  at x =   0.300
 Max camber    =     0.000000  at x =   0.013

 Buffer airfoil set using 331 points

 Blunt trailing edge.  Gap =  0.00252

 Paneling parameters used...
   Number of panel nodes       160
   Panel bunching parameter    1.000
   TE/LE panel density ratio   0.150
   Refined-area/LE panel density ratio    0.200
   Top    side refined area x/c limits  1.000 1.000
   Bottom side refined area x/c limits  1.000 1.000

Может кто-нибудь сказать мне, как решить эту проблему.

Большое спасибо.

...