Receiving error when run code through function

Asked by David on 2018-10-09

I have a lib file with 2 functions. When I run them outside of a function, they work fine. But as a function one is constantly failing while the other works fine.

Here is my code
#contents of flexlib
from sikuli import *

Settings.MoveMouseDelay = 0
Settings.DelayBeforeMouseDown = 0
Settings.DelayBeforeMouseUp = 0

def Decline():

def Accept():

#Contents of wholefoods
import flexLib

Settings.MoveMouseDelay = 0
Settings.DelayBeforeMouseDown = 0
Settings.DelayBeforeMouseUp = 0
Phone = find(Pattern("1532767070365.png").similar(0.69))

while True:
    if Phone.exists(Pattern("1532873575385.png").similar(0.95)):
    elif Phone.exists(Pattern("1536865272142.png").similar(0.95)):
    elif Phone.exists("1539112486644.png"):

    elif Phone.exists("1532724477876.png"):


The code inside flexLib.Accept() runs fine if I run it stand alone outside of a function. But inside the function when called, is giving me this error:

[log] CLICK on L(1104,453)@S(0)[0,0 1920x1080]

[error] Image: could not be loaded: file:///DAVID-PC/Users/David/Documents/Sikuli/scripts/Wholefoods.sikuli/1532724815166.png
[error] Image: Image not valid, but TextSearch is switched off!
[error] script [ Wholefoods ] stopped with error in line 24
[error] FindFailed ( Region: doFind: Image not loadable: 1532724815166.png )
[error] --- Traceback --- error source first line: module ( function ) statement 13: flexLib ( Accept ) click("1539113672446.png")
[error] --- Traceback --- end --------------

I have tried deleting the scripts and rebuilding with new screen captures thinking the images got corrupted. Didn't change anything.

Question information

English Edit question
Sikuli Edit question
No assignee Edit question
Last query:
Last reply:
RaiMan (raimund-hocke) said : #1

the error messages do not fit to the pasted code:
--- click("1539113672446.png") is not in Accept
--- 1532724815166.png is not in the main script

David (davper) said : #2

I know, That is part of my problem. The error that keeps coming up doesn't appear to relate to my script but it references the correct script.

Can you help with this problem?

Provide an answer of your own, or ask David for more information if necessary.

To post a message you must log in.