← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #207060]: How to pass command line argument to imported file

 

Question #207060 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/207060

    Status: Open => Answered

RaiMan proposed the following answer:
I understand:
To run the EN language case for example, you manually edit the statement
import EN_Images

which is in commons.sikuli and then run your stuff.

If you want to run the test for another language, you again edit the
statement accordingly and run the test.

If this is correct, so what can you do?

--1. auto-edit commons.sikuli
make a whatever script, that reads commons.sikuli/commons.py, changes the statement accordingly based on a command line parameter and saves the changed .py again (you can do this using a Sikuli script).
Make this the first step in your batch sequence before the main stuff is run.

--2. using a global variable
In your main module read a command line parameter that defines the language to use (e.g. DE) and store it this way as a global variable:
Settings.myLang = sys.argv[1]

this will save the given language string ("DE" in this case) in Sikuli's
global Settings class.

In commons.sikuli change the import statement this way:
exec("import " + Settings.myLang + "_images")

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.