Python API output to screen

57 views
Skip to first unread message

jordi nosaurio

unread,
Aug 1, 2022, 5:52:22 AM8/1/22
to OpenVSP
Hello OpenVSP community,

First thank you very much for this very nice piece of software, it is making our life much easier.

It is a way to stop vspaero to output convergence results to screen using the python API?. It is a nice feature for debugging but sometimes it gives "IOstream flush time out". I guess it is having trouble to synchronize the vspaero text output to the screen. I guess it is also a solution to redirect the output to a file, but I do not know how to do it.

thank you!
jorge

Rob McDonald

unread,
Aug 1, 2022, 11:07:21 AM8/1/22
to OpenVSP
You will need to redirect the output using Python.  There is no way to suppress the output from VSPAERO.

Rob

jordi nosaurio

unread,
Aug 1, 2022, 3:22:14 PM8/1/22
to OpenVSP
May I recompile vspaero with this feature added right?, although Python redirecting seems more straightforward, thank you!

Rob McDonald

unread,
Aug 1, 2022, 4:05:52 PM8/1/22
to ope...@googlegroups.com
You could in theory.  However, VSPAERO has hundreds of print statements.  Some go to file, others to the console.  You would need to redirect all of the ones to console to something else....  This would be a giant pain.

This is the exact reason that operating systems (and scripting languages) have the ability to redirect output.

Rob


--
You received this message because you are subscribed to the Google Groups "OpenVSP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openvsp+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/openvsp/8e4d6092-4f09-4dc1-a60d-97b61bbaff83n%40googlegroups.com.

jordi nosaurio

unread,
Aug 4, 2022, 3:32:20 PM8/4/22
to OpenVSP
Hello, just in case someone is interested


I came up (really, they did) with something that seems to be working:

#import packages
from contextlib import redirect_stdout
from wurlitzer import sys_pipes

#when executing vspaero use the redirection
with open('log.txt', 'a') as f:
    with redirect_stdout(f), sys_pipes():
         resId = vsp.ExecAnalysis('VSPAEROSweep')

The output of vparero will be outputted to log.txt

Cheers
Reply all
Reply to author
Forward
0 new messages