Skip to main content
Question

PythonCaller: download from FTP to specific folder

  • October 30, 2024
  • 4 replies
  • 86 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
Evangelist
  • 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+8
  • 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
saraatsafe wrote:

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.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings