I have a Simple PythonCaller code to delete all .gdb files is a directory
import os
import time
# Define the directory and the age limit
directory = r"../../../10_9_1"
age_limit_days = 1
current_time = time.time()
# Calculate the age limit in seconds
age_limit_seconds = age_limit_days * 24 * 60 * 60
# Iterate through the files in the directory
for filename in os.listdir(directory):
if filename.endswith('.gdb'):
file_path = os.path.join(directory, filename)
file_age = current_time - os.path.getmtime(file_path)
# Check if the file is older than the age limit
if file_age > age_limit_seconds:
try:
os.remove(file_path) # Delete the file
print(f"Deleted: {filename}")
except Exception as e:
print(f"Error deleting {filename}: {e}")
Now using FME Flow(Server) I want to send an email based the Result of this code
If there was a .gdb file to be deleted! then I need to get and expose the name of the deleted file and send it to automation email system and eventually send an email to end users
If there is no file to be deleted! or there is an exception then send an email with a message of there is no file to be delete
Thanks