What am I doing wrong?

Asked by Mark McGuinn on 2019-12-06

Hi,

I am writing a script to gather some info from a auction site. I ran into a problem and tried to use the debug features of Sikuli. However the simple script below hangs when it tries to print out a string and variable. Is there something I am missing or is this a bug:

rom sikuli import *
from ast import literal_eval
import unittest
Settings.OcrReadText = True
Settings.OcrLanguage="ENG"
import java.lang.System
import java.util.Arrays
import java.lang.Object
import java.awt.event.InputEvent
import java.io.FilterInputStream
from java import *
import unittest
import re
import org.sikuli.basics.Debug
import org.sikuli.script.ImagePath;
import org.sikuli.script.Match;
import org.sikuli.script.Screen;
#public class Arrays
 # java.lang.Object
# import java.io.Object
Settings.OcrTextSearch=True
Settings.OcrTextRead=True
Settings.UserLogs = True
Settings.UserLogPrefix = "user"
Settings.UserLogTime = True
Debug.setUserLogFile("C:\\Users\\mmcguinn\\Documents\\sikuli_log.txt")
Debug.on(3)
strippedString = [12345]
def takeSecond(val):
    return val[1]
def runkey(event):
    global running
    running = False
stored_info = []
sorted_stored_info= []
Env.addHotkey(Key.F1,KeyModifier.CTRL,runkey)
import java.util
import java.lang.System
import java.lang.Object
import java.awt.event.InputEvent
carmake = "FORD"
counter = 0

def end_loop(val):
    return val[1]

wait( "1575294322743.png")

# check if there are any auctions
#

auctions_reg = ("1575542482620.png")

if exists (auctions_reg):
    print("No Auctions")
    Debug.user("No Auctions")
    Auctions = False
else:
     print("Auctions ")
     Debug.user("Auctions ")
     lowestbid = 0
     lowestask = 0
     auction_count = 0
     Auctions = True
     Continue = True
     test_str = "true"

arrow_region = (Region(410,792,147,33))

#
# Here need to deal with th case where there is no downlit arrow
# This means there could be 1 - 4 auctions
#
if Auctions is True and arrow_region.exists(Pattern("downarrowlit.png").similar(0.91)) :
    Debug.user("Auctions True and downlit arrow exists")

elif Auctions is True:
       popup ("Auction true and count is-->")
       Debug.user("Auctions True but no downlit arrow-->", test_str,"<---")

else:
    Debug.user("Fell through to Pass")
    print"Passing "
    pass

The log file contains:

6/12/19 17:37:48)] Auctions
[user (06/12/19 17:37:53)] Auctions True but no downlit arrow-->

and the debug output in the ide is:

debug] HotkeyManager: add Hotkey: CTRL F1 (112, 2)
[debug] Image: reused: 1575294322743.png (file:C:\Users\mmcguinn\Documents\testdebug.sikuli\1575294322743.png)
[debug] Region: wait: waiting 3.0 secs for 1575294322743.png to appear in R[0,0 1680x1050]@S(0)
[debug] Finder2: makeMat: INT_RGB (1680x1050)
[debug] Finder2: makeMat: 3BYTE_BGR (111x38)
[debug] Finder2: doFind: start (stdDev: 118.1697 mean: 648.124467)
[debug] Finder2: doFind: in original: %99.9999 (?70) 185 msec
[debug] Finder2: doFind: end 185 msec
[debug] Region: wait: 1575294322743.png appeared (M[212,219 111x38]@S(0) S:1.00 C:267,238 [242 msec])
[debug] Image: reused: 1575542482620.png (file:C:\Users\mmcguinn\Documents\testdebug.sikuli\1575542482620.png)
[debug] Region: exists: waiting 3.0 secs for 1575542482620.png to appear in R[0,0 1680x1050]@S(0)
[debug] Finder2: makeMat: INT_RGB (1680x1050)
[debug] Finder2: makeMat: 3BYTE_BGR (315x48)
[debug] Finder2: doFind: start (stdDev: 154.3045 mean: 461.725132)
[debug] Finder2: doFind: in original: %47.1262 (?70) 157 msec
[debug] Finder2: doFind: end 157 msec
[debug] Finder2: makeMat: INT_RGB (1680x1050)
[debug] Finder2: doFind: start (stdDev: 154.3045 mean: 461.725132)
[debug] Finder2: doFind: in original: %47.2291 (?70) 144 msec
[debug] Finder2: doFind: end 144 msec
[debug] Finder2: makeMat: INT_RGB (1680x1050)
[debug] Finder2: doFind: start (stdDev: 154.3045 mean: 461.725132)
[debug] Finder2: doFind: in original: %47.3131 (?70) 146 msec
[debug] Finder2: doFind: end 146 msec
[debug] Finder2: makeMat: INT_RGB (1680x1050)
[debug] Finder2: doFind: start (stdDev: 154.3045 mean: 461.725132)
[debug] Finder2: doFind: in original: %47.4196 (?70) 188 msec
[debug] Finder2: doFind: end 188 msec
[debug] Finder2: makeMat: INT_RGB (1680x1050)
[debug] Finder2: doFind: start (stdDev: 154.3045 mean: 461.725132)
[debug] Finder2: doFind: in original: %47.4097 (?70) 148 msec
[debug] Finder2: doFind: end 149 msec
[debug] Finder2: makeMat: INT_RGB (1680x1050)
[debug] Finder2: doFind: start (stdDev: 154.3045 mean: 461.725132)
[debug] Finder2: doFind: in original: %47.4929 (?70) 143 msec
[debug] Finder2: doFind: end 143 msec
[debug] Finder2: makeMat: INT_RGB (1680x1050)
[debug] Finder2: doFind: start (stdDev: 154.3045 mean: 461.725132)
[debug] Finder2: doFind: in original: %47.8846 (?70) 154 msec
[debug] Finder2: doFind: end 154 msec
[debug] Finder2: makeMat: INT_RGB (1680x1050)
[debug] Finder2: doFind: start (stdDev: 154.3045 mean: 461.725132)
[debug] Finder2: doFind: in original: %48.5306 (?70) 148 msec
[debug] Finder2: doFind: end 149 msec
[debug] Finder2: makeMat: INT_RGB (1680x1050)
[debug] Finder2: doFind: start (stdDev: 154.3045 mean: 461.725132)
[debug] Finder2: doFind: in original: %48.8510 (?70) 138 msec
[debug] Finder2: doFind: end 138 msec
[debug] Region: exists: 1575542482620.png did not appear [3000 msec]
[debug] Image: reused: downarrowlit.png (file:C:\Users\mmcguinn\Documents\testdebug.sikuli\downarrowlit.png)
[debug] Region: exists: waiting 3.0 secs for downarrowlit.png to appear in R[410,792 147x33]@S(0)
[debug] Finder2: makeMat: INT_RGB (147x33)
[debug] Finder2: makeMat: 3BYTE_BGR (126x31)
[debug] Finder2: doFind: start (stdDev: 49.5352 mean: 750.304659)
[debug] Finder2: doFind: in original: %13.8226 (?91) 1 msec
[debug] Finder2: doFind: end 1 msec
Auctions
[debug] Finder2: makeMat: INT_RGB (147x33)
[debug] Finder2: doFind: start (stdDev: 49.5352 mean: 750.304659)
[debug] Finder2: doFind: in original: %13.6380 (?91) 0 msec
[debug] Finder2: doFind: end 0 msec
[debug] Finder2: makeMat: INT_RGB (147x33)
[debug] Finder2: doFind: start (stdDev: 49.5352 mean: 750.304659)
[debug] Finder2: doFind: in original: %13.7379 (?91) 0 msec
[debug] Finder2: doFind: end 0 msec
[debug] Finder2: makeMat: INT_RGB (147x33)
[debug] Finder2: doFind: start (stdDev: 49.5352 mean: 750.304659)
[debug] Finder2: doFind: in original: %13.6136 (?91) 0 msec
[debug] Finder2: doFind: end 0 msec
[debug] Finder2: makeMat: INT_RGB (147x33)
[debug] Finder2: doFind: start (stdDev: 49.5352 mean: 750.304659)
[debug] Finder2: doFind: in original: %13.6178 (?91) 0 msec
[debug] Finder2: doFind: end 0 msec
[debug] Finder2: makeMat: INT_RGB (147x33)
[debug] Finder2: doFind: start (stdDev: 49.5352 mean: 750.304659)
[debug] Finder2: doFind: in original: %13.5910 (?91) 0 msec
[debug] Finder2: doFind: end 0 msec
[debug] Finder2: makeMat: INT_RGB (147x33)
[debug] Finder2: doFind: start (stdDev: 49.5352 mean: 750.304659)
[debug] Finder2: doFind: in original: %13.7758 (?91) 1 msec
[debug] Finder2: doFind: end 1 msec
[debug] Finder2: makeMat: INT_RGB (147x33)
[debug] Finder2: doFind: start (stdDev: 49.5352 mean: 750.304659)
[debug] Finder2: doFind: in original: %13.8368 (?91) 0 msec
[debug] Finder2: doFind: end 0 msec
[debug] Finder2: makeMat: INT_RGB (147x33)
[debug] Finder2: doFind: start (stdDev: 49.5352 mean: 750.304659)
[debug] Finder2: doFind: in original: %13.4695 (?91) 1 msec
[debug] Finder2: doFind: end 1 msec
[debug] Region: exists: downarrowlit.png did not appear [3002 msec]

Question information

Language:
English Edit question
Status:
Solved
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
2019-12-10
Last query:
2019-12-10
Last reply:
2019-12-10
RaiMan (raimund-hocke) said : #1

Apparently at this point
if Auctions is True and arrow_region.exists(Pattern("downarrowlit.png").similar(0.91)) :

the downarrowlit.png did not appear within 3 seconds:
Region: exists: downarrowlit.png did not appear [3002 msec]

Mark McGuinn (mmcguinn) said : #2

Because the down arrow does not appear the system starts to print out the string:

Auctions True but no downlit arrow-->

It should add in test_string a variable which contains "true", however the system hangs and the only way to get it back is to kill the process.

Best RaiMan (raimund-hocke) said : #3

ok, finally understood ;-)

 Debug.user("Auctions True but no downlit arrow-->", test_str,"<---")

is not possible this way

the parameter must be a string:

 Debug.user("Auctions True but no downlit arrow-->" + test_str + "<---")

or a Java format string and a list of parameters:
 Debug.user("Auctions True but no downlit arrow-->%s<---", test_str)

BTW: you should not use popup(), because this might interfere with your GUI. Either use print or Debug.user().

To make print more helpful, you should run your script in a commandline, so you can see the printout live.
In the IDE in parallel edit/save your script.

Mark McGuinn (mmcguinn) said : #4

Thanks for the response, the changes you suggested solve the issue, cheers