37 lines
1.1 KiB
Python
37 lines
1.1 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Shandex version, check for unprocessed EDI files and alert
|
|
that there is a problem of some kind, all files should move out of
|
|
these folders for each run of master controller
|
|
"""
|
|
import pprint
|
|
import pathlib
|
|
import simple_email_notification
|
|
|
|
#The directories we want to check for a leftover file
|
|
THIS_DIRECTORY = pathlib.Path(__file__).parent
|
|
OUTGOING_DIRECTORY = THIS_DIRECTORY / 'outgoing'
|
|
INCOMING_DIRECTORY = THIS_DIRECTORY / 'incoming'
|
|
|
|
MONITOR_LIST = [OUTGOING_DIRECTORY, INCOMING_DIRECTORY]
|
|
|
|
def main():
|
|
"""
|
|
Check for leftover files which means something unexpected happened.
|
|
"""
|
|
file_count = []
|
|
for path in MONITOR_LIST:
|
|
for file in path.iterdir():
|
|
if file.name[-4:] == '.edi' or file.name[-4:] == '.txt':
|
|
file_count.append(f'{path}\\{file.name}')
|
|
if file_count:
|
|
simple_email_notification.email_noticication(
|
|
['bleeson@stashtea.com','icarrera@yamamotoyama.com'],
|
|
'Shandex EDI leftover files',
|
|
file_count
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|