How to pass in parameters to sikuli script?

Asked by Eileen Wei

Hi,

I would like to know if there is a way to pass in parameters for a sikuli script? Here is my script:

===========
import getopt
import sys

opts, args = getopt.getopt(sys.argv[1:], "a:")

print 'opts is:', opts
==========

If I save it as a checkParm.py, and do the following from command line, this is what I got:

>python checkParm.py -a myapplication
opts is: [('-a', 'myapplication')]

But if I put this script into Sikuli IDE and save executable as checkParm.skl, and run it from command line, it seems the Sikuli script cannot get the pass in parameter, see the following:

>Sikuli-IDE.bat checkParm.skl -a myapplication
VDictProxy loaded.
ScreenMatchProxy loaded.
Win32Util loaded.
opts is: []

So is there a way to pass in parameter to sikuli script?

Note that I didn't use the optparse module since Jython doesn't support it yet.

Thanks,
Eileen

Question information

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

Until now, it seems, that they did not implement any handling of command line parameters. At least they are not available in a way you would expect when looking at a Sikuli script as being something that looks and feels like a python script.

If it is really a missing feature for you, you should report it as a bug.

Since I'm a Mac, I tend to implement missing functionality with applescripts, that I'm calling from inside a Sikuli script.

I have an applescript as a wrapper, that makes a file from the parameters, so that in the Sikuli script I can read this file and say myParms = eval("[" + File(tempfile).readline() + "]")
The 1st line of the file e.g.:
"some text", 1, "more text", 5.6

I'm sure it would be possible (and even easier than with applescript) to make such a wrapper with python.

Revision history for this message
RaiMan (raimund-hocke) said :
#2

will be supported in upcoming version 0.10

Revision history for this message
Eileen Wei (eileenwei) said :
#3

This is great! I think wrapper will work but it will be nice to have a more straight forward way to do it since this will be very useful in automation task.

Thank you!
Eileen