Jun-06-2019, 11:29 PM
@snippsat I REALLY appreciate your detailed response. I tried adopting your example in my script and received the following-
[INFO] starting cameras... Traceback (most recent call last): File "/home/pi/Public/2Cameras.py", line 64, in <module> send_mail(frame=frame) File "/home/pi/Public/send_mail.py", line 30, in send_mail datetime.datetime(2019, 3, 11, 0, 0) AttributeError: type object 'datetime.datetime' has no attribute 'datetime' >>>This was the code-
def send_mail(frame): path = os.path.dirname(sys.argv[0]) log_file = path + '/email.log' # Check if the last email was sent in an 1 minute tolerance. # We are going to use a .log file to keep track of it. if os.path.isfile(log_file): # First check if file exists. with open(log_file, 'r') as f: date = '2019-03-11' date_to_datetime = datetime.strptime(date, "%Y-%m-%d") datetime.datetime(2019, 3, 11, 0, 0) if datetime.now() < date_to_datetime + timedelta(minutes=1): return # Update the email log. with open(log_file, 'w') as f: f.write(str(datetime.now()))