41 lines
1.4 KiB
Python
41 lines
1.4 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
This is called unprocessed files, but it's really files that went through processing
|
|
We can tell there's a problem if the same files are reprocessing over and over, this is
|
|
more of an alert to show that something is happening.
|
|
"""
|
|
# pylint: disable=too-many-instance-attributes
|
|
import pathlib
|
|
import smtplib
|
|
from email.mime.multipart import MIMEMultipart
|
|
from email.mime.text import MIMEText
|
|
|
|
import records # type: ignore
|
|
|
|
THIS_DIRECTORY = pathlib.Path(__file__).parent
|
|
X12_DIRECTORY = THIS_DIRECTORY / "incoming"
|
|
|
|
|
|
def main():
|
|
edi_types = {}
|
|
for edi_filename in X12_DIRECTORY.iterdir():
|
|
if edi_filename.name.endswith('.edi'):
|
|
edi_file_type = edi_filename.name[:3]
|
|
if edi_file_type not in edi_types:
|
|
edi_types[edi_file_type] = 1
|
|
else:
|
|
edi_types[edi_file_type] += 1
|
|
|
|
if edi_types:
|
|
msg = MIMEMultipart()
|
|
msg['Subject'] = 'Shandex Files'
|
|
msg['Precedence'] = 'bulk'
|
|
msg['From'] = 'x3report@stashtea.com'
|
|
msg['To'] = 'bleeson@stashtea.com'
|
|
emailtext = str(edi_types)
|
|
msg.attach(MIMEText(emailtext, 'plain'))
|
|
with smtplib.SMTP_SSL("smtp.gmail.com", 465) as smtp:
|
|
smtp.login(user='x3reportmk2@yamamotoyama.com', password=r'n</W<7fr"VD~\2&[pZc5')
|
|
smtp.send_message(msg)
|
|
if __name__ == "__main__":
|
|
main() |