def email_test(self): ''' Test the email settings, and return the result.''' email_from = request.forms.get('email_from') email_to = request.forms.get('email_to').split(',') passw = request.forms.get('email_pswd') smtp = request.forms.get('smtp') try: problems = sendemail(email_from, email_to, [], 'Test email from the sprinkler', "This test was apparently successful", email_from, passw, smtp) if len(problems.items()) == 0: return "Test successful" except SMTPAuthenticationError as ae: return "SMTPAuthenticationError: username '%s' and password don't match" % email_from except SMTPResponseException as re: return "SMTP Exception (%d): %s" % (re.smtp_code, re.smtp_error) except SMTPRecipientsRefused as rr: return "Problem with recipient (%s):" % email_to except socket.error as err: return "Error connecting to '%s'" % smtp + " maybe you need the port (like smtp.gmail.com:587)" self.log.info("Successful Email Test"); return str(problems)
def actuateZone(self, active_zone): if active_zone is None: self.log.info("Turning off the sprinklers") else: self.log.info('setting new zone to %s, "%s"', str(active_zone), zones[active_zone][1]) if self.previous_zone is not None: self.hwio.output(zones[self.previous_zone][0], True) if active_zone is not None: self.hwio.output(zones[active_zone][0], False) if active_zone is None: sendemail( settings.Get("email_from"), settings.Get("email_to").split(","), [], "Sprinklers ran", "", settings.Get("email_from"), settings.Get("email_passw"), ) self.previous_zone = active_zone