← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #222910]: Running several scripts in sequence can not import the modules in different directories

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
about importing look: http://doc.sikuli.org/globals.html#importing-
other-sikuli-scripts-reuse-code-and-images

The easiest  supported solution, that works without any additional
efforts:

have one folder (e.g. my scripts) with content:
testA.sikuli
testB.sikuli
testC.sikuli
createHtmlReport.sikuli (containing createHtmlReport.py)

take care, that imported modules contain
from sikuli import *
if any Sikuli features are used in that module and before they are used (recommended at the beginning)

currently it is not recommended, to store anything inside a .sikuli
folder (possible loss of data), that is not produced by the IDE.

With your concept of using execfile(), the easiest way to have global variables for all scripts is to use the global Settings class of Sikuli:
Settings.myVar1 = "some value" # to set it
localVar = Settings.myVar1 # to use it

I recommend, to name thes variables my...., to avoid any clashes with
the existing Settings attributes.

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