I am writing a program which uses a loop to run several Prism (a graphing program) scripts, exporting PNGs. However, I am having some difficulty with how Prism runs, and I have a couple of suspicions about what might be causing the problem, listed here:
- Prism is not finished doing everything it needs to do before I call it again
- I am using the wrong sort of pipeline to the command line, although I have also tried subprocess.popen() and os.system()
- For whatever reason the command I send to command line is waiting on the program for something
Some strange behaviour that I have encountered is that when I run the program, the Prism startup 'label' shows up on the screen but doesn't go away after a few seconds, indicating to me that Prism has started but is being prevented from running by my code (the particular code I think is causing this is shown below). Additionally, the window I create becomes unresponsive so I have to close the program. However, after I close it, Prism runs the script and I get the exported PNGs from one of the scripts (also indicating that the program might be preventing Prism from running).
A little bit of the code in question is:
os.popen(create_full_prism_path(create_script_name(f)).replace('/', '\\'))
while (not(path.exists(root.output_path + "\\" + f + ".TV.png"))):
pass
Where
create_full_prism_path(create_script_name(f)).replace('/', '\\')
is the command being sent to the command line - I have tested printing and running this command after everything has run, and it works just fine.
while (not(path.exists(root.output_path + "\\" + f + ".TV.png"))):
pass
is the while loop I am using to check that before I go through the loop again, Prism has actually created the PNG I am asking for.
I have tried workarounds to this problem but I can't seem to find a solution, does anyone know how this problem can be solved?