import ftplibimport osimport socketHOST = 'ftp.mozilla.org'DIRN = 'pub/mozilla.org/webtools'FILE = 'bugzilla-LATEST.tar.gz'try: f = ftplib.FTP(HOST)except (socket.error, socket.gaierror), e: print 'ERROR: cannot reach "%s"' % HOST returnprint '*** Connected to host "%s"' % HOSTtry: f.login()except ftplib.error_perm: print 'ERROR: cannot login anonymously' f.quit() returnprint '*** Logged in as "anonymous"'try: f.cwd(DIRN)except ftplib.error_perm: print 'ERROR: cannot CD to "%s"' % DIRN f.quit() returnprint '*** Changed to "%s" folder' % DIRNtry: 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' % FILEf.quit()return
Name (required)
email (will not be published) (required)
Website