On 28 July, 15:18, Bakes <ba...@ymail.com> wrote: > On 28 July, 15:01, Hrvoje Niksic <hnik...@xemacs.org> wrote: > > > > > Bakes <ba...@ymail.com> writes: > > > The error I get is: > > > ftplib.error_temp: 451-Restart offset 24576 is too large for file size > > > 22852. > > > 451 Restart offset reset to 0 > > > which tells me that the local file is larger than the external file, > > > by about a kilobyte. Certainly, the local file is indeed that size, so > > > my local script is doing the right things. I do wonder what is going > > > wrong, can anyone enlighten me? > > > I'd say you failed to take buffering into account. You write into a > > buffered file, yet you use os.path.getsize() to find out the current > > file size. If the data is not yet flushed, you keep re-reading the same > > stuff from the remote file, and writing it out. Once the buffer is > > flushed, your file will contain more data than was retrieved from the > > remote side, and eventually this will result in the error you see. > > > As a quick fix, you can add a file.flush() line after the > > file.write(...) line, and the problem should go away. > > Thank you very much, that worked perfectly.
Actually, no it didn't. That fix works seamlessly in Linux, but gave the same error in a Windows environment. Is that expected? -- http://mail.python.org/mailman/listinfo/python-list