IDE: How to solve/track strange problems
Hi, I have an application which is designed to automate taking part in auctions. One of the functions in the app is to monitor the time left on the auction. It does this by defining a region where the timer appears and then grabs the text from there before doing some processing on the text to convert it into a number.
# Debug.user(
# time_left_j = time_left_i.split()
The problem is that the time_reg.text() call is finding text which does not exists when I call it from my procedure. If I extract the code to a function on its own and then call that from a simple piece of code it finds the correct information. If I call the procedure from my main procedure it doesn't. The names used in this piece of code are unique and only used in these few lines. The phantom text that is found is pretty consistent in that it relates to the item being auctioned (cars), for example:
('Time left i = ', ['|', 'ASTI'])
But this string appears nowhere on the screen never mind in the region defined by time_reg. My question therefore is: is this a bug in Sikuli ?
Question information
- Language:
- English Edit question
- Status:
- Expired
- For:
- SikuliX Edit question
- Assignee:
- No assignee Edit question
- Last query:
- Last reply:
Revision history for this message
|
#1 |
This is the extracted routine:
def get_time():
time_reg = (Region(
Debug.user("In Timer calculator...")
time_left_s = time_reg.text()
Debug.
time_left_i = time_left_s.split(" ")
return(
and this is what calls it when it works:
time_left_i = get_time()
print ("Time left i = ",time_left_i)
Revision history for this message
|
#2 |
--- The names used in this piece of code are unique and only used in these few lines
not really true: time_left_i
Surely not a SikuliX problem, but a coding flaw.
Make a new def: (I prefer camelCase over camel_case)
def getTimeLeft(reg):
return reg.text().split(" ")
and use this one:
time_left_i = getTimeLeft(
print ("Time left i = ",time_left_i)
or completely get rid of the def:
time_left_i = Region(
print ("Time left i = ",time_left_i)
if either of those works, you have to go back and check your coding.
Revision history for this message
|
#3 |
Hi RaiMan,
many thanks for the response,i t has helped me to move things forward. However there is still a problem which is difficult for me as a newbie to sikuli and python to understand. Using the function you provided I get back as string containing the time left, which is fine. The problem arises when I try to convert the string to an int, I get the situation where the string being returned doesn't contain a string with a number instead it returns a string which is linked to the auction but does not appear on the screen. Below is the code:
time_left_i = get_time_
print("Time Left i...",time_left_i)
if time_left_i[0] == "PLETE":
break
elif time_left_i[0] == "SOON":
else:
# wait_time_2 = int(wait_time_1)
result = isinstance(
# wait_time = wait_time_1 - 5
#
This invalid string causes an exception in the ide. It therefore appears that the int() function is interfering with the reg.text call. Is this possible?
Error caused by int()
[error] script [ auction_control ] stopped with error in line 95
[error] ValueError ( invalid literal for int() with base 10: '' )
[error] --- Traceback --- error source first
line: module ( function ) statement
95: main ( <module> ) wait_time_2 = int(wait_time_1)
[error] --- Traceback --- end --------------
Thanks
Mark
The Future Is Certain Give Us Time To Work It Out
_______
From: <email address hidden> <email address hidden> on behalf of RaiMan <email address hidden>
Sent: Sunday 22 December 2019 13:38
To: <email address hidden> <email address hidden>
Subject: Re: [Question #687415]: Strange problem or a bug in Sikuli
Your question #687415 on Sikuli changed:
https:/
Status: Open => Answered
RaiMan proposed the following answer:
--- The names used in this piece of code are unique and only used in
these few lines
not really true: time_left_i
Surely not a SikuliX problem, but a coding flaw.
Make a new def: (I prefer camelCase over camel_case)
def getTimeLeft(reg):
return reg.text().split(" ")
and use this one:
time_left_i = getTimeLeft(
print ("Time left i = ",time_left_i)
or completely get rid of the def:
time_left_i = Region(
print ("Time left i = ",time_left_i)
if either of those works, you have to go back and check your coding.
--
If this answers your question, please go to the following page to let us
know that it is solved:
https:/
If you still need help, you can reply to this email or go to the
following page to enter your feedback:
https:/
You received this question notification because you asked the question.
Revision history for this message
|
#4 |
"ValueError ( invalid literal for int() with base 10: '' )"
This indicates that the value that you wanted to convert was the empty string which cannot be converted into a number.
My guess:
The screen shows something unexpected - not "PLETE", not "SOON", but also not a number, or the OCR program could not correctly interpret the text on the screen
Possible workaround:
In addition the the if-s for "PLETE" and "SOON" add also a branch for the case that time_left_i[0] is the empty string after the re.sub action.
maybe something like
…
elif time_left_i[0] == "":
break
…
Revision history for this message
|
#5 |
Manfred,
thanks for the suggestion, unfortunately it is causing an exception when I try to implement it:
[error] script [ auction_control ] stopped with error at line --unknown--
[error] Error caused by: java.lang.
I had a look for the error and there is a suggestion that this is a problem in jython. I am also still wondering why the correct code is returned when the int() function is not used, but when it is there a problem shows up even when the screen is exactly the same.
regards
Mark
The Future Is Certain Give Us Time To Work It Out
_______
From: <email address hidden> <email address hidden> on behalf of Manfred Hampl <email address hidden>
Sent: Sunday 22 December 2019 18:04
To: <email address hidden> <email address hidden>
Subject: Re: [Question #687415]: Strange problem or a bug in Sikuli
Your question #687415 on Sikuli changed:
https:/
Status: Open => Answered
Manfred Hampl proposed the following answer:
"ValueError ( invalid literal for int() with base 10: '' )"
This indicates that the value that you wanted to convert was the empty
string which cannot be converted into a number.
My guess:
The screen shows something unexpected - not "PLETE", not "SOON", but also not a number, or the OCR program could not correctly interpret the text on the screen
Possible workaround:
In addition the the if-s for "PLETE" and "SOON" add also a branch for the case that time_left_i[0] is the empty string after the re.sub action.
maybe something like
…
elif time_left_i[0] == "":
break
…
--
If this answers your question, please go to the following page to let us
know that it is solved:
https:/
If you still need help, you can reply to this email or go to the
following page to enter your feedback:
https:/
You received this question notification because you asked the question.
Revision history for this message
|
#6 |
What is the last output before that error message?
I assume it should be the output of
print("Time Left i...",time_left_i)
Revision history for this message
|
#7 |
Hi Manfred
thanks for the followup. The exception is raised when the ide does a check before executing the code therefore there is no print output just the error message.
regards
Mark
The Future Is Certain Give Us Time To Work It Out
_______
From: <email address hidden> <email address hidden> on behalf of Manfred Hampl <email address hidden>
Sent: Monday 23 December 2019 07:44
To: <email address hidden> <email address hidden>
Subject: Re: [Question #687415]: Strange problem or a bug in Sikuli
Your question #687415 on Sikuli changed:
https:/
Status: Open => Needs information
Manfred Hampl requested more information:
What is the last output before that error message?
I assume it should be the output of
print("Time Left i...",time_left_i)
--
To answer this request for more information, you can either reply to
this email or enter your reply at the following page:
https:/
You received this question notification because you asked the question.
Revision history for this message
|
#8 |
Please go to the Launchpad site and answer/comment directly in the thread.
Answering to the notification emails directly adds clutter to this thread and makes it hard to follow.
the problem
[error] Error caused by: java.lang.
comes from the Java level and means, that you have some illegal content at the script level, where a string is expected (as Manfred already mentioned).
Such problems can only be tracked down in the IDE, by testing suspicious snippets isolated in a new tab or by only running a line selection (right mouse on line number column).
add a print statement like print "****** testing" and with each test iteration move it further to get nearer to the crash point.
Another option always is to track back, what has been changed before.
Revision history for this message
|
#9 |
I've done what was suggested and am still getting the error when the test procedure basically contains just the if statement:
def test():
#
if time_left_i[0] == ""
Revision history for this message
|
#10 |
What is the definition of get_time_left? I only find a def for get_time()
At the end of the "if" line you need a colon.
The indentation is inconsistent.
Revision history for this message
|
#11 |
Adding the *:* after the if makes no difference to the exception being raised. The def for get time left is:
def get_time_left(reg):
return reg.text().split(" ")
Revision history for this message
|
#12 |
Can you provide a simplified version of your script - as short as possible but still failing, and provide the full text?
Revision history for this message
|
#13 |
Hi Manfred,
below is the simplified script plus a sub-routine it calls. Attached are a couple of screen shots showing the various possible elements in the time area which I am trying to process. I hope sending this directly to you is ok,
Mark
def make_bid(
#
# Here check that
Debug.user("In make_bid")
print("In Make Bid")
if exists ("1576597641783
#
#
print("Bid Placed")
return(1)
#
# if ending soon is not present somethin went wrong, either we are too early
# or someone bought the item
elif exists ("1577013855062
return(1)
else:
print(" Auction is not ending yet need to rerty")
return (2)
#
# need to loop back to calling proc
max_bid = 50000
time_left_i = get_time_
# time_split = time_left_i.split(" ")
print("The len of time_left_i is:",len(
print("Time Left i1..",time_left_i)
if time_left_i[0] == "PLETE":
print("Auction Over")
elif time_left_i[0] == "SOON":
# elif test_if_
# print("Empty string") # <------------
# break # <------------
else:
wait_time_1 = re.sub(
print("Wait time 1 is ",wait_time_1)
print("The type of wait_time_ is:",type(
result = isinstance(
print(
The Future Is Certain Give Us Time To Work It Out
_______
From: <email address hidden> <email address hidden> on behalf of Manfred Hampl <email address hidden>
Sent: Monday 23 December 2019 15:43
To: <email address hidden> <email address hidden>
Subject: Re: [Question #687415]: IDE: How to solve/track strange problems
Your question #687415 on Sikuli changed:
https:/
Status: Open => Needs information
Manfred Hampl requested more information:
Can you provide a simplified version of your script - as short as
possible but still failing, and provide the full text?
--
To answer this request for more information, you can either reply to
this email or enter your reply at the following page:
https:/
You received this question notification because you asked the question.
Revision history for this message
|
#14 |
In the failing lines you have
time_lefti
instead of
time_left_i
Revision history for this message
|
#15 |
Changed all the variable names to be the same and the lines still fail.
Revision history for this message
|
#16 |
Where is the definition of test_if_char ?
Revision history for this message
|
#17 |
Hi Manfred,
the definition is the one you proposed i.e.
def test_if_
for e in value:
if ord(e) > 255: return False
return True
regards
Mark
The Future Is Certain Give Us Time To Work It Out
_______
From: <email address hidden> <email address hidden> on behalf of Manfred Hampl <email address hidden>
Sent: Monday 23 December 2019 17:23
To: <email address hidden> <email address hidden>
Subject: Re: [Question #687415]: IDE: How to solve/track strange problems
Your question #687415 on Sikuli changed:
https:/
Status: Open => Needs information
Manfred Hampl requested more information:
Where is the definition of test_if_char ?
--
To answer this request for more information, you can either reply to
this email or enter your reply at the following page:
https:/
You received this question notification because you asked the question.
Revision history for this message
|
#18 |
But that definition (which isn't my proposal) is missing in your comment #13
Repeating RaiMan's command #8: please do not reply with history!
Revision history for this message
|
#19 |
Manfred,
apologies for the mis-assignment on the code, given that the code which I forgot to include is now available to you are you able to reproduce the problem?
Thanks
Mark
The Future Is Certain Give Us Time To Work It Out
_______
From: <email address hidden> <email address hidden> on behalf of Manfred Hampl <email address hidden>
Sent: Monday 23 December 2019 18:03
To: <email address hidden> <email address hidden>
Subject: Re: [Question #687415]: IDE: How to solve/track strange problems
Your question #687415 on Sikuli changed:
https:/
Status: Open => Answered
Manfred Hampl proposed the following answer:
But that definition (which isn't my proposal) is missing in your comment
#13
Repeating RaiMan's command #8: please do not reply with history!
--
If this answers your question, please go to the following page to let us
know that it is solved:
https:/
If you still need help, you can reply to this email or go to the
following page to enter your feedback:
https:/
You received this question notification because you asked the question.
Revision history for this message
|
#20 |
Yes the problem still exists.
Sent from my Huawei phone
-------- Original message --------
From: Mark McGuinn <email address hidden>
Date: Mon, 23 Dec 2019, 18:22
To: <email address hidden>
Subject: Re: [Question #687415]: IDE: How to solve/track strange problems
Your question #687415 on Sikuli changed:
https:/
Status: Answered => Open
You are still having a problem:
Manfred,
apologies for the mis-assignment on the code, given that the code which
I forgot to include is now available to you are you able to reproduce
the problem?
Thanks
Mark
The Future Is Certain Give Us Time To Work It Out
_______
From: <email address hidden> <email address hidden> on behalf of Manfred Hampl <email address hidden>
Sent: Monday 23 December 2019 18:03
To: <email address hidden> <email address hidden>
Subject: Re: [Question #687415]: IDE: How to solve/track strange problems
Your question #687415 on Sikuli changed:
https:/
Status: Open => Answered
Manfred Hampl proposed the following answer:
But that definition (which isn't my proposal) is missing in your comment
#13
Repeating RaiMan's command #8: please do not reply with history!
--
If this answers your question, please go to the following page to let us
know that it is solved:
https:/
If you still need help, you can reply to this email or go to the
following page to enter your feedback:
https:/
You received this question notification because you asked the question.
--
You received this question notification because you asked the question.
Revision history for this message
|
#21 |
In comment #12 I asked
"Can you provide a simplified version of your script - as short as possible but still failing, and provide the full text?"
You haven't done this so far, so I cannot help further.
And again: Please do not send e-mail replies with history!
Please visit https:/
Revision history for this message
|
#22 |
I get the error with the following simple test
max_bid = 50000
I have emailed a screenshot of the error to the sikuli account as there does not appear a way to upload it to this app.
Revision history for this message
|
#23 |
This question was expired because it remained in the 'Open' state without activity for the last 15 days.