Refactored csv_to_email.py and added basic logging - much more work needed

This commit is contained in:
2025-01-02 00:18:46 +13:00
parent 0ab33b9bad
commit 59d9efe4bd
2 changed files with 40 additions and 34 deletions

View File

@@ -110,7 +110,8 @@ def process_attachments(mailbox, attachment_path, saved_hashes):
f"{file_ext}"
)
with tempfile.NamedTemporaryFile(delete=False, dir="temp") as temp_file:
with tempfile.NamedTemporaryFile(
delete=False, dir="temp") as temp_file:
temp_file.write(att.payload)
temp_path = temp_file.name
final_path = os.path.join(attachment_path, final_name)
@@ -140,8 +141,11 @@ def main():
sys.exit(1)
attachment_path = join(dirname(__file__), "attachments")
temp_path = join(dirname(__file__), "temp")
if not os.path.exists(attachment_path):
os.makedirs(attachment_path)
if not os.path.exists(temp_path):
os.makedirs(temp_path)
ssl_context = setup_ssl_context()