aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--python/process_queue.py22
-rw-r--r--python/remote.py6
2 files changed, 12 insertions, 16 deletions
diff --git a/python/process_queue.py b/python/process_queue.py
index fab0fc78..ea0fe6e9 100644
--- a/python/process_queue.py
+++ b/python/process_queue.py
@@ -339,16 +339,13 @@ def process_list(
if trade_type == "bond" and fund == "SERCGMAST":
trades = [send_email(trade) for trade in trades]
if fund in ("SERCGMAST", "BOWDST") or trade_type in ("cds", "swaption"):
- try:
- buf = generate_csv(
- (t for t in trades if t.get("upload", True)), trade_type, fund,
- )
- dest = get_filepath(DAILY_DIR, trade_type, fund)
- if upload:
- upload_buf(buf, dest.name, fund)
- dest.write_bytes(buf)
- except IOError:
- pass
+ buf = generate_csv(
+ (t for t in trades if t.get("upload", True)), trade_type, fund,
+ )
+ dest = get_filepath(DAILY_DIR, trade_type, fund)
+ if upload:
+ upload_buf(buf, dest.name, fund)
+ dest.write_bytes(buf)
p.delete(key)
@@ -857,8 +854,7 @@ def upload_buf(buf: bytes, dest: str, fund: str) -> None:
elif fund == "BOWDST":
sftp = SftpClient.from_creds("bony")
sftp.client.chdir("/inbound/cfe/")
- sftp.put(buf, dest)
- attach = FileAttachment(dest, buf)
+ sftp.put(buf, dest, False)
em = ExchangeMessage()
em.send_email(
"Trade file",
@@ -868,7 +864,7 @@ def upload_buf(buf: bytes, dest: str, fund: str) -> None:
"hm-operations@bnymellon.com",
),
cc_recipients=("bowdoin-ops@lmcg.com",),
- attachments=(FileAttachment(dest, buf),),
+ attach=(FileAttachment(name=dest, content=buf),),
)
else:
raise ValueError("unknow fund name")
diff --git a/python/remote.py b/python/remote.py
index bce065fd..23513587 100644
--- a/python/remote.py
+++ b/python/remote.py
@@ -59,14 +59,14 @@ class SftpClient(Client):
if not local_file.exists():
self.client.get(f"{src}/{f}", localpath=local_file)
- def put(self, src: Union[pathlib.Path, bytes], dst: str = None):
+ def put(self, src: Union[pathlib.Path, bytes], dst: str = None, confirm=True):
if isinstance(src, pathlib.Path):
if dst is None:
dst = src.name
with src.open("rb") as fh:
- self.client.putfo(fh, dst)
+ self.client.putfo(fh, dst, confirm=confirm)
else:
- self.client.putfo(BytesIO(src), dst)
+ self.client.putfo(BytesIO(src), dst, confirm=confirm)
class SftpClient2(Client):