diff options
Diffstat (limited to 'python/ice.py')
| -rw-r--r-- | python/ice.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/python/ice.py b/python/ice.py index 0d36c5fb..c42588e8 100644 --- a/python/ice.py +++ b/python/ice.py @@ -4,12 +4,25 @@ except KeyError: sys.exit("Please set 'DAILY_DIR' in the environment") from serenitas.utils.remote import SftpClient +from stat import S_ISREG def download_files(): sftp = SftpClient.from_creds("ice") dst = DAILY_DIR / "ICE_reports" - sftp.download_files("/", dst) + download_sftp_files(sftp, "/", dst) + + +def download_sftp_files(sftp, src, dst): + for f in sftp.client.listdir_iter(src): + if (f.filename.startswith("ICC_CDSSingleNameClearingEligibleInstruments")) or ( + f.filename.startswith("clearingHouseClearingEligibleInstruments") + ): + continue + if S_ISREG(f.st_mode): + local_file = dst / f.filename + if not local_file.exists(): + sftp.client.get(f"{src}/{f.filename}", localpath=local_file) if __name__ == "__main__": |
