This script works when i call it from the command line, but when i have "Motion" call it following the save of a jpg to my PI, it only sends the emails.
I'm mostly get about 10 jpgs, for each event, so wondered if the script was being upset by being called again whilst running. Just a hunch, but how could i test for this, and possibly rectify?
#!/usr/bin/env python
import smtplib
import time
import subprocess
from email.mime.text import MIMEText
USERNAME = ""
PASSWORD = ""
MAILTO = ""
msg = MIMEText('blar blar')
msg['Subject'] = 'from pi script test1'
msg['From'] = USERNAME
msg['To'] = MAILTO
server = smtplib.SMTP('smtp.gmail.com:587')
server.ehlo_or_helo_if_needed()
server.starttls()
server.ehlo_or_helo_if_needed()
server.login(USERNAME,PASSWORD)
server.sendmail(USERNAME, MAILTO, msg.as_string())
server.quit()
time.sleep(20)
subprocess.call("cp /mnt/*.jpg /home/pi/box/pi_pictures", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)