aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/mtm_status.py14
1 files changed, 6 insertions, 8 deletions
diff --git a/python/mtm_status.py b/python/mtm_status.py
index 2ac2fe78..533b6e40 100644
--- a/python/mtm_status.py
+++ b/python/mtm_status.py
@@ -17,21 +17,19 @@ def latest(f):
def get_latest_file(date):
try:
sftp = SftpClient.from_creds("mtm")
- except (
- AuthenticationException,
- SSHException,
- ) as e:
+ except (AuthenticationException, SSHException) as e:
logger.warning(e)
return
+
files = [
f
for f in sftp.client.listdir("outbound")
- if date.strftime("%m%d%Y") in f
- if "mtm" in f
+ if date.strftime("%m%d%Y") in f and "mtm" in f
]
if not files:
return
- target_file = max(files, key=latest)
+
+ target_file = max(files, key=lambda x: int(x.split("_")[-1].split(".")[0]))
with sftp.client.open(f"outbound/{target_file}") as sftp_handle:
with ZipFile(sftp_handle).open(target_file.removesuffix(".zip")) as zip_handle:
df = pd.read_csv(zip_handle, skiprows=2, na_filter=False)
@@ -41,7 +39,7 @@ def get_latest_file(date):
def run(conn, date):
df = get_latest_file(date)
- if df.empty:
+ if df is None or df.empty:
return
df = df[
(df["SwapType"].isin(["NEW", "ASGM", "TERM"]))