← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #210756]: Not able to write the text file.

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
then you should try this revised version:

wait(2)
el = "\n" # the end of line you want to use
my_dir = "D:\\"
my_file=file(my_dir + "DPWrite.txt", "w")
if exists ("ULUNPAID-5.png"):
    type("UL")
    my_file.write("UL"+el) # if you want to have line breaks
    wait(2)
if exists ("WOWEEKLYOFF-5.png"):
    type("WO")
    my_file.write("WO"+el) # if you want to have line breaks
    wait(2)
if exists ("CLCASUAL-5.png"):
    type("CL")
    my_file.write("CL"+el) # if you want to have line breaks
    wait(2)
if exists ("PFPresentFul-4.png"):
    type("PF")
    my_file.write("PF"+el) # if you want to have line breaks
    wait(2)
my_file.close()
wait(2)


Since I guess you are running this in IDE, you should assure, that the file is closed in any cases (which is the fact in this version).

With the full script: If only [log] TYPE "UL" is reported, this means,
that the other type()'s are not processed, hence the close() neither. So
the content might not be written to disk yet with these few bytes as
long as you do not shutdown the IDE.

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