← Back to team overview

sikuli-driver team mailing list archive

[Question #210841]: Not able to read from text file when timestamp is used

 

New question #210841 on Sikuli:
https://answers.launchpad.net/sikuli/+question/210841

Dear,

I have one text file "Time.txt"  which contents data like:
18, 50, 50
19, 25, 56

Then I have write script in which I want take the data from text file line by line.


wait(2)
import array
arr=[]
f=open("D:\\DPTT_XML\\Time.txt","r")
fout = open("D:\\DPTT_XML\\Time-results.txt","w")

for line in f.readlines():
    arr.append(line.strip()) # get rid of newline
f.close()
wait(2)
click("1348813496420-5.png")
wait(1)
# For clock in for Employee E3
type("D:\\DPTT_XML\\E3.txt")
wait(1)
type(Key.ENTER)
wait(1)
type('a', KeyModifier.CTRL)
type('c', KeyModifier.CTRL)
type(Key.F4, KeyModifier.ALT)
wait(1)
# Open firefox
click("1348813496420-5.png")
wait(5)
click("earthprogram-8.png")
type("firefox" + Key.ENTER)
wait(5)
type("t", KeyModifier.CTRL)
wait(5)
type("http://abcd:80/Test.jsp"; + Key.ENTER)
wait("RequestXMLRe-2.png",20)
type(Key.TAB + Key.TAB)
type('v', KeyModifier.CTRL)
wait(2)
until = list(time.localtime())
until[3:6] = (arr[0]) # hour minute second
timeUntil = time.mktime(tuple(until))
timeToWait = int(timeUntil - time.time())
wait (timeToWait)
click("submit-2.png")
wait(2)
click("clear-1.png")
wait(2)
# For clock in for Employee E6
click("1348813496420-5.png")
wait(1)
type("D:\\DPTT_XML\\E6.txt")
wait(1)
type(Key.ENTER)
wait(1)
type('a', KeyModifier.CTRL)
type('c', KeyModifier.CTRL)
type(Key.F4, KeyModifier.ALT)
wait(2)
click("1349867277615-1.png")
type('v', KeyModifier.CTRL)
wait(2)
until = list(time.localtime())
until[3:6] = (arr[1]) # hour minute second
timeUntil = time.mktime(tuple(until))
timeToWait = int(timeUntil - time.time())
wait (timeToWait)
click("submit-2.png")
wait(2)
click("clear-1.png")
wait(2)

Error occurs as:

[log] CLICK on (28,748)

[log] TYPE "D:\DPTT_XML\E3.txt"

[log] TYPE " "

[log] Ctrl+TYPE "a"

[log] Ctrl+TYPE "c"
[log] Alt+TYPE "?"

[log] CLICK on (28,748)

[log] CLICK on (101,695)

[log] TYPE "firefox "

[log] Ctrl+TYPE "t"

[log] TYPE "http://abcd:80/Test.jsp "

[log] TYPE " "

[log] Ctrl+TYPE "v"

[error] Stopped
[error] An error occurs at line 37
[error] Error message: Traceback (most recent call last):
 File "C:\Users\milindw\AppData\Local\Temp\sikuli-tmp6010284413651765971.py", line 37, in 
 timeUntil = time.mktime(tuple(until))
OverflowError: an integer is required


But when I have tried by writing :
from until[3:6] = (arr[0]) # hour minute second 
To until[3:6] = (18, 30, 56) # hour minute second

Then it works.

But I don't know why it was not picking value from text file.

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