sikuli_cpython
sikuli_cpython copied to clipboard
wait function not working
The wait function does not define the duration variable:
def wait(target_string, *args, **kwargs):
if not duration and duration != 0:
duration = 5000
target = Pattern(target_string).getTarget()
screen = DesktopScreenRegion()
return screen.wait(target, duration)
Also, the Pattern().getTarget() crashes causing a jvm error.
The problem is how ImageTarget gets constructed. So, to save it from crashing you need to pass it a URL (not relative image path like you do in sikuli IDE).
For instance, this works on my machine:
import sikuli as si
si.wait('file:///C:\\targetImage.png', 10)
this doesn't solve for me:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Traceback (most recent call last):
File "sikuli_nounittest.py", line 16, in <module>
main()
File "sikuli_nounittest.py", line 6, in main
wait("file:///bla/bla/blabla/blabla/blablabla.png", 60)
File "/usr/lib/python2.7/sikuli/sikuli.py", line 41, in wait
if not duration and duration != 0:
UnboundLocalError: local variable 'duration' referenced before assignment
submitted a patch for the wait function together with @mnovait
actually noticed that some bugfix and improvements have been committed in a fork from @flycodepl https://github.com/flycodepl/sikuli_cpython. I already asked via mail if he could submit a pullrequest