Problem using StringIO file object

Myles myles at geocities.com
Thu May 20 04:01:21 EDT 2004


"Joshua Burvill" <josh at mri.com.au> wrote in message news:<mailman.100.1085022042.6949.python-list at python.org>...

>     file_handle.write(zpt_code)

Okay, you've written to your file object, so your current "file
position" is at the end of the buffer, ready for more writes - reading
from it now will only produce an empty string.
You need to reset your file position to the beginning of the buffer.

>     ftp=FTP(printserver_ip)
>     ftp.login("","")
>     ftp.set_pasv(0)
> 

I'd try putting in a
    file_handle.seek(0)
here, so that your ftp object can read from the beginning 
of the buffer

>     val=ftp.storlines("STOR " + portname, file_handle)

and another
    file_handle.seek(0)
here so the read can also produce data.

>     return val, file_handle.read()

Regards, Myles.



More information about the Python-list mailing list