0

Hi All,

I made a python ftp client on Windows XP which does binary get & put.

The issue here is that when I do FTP manually the time taken to either GET or PUT is about half the time taken by my ftp client.

Following is a snippet of my code; Is there a better approach to do this?

def get(self,filename):
        try:
            start = time.clock() 
            self.ftph.retrbinary('RETR '+ filename, open(filename, 'wb').write)
            end = time.clock() 
        except Exception:
            print "Error in downloading the remote file."
            return
        else:
            print "Successful download!"
            print "GET completed in %f seconds." % (end-start)
            return

Thanks

2
Contributors
3
Replies
4
Views
9 Years
Discussion Span
Last Post by jlm699
0

I'm not positive about this but I would assume that some of the time is consumed in the buffering of the file write process.

Perhaps in stead of an open file handle you could try an IOString, which after the operation is complete you could write to file in one chunk?

0

Hi Jim,

I was looking around for IOString module. But I could'nt find it, import IOString fails on windows.

Thanks

0

Lo siento mi amigo, it's StringIO... sometimes I type faster than my brain can process words. :\

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.