Blank log file

Asked by William Elmer

Hello! I am new to jython but moderate programmer. I am trying to write to a file for someone to see whether or not the test passed. But I get a blank write.txt file back. So here is generic code.

f = open(my_dir + 'read.txt', 'r')
#do work
username = f.readline()
password = f.readline()
f.close
w = open(my_dir + 'write.txt", 'w')
w.write("username was " + username)
#some more work
w.close()
sleep(5)
# script ends here.

Experimented with w.flush and everything and nothing seems to work.

edit:
For clarity purposes, I wanted to stress : It reads great! But when I try to write it fails every time.

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
William Elmer (william-elmer) said :
#1

additonal information:
Windows XP
I fully define each time I open a new file. (I verify the path by using the run in windows, just adding for clarification )
I am a admin on the machine.
I get no error messages.

Revision history for this message
j (j-the-k) said :
#2

Maybe it's just a typo, but "f.close" has no "()" in your script.

Your script seems okay.
Make sure you defenitely have the right path in my_dir.
I have used the same commands before in Sikuli and mine worked, so it's not a Sikuli bug but some problem in your script.
If you specify a wrong path, Python will just create a file at the wrong location and you will not get any error messages.

Revision history for this message
William Elmer (william-elmer) said :
#3

Thanks for the tip but yes it was just a typo. My script has f.close.

I have confirmed that it was the correct path by copy pasta into windows-> run and it launches my log file.
Again, no error messages. I have circumvented this problem by allowing the file to be created in the local sikuli directory and so it is not a problem with my write statements or close statements either. I am assuming it has to be something with the path or the way XP does things. ./shrug. QA will just have to be happy with what I give them :D

Revision history for this message
RaiMan (raimund-hocke) said :
#4

user is happy now