← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #190179]: Using Variables via Settings, refresh?

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
--- Sometimes causing the first file to repeat it's execution.
Sorry, I did not think about the fact, that the first time the main script is run, every subscript is run 2 times (first for the import, that is only done once as long as IDE stays open and second with the reload (which in turn is the only processing on rerun))

- this trick helps: 
# at the beginning of the main script only once:
try: Settings.isRerun; Settings.isRerun = True
except: Settings.isRerun = False

# every  import / reload
import sub
if Settings.isRerun: reload(sub)

on the first run, isRerun will be undefined, so it gets assigned False
and only the import will run. The second time and later, isRerun will be
True, so the reload will be processed. So in both cases, your sub script
will only be run once.

But be aware: after adding a new import/reload, you have to restart the
IDE !!

---  It was constantly spitting out the initial time and date.
I cannot reproduce this behavior.

Using this in the IDE:
Settings.myClientName = "Sikuli " + time.strftime("%Y/%m/%d - %H:%M.%S")
print Settings.myClientName

prints the actual time on every rerun.

And this is the preferred solution (you should not need to put it in an
extra script).

So you have to check your code and observation.

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