Python and Networking type questions

Ok, there was a lot in that post, I’ll try to provide the best answers I can, in order.

  1. There isn’t really a cap on the client machine, unless the FTP server imposes one. I mean, there is a cap (# of ephemeral ports available in Windows, typically 5000), but for all practical purposes, you won’t hit it.

  2. Sorry, I don’t know. The Python doc page for FTP doesn’t have any mention of a timeout, its probably using some OS default, but you might be able to set it somehow, not sure…

  3. I don’t know.

Leading Zero:

This is easy to do, just use string formatting, like so:

filename = 'MACH_%02d.CSV' % k

Multiple downloads at once:

You can do this using fpmi.system.invokeAsynchronous - here is an example:

[code]
for loopVar in range(20):
def doDownload(i=loopVar):
try:
string = ‘10.0.0.’+str(i)
k=i-10
filename = ‘MACH_0’+str(k)+’.CSV’
from ftplib import FTP
ftp = FTP(string)
ftp.login(‘david’,‘bigbrother’)
print"Downloading :"+filename
ftp.set_pasv(0)
ftp.retrbinary('RETR ’ + filename,open(filename,‘wb’).write)
print"accept",i
except:
print"deny",i

fpmi.system.invokeAsynchronous(doDownload)[/code]

Hope this helps,