diff options
Diffstat (limited to 'python/collateral/wells.py')
| -rw-r--r-- | python/collateral/wells.py | 51 |
1 files changed, 6 insertions, 45 deletions
diff --git a/python/collateral/wells.py b/python/collateral/wells.py index affd99a8..e47142ee 100644 --- a/python/collateral/wells.py +++ b/python/collateral/wells.py @@ -1,54 +1,15 @@ import pandas as pd -import socket -from . import DAILY_DIR +from . import DAILY_DIR, SftpClient2 from .common import compare_notionals, STRATEGY_CASH_MAPPING -from paramiko import Transport, SFTPClient +from functools import partial from sqlalchemy.exc import IntegrityError -from ssh2.session import Session -from ssh2.sftp import LIBSSH2_FXF_READ, LIBSSH2_SFTP_S_IRUSR, LIBSSH2_SFTP_S_IFREG -def get_wells_sftp_client(): - transport = Transport(("axst.wellsfargo.com", 10022)) - transport.connect(username="LMCHsWC6EP", password="HI2s2h19+") - return SFTPClient.from_transport(transport) +sftp = SftpClient2.from_creds("wells") - -def get_wells_sftp_client2(): - sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - sock.connect(("axst.wellsfargo.com", 10022)) - session = Session() - session.handshake(sock) - session.userauth_password("LMCHsWC6EP", "HI2s2h19+") - sftp = session.sftp_init() - return sftp - - -def download_files2(d=None): - DATA_DIR = DAILY_DIR / "Wells_reports" - sftp = get_wells_sftp_client() - base_dir = "/RECEIVE/339425_DATO2" - for f in sftp.listdir(base_dir): - if not (DATA_DIR / f).exists(): - sftp.get(f"{base_dir}/{f}", localpath=DATA_DIR / f) - - -def download_files(d=None): - DATA_DIR = DAILY_DIR / "Wells_reports" - sftp = get_wells_sftp_client2() - files = [] - with sftp.opendir("/RECEIVE/339425_DATO2") as fh: - for size, buf, attrs in fh.readdir(): - if attrs.permissions & LIBSSH2_SFTP_S_IFREG: - files.append(buf.decode()) - for f in files: - local_file = DATA_DIR / f - if not local_file.exists(): - with sftp.open( - f"/RECEIVE/339425_DATO2/{f}", LIBSSH2_FXF_READ, LIBSSH2_SFTP_S_IRUSR - ) as remote_handle, local_file.open("wb") as local_handle: - for size, data in remote_handle: - local_handle.write(data) +download_files = partial( + sftp.download_files, "/RECEIVE/339425_DATO2", DAILY_DIR / "Wells_reports" +) def collateral(d, positions, engine): |
