calling a python script with os.system

Asked by stephane

I am trying to call a python script from the sikuli IDE (Sikuli 1.1.0 on windows):

import os
os.system("py test.py")

(I know it's kind of stupid to use os.system as sikuli is based on python, but test.py has a sophisticated argument parsing system that would take too much time for me to recode)

in test.py I have a simple

print "3"

If I run py test.py in the command line it works
but if I run the above script from within the IDE I don't get any output

Is the output printed but I don't see it? Or is it that test.py is not ran at all?

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
stephane
Solved:
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1
Revision history for this message
stephane (su1) said :
#2

Ok thanks, got it working with:

from subprocess import Popen, PIPE
pipe = Popen("py -2.7 C:\\test.py", stdout=PIPE)
text = pipe.communicate()[0]
print text