sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #32574
Re: [Question #267396]: 1.1 errors on attempting exit()
Question #267396 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/267396
Status: Open => Answered
RaiMan proposed the following answer:
what you are doing, is not really the intended use of import.
A script, intended to be imported should consist of at least some
functions, that can be called by the importing script using
retval = module.function()
if the function ends with a
return number
then you will have that in your main script in retval then.
To change your code do the following:
# the sub module (e.g. mySubModule.sikuli)
from sikuli import *
def run():
click("1431123550795.png")
click("Screen Shot 2015-04-28 at 11.50.04 AM.png")
click("1418422585290.png")
click("1418422597111.png")
wait(3)
click("1418422611695.png")
wait(5)
click("1418422621054.png")
return 1
and in the main module you have
import mySubModule
# … some code
retval = mySubModule.run()
This is the way how one should use the import.
Be aware: the code you currently have in your sub script is only
executed once in a Sikuli session at time of import (indent-
level-0-code)
With the "real" import solution, at time of import only the function is accepted as defined and nothing else happens.
the code in the function run is executed each time you use
mySubModule.run()
But if you want to stay with your solution of indent-level-0-code, then you have another option now (use the latest build please):
http://sikulix-2014.readthedocs.org/en/latest/scripting.html#running-scripts-and-snippets-from-within-other-scripts-and-run-scripts-one-after-the-other
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.