0

I'm new to python, and am programming on a Raspberry Pi. I created this script that I want to send an email at a certain time of day (i.e. 6am). I already have the email portion of the script functional, all that is left is the automation of the email.

I figured the best way to do this was to put it in a if-statement. I'm using the import timedate for the time functionality. Here is what I have of the if-statement:

import smtplib
import datetime
import time

now = date time.datetime.now()
morning = 6
noon = 12
afternoon = 18

if datetime.time.hour(6) == morning or datetiem.time.hour(12) == noon or datetime.time.hour(18) == afternoon:

# Email code here #

When I run it currently, I get a TypeError: 'getset_discriptor' is not callable. Because i'm new to Python, I have no idea really how to fix this, so any help is much appreciated!

Connor Bailey
  • 69
  • 1
  • 13
  • Is there a reason you don't want to / cannot use cron to run your jobs? Simply adding the time into your script will only work if you are constantly running the script (it's not a daemon). Check out this instead: https://www.raspberrypi.org/documentation/linux/usage/cron.md – Karen Clark Mar 08 '16 at 00:06
  • @KarenClark I haven't checked out cron yet, I'll give that a look over and see if it's worth using. The Raspberry Pi is always going to be powered on and unhooked from a monitor when it runs these tasks, so I don't mind if the program is always running. Right now it's only using about 30% of the CPU overclocked to 950MHz while this program is running, so it shouldn't be a problem to leave running. – Connor Bailey Mar 08 '16 at 00:10
  • While you could run your python script to do this, it's not necessarily meant for that, whereas cron is. The nice thing about cron is it's "ancient" and therefore most problems with it have been solved. :) – Karen Clark Mar 08 '16 at 00:13

0 Answers0