← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #140267]: writing a log

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
the sequence

logfile = file(dir + "txt.txt", "w")
logfile.write("ok")
logfile.close

every time rewrites the file from beginning. So it contains only 1 line
(the last one written)

use 
logfile = file(dir + "txt.txt", "a")
to append lines to the end of the file.

alternatively use:
dir = "c:\\...."
logfile = file(dir + "txt.txt", "w")
at the beginning of your script, to get it empty and opened

and then only use 
logfile.write("ok")
in between to write the next line to the open file

and at the end of the script once
logfile.close()

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