From 4bb6d94357431478a7aff88cbdc33fd17bed4c88 Mon Sep 17 00:00:00 2001 From: Changaco Date: Sat, 17 Feb 2018 17:57:01 +0100 Subject: [PATCH 1/2] create tarballs directory automatically closes #27 --- legi/download.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/legi/download.py b/legi/download.py index 8464c49..d721d0b 100644 --- a/legi/download.py +++ b/legi/download.py @@ -15,6 +15,8 @@ def download_legi(dst_dir): + if not os.path.exists(dst_dir): + os.mkdir(dst_dir) local_files = {filename: {} for filename in os.listdir(dst_dir)} ftph = ftplib.FTP() ftph.connect(DILA_FTP_HOST, DILA_FTP_PORT) From 7b55483b57c4c86ed4cdf46e1ff10192492dc291 Mon Sep 17 00:00:00 2001 From: Changaco Date: Sat, 17 Feb 2018 18:13:08 +0100 Subject: [PATCH 2/2] download files in order --- legi/download.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/legi/download.py b/legi/download.py index d721d0b..6f2d3cc 100644 --- a/legi/download.py +++ b/legi/download.py @@ -22,11 +22,10 @@ def download_legi(dst_dir): ftph.connect(DILA_FTP_HOST, DILA_FTP_PORT) ftph.login() ftph.cwd(DILA_LEGI_DIR) - remote_files = {filename: {} for filename in ftph.nlst() if 'legi_' in filename} - local_set = set(local_files.keys()) - remote_set = set(remote_files.keys()) - common_files = list(local_set & remote_set) - missing_files = list(remote_set - local_set) + remote_files = [filename for filename in ftph.nlst() if 'legi_' in filename] + common_files = [f for f in remote_files if f in local_files] + missing_files = [f for f in remote_files if f not in local_files] + remote_files = {filename: {} for filename in remote_files} for filename in common_files: local_files[filename]['size'] = os.path.getsize( os.path.join(dst_dir, filename)