← Back to team overview

sikuli-driver team mailing list archive

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

 

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

    Status: Solved => Open

Milind Warade is still having a problem:
Hi ,

I am again not able to read the time from the text file.

When there are two lines say,
(19, 45, 08)
(19, 46, 10)
then it was working in fine manner.

But in below script it was not working.


I have given text file "Time.txt" as:
(19, 45, 08)
(19, 46, 10)
(19, 47, 08)
(19, 48, 10)
(19, 49, 08)
(19, 50, 10)
(19, 51, 08)
(19, 52, 10)
(19, 53, 08)
(19, 54, 10)
(19, 55, 08)
(19, 56, 10)
(19, 57, 08)
(19, 58, 10)


My script is:

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-4.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-4.png")
wait(5)
click("earthprogram-7.png")
type("firefox" + Key.ENTER)
wait(5)
type("t", KeyModifier.CTRL)
wait(5)
type("https://ABCD:80/IDS/TestIDS.jsp"; + Key.ENTER)
wait("RequestXMLRe-1.png",20)
type(Key.TAB + Key.TAB)
type('v', KeyModifier.CTRL)
wait(2)
until = list(time.localtime())
until[3:6] = eval(arr[0]) # hour minute second
timeUntil = time.mktime(tuple(until))
timeToWait = int(timeUntil - time.time())
if timeToWait < 1:
    timeToWait1 = (86400 + int(timeUntil - time.time()))
    wait(timeToWait1)
else:
    wait(timeToWait)
click("submit-1.png")
wait(8)
click("clear.png")
wait(2)
# For clock in for Employee E6
click("1348813496420-4.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.png")
type('v', KeyModifier.CTRL)
wait(2)
until = list(time.localtime())
until[3:6] = eval(arr[1]) # hour minute second
timeUntil = time.mktime(tuple(until))
timeToWait = int(timeUntil - time.time())
if timeToWait < 1:
    timeToWait1 = (86400 + int(timeUntil - time.time()))
    wait(timeToWait1)
else:
    wait(timeToWait)
click("submit-1.png")
wait(8)
click("clear.png")
wait(2)
# For clock in for Employee E5
click("1348813496420-4.png")
wait(1)
type("D:\\DPTT_XML\\E5.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.png")
type('v', KeyModifier.CTRL)
wait(2)
until = list(time.localtime())
until[3:6] = eval(arr[2]) # hour minute second
timeUntil = time.mktime(tuple(until))
timeToWait = int(timeUntil - time.time())
if timeToWait < 1:
    timeToWait1 = (86400 + int(timeUntil - time.time()))
    wait(timeToWait1)
else:
    wait(timeToWait)
click("submit-1.png")
wait(8)
click("clear.png")
wait(2)
# For clock in for Employee E2
click("1348813496420-4.png")
wait(1)
type("D:\\DPTT_XML\\E2.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.png")
type('v', KeyModifier.CTRL)
wait(2)
until = list(time.localtime())
until[3:6] = eval(arr[3]) # hour minute second
timeUntil = time.mktime(tuple(until))
timeToWait = int(timeUntil - time.time())
if timeToWait < 1:
    timeToWait1 = (86400 + int(timeUntil - time.time()))
    wait(timeToWait1)
else:
    wait(timeToWait)
click("submit-1.png")
wait(8)
click("clear.png")
wait(2)
# For clock in for Employee E3
click("1348813496420-4.png")
wait(1)
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(2)
click("1349867277615.png")
type('v', KeyModifier.CTRL)
wait(2)
until = list(time.localtime())
until[3:6] = eval(arr[4]) # hour minute second
timeUntil = time.mktime(tuple(until))
timeToWait = int(timeUntil - time.time())
if timeToWait < 1:
    timeToWait1 = (86400 + int(timeUntil - time.time()))
    wait(timeToWait1)
else:
    wait(timeToWait)
click("submit-1.png")
wait(8)
click("clear.png")
wait(2)
# For clock in for Employee E7
click("1348813496420-4.png")
wait(1)
type("D:\\DPTT_XML\\E7.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.png")
type('v', KeyModifier.CTRL)
wait(2)
until = list(time.localtime())
until[3:6] = eval(arr[5]) # hour minute second
timeUntil = time.mktime(tuple(until))
timeToWait = int(timeUntil - time.time())
if timeToWait < 1:
    timeToWait1 = (86400 + int(timeUntil - time.time()))
    wait(timeToWait1)
else:
    wait(timeToWait)
click("submit-1.png")
wait(8)
click("clear.png")
wait(2)
# For clock in for Employee E8
click("1348813496420-4.png")
wait(1)
type("D:\\DPTT_XML\\E8.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.png")
type('v', KeyModifier.CTRL)
wait(2)
until = list(time.localtime())
until[3:6] = eval(arr[6]) # hour minute second
timeUntil = time.mktime(tuple(until))
timeToWait = int(timeUntil - time.time())
if timeToWait < 1:
    timeToWait1 = (86400 + int(timeUntil - time.time()))
    wait(timeToWait1)
else:
    wait(timeToWait)
click("submit-1.png")
wait(8)
click("clear.png")
wait(2)
# For clock in for Employee E5
click("1348813496420-4.png")
wait(1)
type("D:\\DPTT_XML\\E5.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.png")
type('v', KeyModifier.CTRL)
wait(2)
until = list(time.localtime())
until[3:6] = eval(arr[7]) # hour minute second
timeUntil = time.mktime(tuple(until))
timeToWait = int(timeUntil - time.time())
timeToWait1 = (86400 + int(timeUntil - time.time()))
if timeToWait < 1:
    timeToWait1 = (86400 + int(timeUntil - time.time()))
    wait(timeToWait1)
else:
    wait(timeToWait)
click("submit-1.png")
wait(8)
click("clear.png")
wait(2)
# For clock in for Employee E1
click("1348813496420-4.png")
wait(1)
type("D:\\DPTT_XML\\E1.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.png")
type('v', KeyModifier.CTRL)
wait(2)
until = list(time.localtime())
until[3:6] = eval(arr[8]) # hour minute second
timeUntil = time.mktime(tuple(until))
timeToWait = int(timeUntil - time.time())
if timeToWait < 1:
    timeToWait1 = (86400 + int(timeUntil - time.time()))
    wait(timeToWait1)
else:
    wait(timeToWait)
click("submit-1.png")
wait(8)
click("clear.png")
wait(2)
# For clock in for Employee E8
click("1348813496420-4.png")
wait(1)
type("D:\\DPTT_XML\\E8.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.png")
type('v', KeyModifier.CTRL)
wait(2)
until = list(time.localtime())
until[3:6] = eval(arr[9]) # hour minute second
timeUntil = time.mktime(tuple(until))
timeToWait = int(timeUntil - time.time())
if timeToWait < 1:
    timeToWait1 = (86400 + int(timeUntil - time.time()))
    wait(timeToWait1)
else:
    wait(timeToWait)
click("submit-1.png")
wait(8)
click("clear.png")
wait(2)
# For clock in for Employee E2
click("1348813496420-4.png")
wait(1)
type("D:\\DPTT_XML\\E2.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.png")
type('v', KeyModifier.CTRL)
wait(2)
until = list(time.localtime())
until[3:6] = eval(arr[10]) # hour minute second
timeUntil = time.mktime(tuple(until))
timeToWait = int(timeUntil - time.time())
timeToWait1 = (86400 + int(timeUntil - time.time()))
if timeToWait < 1:
    timeToWait1 = (86400 + int(timeUntil - time.time()))
    wait(timeToWait1)
else:
    wait(timeToWait)
click("submit-1.png")
wait(8)
click("clear.png")
wait(2)
# For clock in for Employee E6
click("1348813496420-4.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.png")
type('v', KeyModifier.CTRL)
wait(2)
until = list(time.localtime())
until[3:6] = eval(arr[11]) # hour minute second
timeUntil = time.mktime(tuple(until))
timeToWait = int(timeUntil - time.time())
timeToWait1 = (86400 + int(timeUntil - time.time()))
if timeToWait < 1:
    timeToWait1 = (86400 + int(timeUntil - time.time()))
    wait(timeToWait1)
else:
    wait(timeToWait)
click("submit-1.png")
wait(8)
click("clear.png")
wait(2)
# For clock in for Employee E7
click("1348813496420-4.png")
wait(1)
type("D:\\DPTT_XML\\E7.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.png")
type('v', KeyModifier.CTRL)
wait(2)
until = list(time.localtime())
until[3:6] = eval(arr[12]) # hour minute second
timeUntil = time.mktime(tuple(until))
timeToWait = int(timeUntil - time.time())
timeToWait1 = (86400 + int(timeUntil - time.time()))
if timeToWait < 1:
    timeToWait1 = (86400 + int(timeUntil - time.time()))
    wait(timeToWait1)
else:
    wait(timeToWait)
click("submit-1.png")
wait(8)
click("clear.png")
wait(2)
# For clock in for Employee E1
click("1348813496420-4.png")
wait(1)
type("D:\\DPTT_XML\\E1.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.png")
type('v', KeyModifier.CTRL)
wait(2)
until = list(time.localtime())
until[3:6] = eval(arr[13]) # hour minute second
timeUntil = time.mktime(tuple(until))
timeToWait = int(timeUntil - time.time())
if timeToWait < 1:
    timeToWait1 = (86400 + int(timeUntil - time.time()))
    wait(timeToWait1)
else:
    wait(timeToWait)
click("submit-1.png")
wait(8)
click("clear.png")
wait(5)
App.close("Firefox")
wait(1)



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 "https://ABCD:80/IDS/TestIDS.jsp "

[log] TYPE " "

[log] Ctrl+TYPE "v"

[error] Stopped
[error] An error occurs at line 36
[error] Error message: Traceback (most recent call last):
 File "C:\Users\milindw\AppData\Local\Temp\sikuli-tmp8926183849044586452.py", line 36, in 
 until[3:6] = eval(arr[0]) # hour minute second
SyntaxError: ("no viable alternative at character ')'", ('', 1, 11, '(19, 45, 08)\n'))


Please help me out.

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