I don’t get it. What am I doing wrong?
self.firstRun = 0
# Check if log file exist
try:
self.checkFile = open('rec.txt')
# if it doesn't write it
except IOError:
self.checkFile = open('rec.txt', 'w')
self.checkFile.write('File INI\n\nFirst
Run = TRUE\nTime = '+str(self.getTime)+'\n')
self.checkFile.close()
# otherwise just read it and print it
else:
self.checkFile = open('rec.txt', 'r')
for line in fileinput.input(['rec.txt']):
print (line)
self.checkFile.close()
# For appending purposes
try:
self.recordFile = open('rec.txt')
except IOError:
print "File rec.txt not found"
else:
self.recordFile = open('rec.txt', 'r')
self.readLine =
linecache.getline('rec.txt', 3)
if self.readLine == "First Run = TRUE":
self.firstRun = 1
print "##"+str(self.readLine)
for line in fileinput.input(['rec.txt']):
print (line)
self.recordFile.close()
The print for self.readLine is ##First Run = TRUE, but strangely (at least for me) print (line) has some extra lines:
File INI
First Run = TRUE
Time = 10.8168613321
Still I don’t understand why self.readLine is not equal to “First Run = TRUE”. I know it doesn’t because when I use this code;
if self.firstRun == 1:
self.hVoice001 =
loader.loadSfx("Sound/silent.mp3")
else:
self.hIV = Sequence(Wait(20),
Parallel(self.hVoiceID_001,
Func(self.narLetter_0.__setitem__, "text",
"Welcome,"),
Func(self.narLetter_0.__setitem__, "text_fg",
(1,1,0,1))), Wait(8))
self.hIV.start()
self.hIV plays
However, when I use this:
if self.firstRun == 0:
self.hVoice001 =
loader.loadSfx("Sound/silent.mp3")
else:
self.hIV = Sequence(Wait(20),
Parallel(self.hVoiceID_001,
Func(self.narLetter_0.__setitem__, "text",
"Welcome,"),
Func(self.narLetter_0.__setitem__, "text_fg",
(1,1,0,1))), Wait(8))
self.hIV.start()
The sequence doesn’t play.
I don’t see why it’s not working as I think it should.