How do I run AVL (a binary) from a python script using the subprocess module? -


i'm trying script series of runs in avl (athena vortex lattice), vortex lattice code designing wings , other lifting surfaces.

i have binary stored in ~/bin/. typically run avl within terminal, , enter commands. typical commands be:

  1. load ~/path/avlexamplefile.avl
  2. oper
  3. a 5
  4. x
  5. fs
  6. return
  7. quit

which, loads .avl input file, enter operations menu, sets angle of attack 5 degrees, executes computation, prints out forces output file, exits operations menu, , quits program.

i'm trying run avl python script using subprocess module using following code:

    import subprocess sp     avl = sp.popen(['~/bin/avl3.35'],            stdin=sp.pipe,stdout=none,             stderr=none,             universal_newlines=true)      avl.communicate('load ~/file/avlexamplefile.avl') 

this works. avl loads, first command executed, following error, , won't take further commands.

    avl   c>  forrtl: severe (24): end-of-file during read, unit -4, file        stdin     image              pc                routine            line        source                  avl3.35            000000010a00f43b  unknown               unknown  unknown     avl3.35            000000010a00dbfe  unknown               unknown  unknown     avl3.35            0000000109fd5177  unknown               unknown  unknown     avl3.35            0000000109f8b426  unknown               unknown  unknown     avl3.35            0000000109f8aa39  unknown               unknown  unknown     avl3.35            0000000109fb61f3  unknown               unknown  unknown     avl3.35            0000000109eeecf3  unknown               unknown  unknown     avl3.35            0000000109e7130f  unknown               unknown  unknown     avl3.35            0000000109e6fc7c  unknown               unknown  unknown     libdyld.dylib      00007fff8b1d95ad  unknown               unknown  unknown 

can point out i'm doing wrong? eventually, i'd place above inside loop running through multiple variations.

try using avl.stdin.write("your cmd here" +'\n').

working example using xfoil here (not mine):

https://github.com/launchpad-mcq/aileron-design/blob/master/design-aileron.py


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -