← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #242288]: How to import Sikuli file but not run it immediately?

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
by design, import is not intended to use it to run the contained script code completely.
imported modules usually contain stuff that is used in the main workflow by calling methods/functions and using classes, that are defined/setup in the module.

In Sikuli though it might be tempting, to use it for running scripts,
since you get the image path management on top.

Since any solution for your problem would need to put the script content
into some <if condition: > construct to manage run/do-not-run, you
should make the right step:

--- put the complete content of the script inside your imported module
into a <def mySubScript(): > construct

and the use the module as intended by import:

import module # nothing happens here now
module.mySubScript() # will run your stuff

now you have complete control and even more options like adding
parameters to modify a run of module.

HowTo:

# current content of your module
statement
statement
...
statement

# modified with function
def mySubScript():
    statement
    statement
    ...
    statement

--- below the def statement your complete code is simply intended one
level (see faq 1800)

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