Skip to main content
Question

PythonCaller: download from FTP to specific folder

  • October 30, 2024
  • 4 replies
  • 105 views

fikusas
Contributor
Forum|alt.badge.img+5

How can I download file from ftpes:// to specified folder? I’m using the script below.

import fmeobjects
import os
from ftplib import FTP_TLS
import ssl

def processFeature(feature):
path = '/lsms/'
filename = 'apples.zip'

ftp = FTP_TLS('FTP-SERVER')
ftp.ssl_version = ssl.PROTOCOL_TLS
ftp.login('name', 'pass')
ftp.prot_p()
ftp.cwd(path)
ftp.retrbinary("RETR " + filename, open(filename, 'wb').write)
ftp.quit()
feature.setAttribute('name', filename)

 

4 replies

david_r
Celebrity
  • October 30, 2024

Why not use the FTPCaller?


fikusas
Contributor
Forum|alt.badge.img+5
  • Author
  • Contributor
  • October 30, 2024

FTPCaller gives error with no clear info about it. I'm using older version of FME. Trying to work around this.


saraatsafe
Safer
Forum|alt.badge.img+12
  • Safer
  • November 6, 2024

Hi @fikusas, what’s the error you’re running into when you try the FTPCaller? It might help to run your workspace with Log Debug enabled, sometimes that can give us a little more information as to what’s gone wrong. You can enable Log Debug by navigating to Tools > FME Options > Translation > Log Settings. 


fikusas
Contributor
Forum|alt.badge.img+5
  • Author
  • Contributor
  • November 7, 2024

Hi @fikusas, what’s the error you’re running into when you try the FTPCaller? It might help to run your workspace with Log Debug enabled, sometimes that can give us a little more information as to what’s gone wrong. You can enable Log Debug by navigating to Tools > FME Options > Translation > Log Settings. 

Log shows “Error” without any details about it. Probably its version bug.