# Use the FTP Directory to retrieve KMZ
try:
f.retrbinary('RETR %s' % FILE, open(FILE, 'wb').write)
except ftplib.error_perm:
print 'ERROR: cannot read file "%s"' % FILE
os.unlink(FILE)
else:
print '*** Downloaded "%s" to CWD' % FILE
Do they seem right to you ? This is from the book Programming ArcGIS 10.1 with Python cookbook. When I ran it in Pyscripter 2.5.3.0 and it gave me the error :
Traceback (most recent call last):
File "C:\ArcpyBook\Appendix2\ftp.py", line 45, in <module>
f.retrbinary('RETR %s' % FILE, open(FILE, 'wb').write)
File "C:\Python27\ArcGIS10.1\lib\ftplib.py", line 398, in retrbinary
self.voidcmd('TYPE I')
File "C:\Python27\ArcGIS10.1\lib\ftplib.py", line 248, in voidcmd
self.putcmd(cmd)
File "C:\Python27\ArcGIS10.1\lib\ftplib.py", line 178, in putcmd
self.putline(line)
File "C:\Python27\ArcGIS10.1\lib\ftplib.py", line 173, in putline
self.sock.sendall(line)
AttributeError: 'NoneType' object has no attribute 'sendall'