Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to detect if Python or PSSE is running the show.

I have a script that is normally launched from the shell with PSSE on top like so:

psse32 -buses 150000 -pyfile "MyScript.py" -embed

I am converting the script to run with Python on top as part of a larger python program. Does anyone know how to detect if I am running as an embedded session in PSSE or standalone?

I found have an indirect route by explicitly setting the mode:

def main(embedded=True):
    ...
    if embedded:
        psspy.stop_2()
    else:
        # do something else to finish up.

if __name__ == '__main__':
    # PSSE embedded scripts enter here 
    main()

And invoke the script using:

import MyScript
MyScript.main(embedded=False)