I have a code to be executed in Sikuli, and I want to call an external Python Script to analyze the data from a generated file.
I have tried directly importing the .py file, subprocess.call(), subprocess.Popen() and execfile()
I have two main problems:
I am lost already, after trying all the possibilities I could think of. What should work best? Thank you in advance.
You can pass arguments to a Sikuli script as easy as that:
C:\Sikulix\runScript.cmd -r Tests\Test.sikuli --arg argVal
then you can access it like this:
print sys.argv[1]
where 1
is the order of an argument as they appear in command line.
You can use execfile
like this:
execfile("C:\SikuliX\Tests\Test.py")
the issue with this however is that execfile
runs a Python file by loading it and not as a script. You can only pass in variable bindings, not arguments.
If you want to run a program from within Python, use subprocess.call. Eg
subprocess.call(['./abc.py', arg1, arg2])
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.