file operation question
Ivan Brkanac
ivan.brkanac at hl.hinet.hr
Wed Oct 16 08:54:40 EDT 2002
Hello I am making little application and in it I am processing some
files
and I decided to make code that rebuilds(fetch from Internet) file if it
is not existing. But I get error message belov is part off the code and
report off error. Problem is as I can see that win don't update file so
fast and when script try to read file again it reads emptyy file. I used
file.close() before opening file again for parsing. Is there any way to
wait until file is closed so that it can be read again
Regards Ivan
try:
self.inicijalizacija(open('./tecaji.dat','r'))
except IOError:
wxSetCursor(wxHOURGLASS_CURSOR) # Kursor U hourglas
import urllib, urllister, urlparse
f =urllib.URLopener().open(adresa)
t = f.read() # UÃitamo je u string
f.close()
parser = urllister.URLLister()
parser.feed(t)
parser.close()
t = open('./tecaji.dat','w')
f = urllib.URLopener().open(urlparse.urljoin(adresa ,
parser.urls[0]))
t.write(f.read())
t.close
f.close # close file
wxSetCursor(wxSTANDARD_CURSOR) # postavimo normalni kursor
self.inicijalizacija(open('./tecaji.dat','r')) # AGAIN
# opening for procesing but it reads empty ??
D:\Documents and Settings\Administrator\My Documents\Python>python
pretvorba.py
Traceback (most recent call last):
File "pretvorba.py", line 153, in ?
app = MyApp(0)
File "C:\Python\lib\site-packages\wxPython\wx.py", line 1587, in
__init__
_wxStart(self.OnInit)
File "pretvorba.py", line 148, in OnInit
frame = MyFrame(NULL, -1, "Konverzija Valuta Tecaj od ")
File "pretvorba.py", line 24, in __init__
self.inicijalizacija(open('./tecaji.dat','r'))
File "pretvorba.py", line 104, in inicijalizacija
datum = ND(tecaj[15:19]+tecaj[13:15]+tecaj[11:13])
File "C:\Python\lib\normalDate.py", line 82, in __init__
self.setNormalDate(normalDate)
File "C:\Python\lib\normalDate.py", line 376, in setNormalDate
raise NormalDateException("Bad integer: '%s'" % normalDate)
normalDate.NormalDateException: Bad integer: ''
More information about the Python-list
mailing list