1

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:

  • Firstly, I need to pass some arguments to the python script (specifically the path of the file to analyze [str] and the test number [int]).
  • Secondly, my .py script uses libraries such as matplotlib.pyplot or numpy that cannot be executed by Jython.

I am lost already, after trying all the possibilities I could think of. What should work best? Thank you in advance.

Slash
  • 285
  • 2
  • 13

1 Answers1

0

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. E.g.

subprocess.call(['./abc.py', arg1, arg2])
Community
  • 1
  • 1
Eugene S
  • 6,709
  • 8
  • 57
  • 91