Last active
May 31, 2018 17:39
-
-
Save benjamingregory/da6d1b34e1e056419239b8612d2059d2 to your computer and use it in GitHub Desktop.
ftp_example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from airflow.hooks.ftp_hook import FTPHook | |
def describe_directory(**kwargs): | |
path = kwargs.get('path', None) | |
ftp_conn_id = kwargs.get('ftp_conn_id', None) | |
filename = kwargs.get('templates_dict').get('filename', None) | |
ftp_hook = FTPHook(ftp_conn_id=ftp_conn_id) | |
client = ftp_hook.get_conn() | |
directory = client.describe_directory(path) | |
logging.info('Directory Retrieved.') | |
if directory: | |
for k,v in directory.items: | |
print('{} - {}'.format(k,v)) | |
return directory | |
else: | |
print('Directory empty.) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment