blob: c42588e87a67e2e7d898d176d24d1e77626e2d4d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
try:
from serenitas.utils.env import DAILY_DIR
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"
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__":
download_files()
|