Revision history [back]
You can see which application started Python by looking at sys.executable, which returns the executable that was used to start the Python session.
import os
import sys
def main():
# Determine if this script is being run from PSSE or plain Python.
full_path_executable = sys.executable
# Remove the folder path and keep only the executable file (in lower case).
executable = os.path.basename(full_path_executable).lower()
run_in_psse = True
if executable in ['python.exe', 'pythonw.exe']:
# If the executable was one of the above, it is a Python session.
run_in_psse = False
if not run_in_psse:
psspy.stop_2()
else:
# do something else to finish up.
You can see which application started Python by looking at sys.executable, which returns the executable that was used to start the Python session.
import os
import sys
def main():
# Determine if this script is being run from PSSE or plain Python.
full_path_executable = sys.executable
# Remove the folder path and keep only the executable file (in lower case).
executable = os.path.basename(full_path_executablefull_path_exec).lower()
run_in_psse = True
if executable in ['python.exe', 'pythonw.exe']:
# If the executable was one of the above, it is a Python session.
run_in_psse = False
if not run_in_psse:
psspy.stop_2()
else:
# do something else to finish up.