Esempio n. 1
0
def sendEmail (emailAddresses, subject="no subject", body="no body", logger=setupRobotLogger()):
    for emailAddress in emailAddresses:
        logger.info("Sending email to " + emailAddress)
        p1 = subprocess.Popen(['/bin/echo', body], stdout=subprocess.PIPE) #Set up the echo command and direct the output to a pipe
        p2 = subprocess.Popen(['/usr/bin/mail', '-s', '[raspwave-alarm] ' + subject, emailAddress], stdin=p1.stdout) #send p1's output to p2
        p1.stdout.close() #make sure we close the output so p2 doesn't hang waiting for more input
        output = p2.communicate()[0] #run our commands
Esempio n. 2
0
def sendEmail(emailAddresses,
              subject="no subject",
              body="no body",
              logger=setupRobotLogger()):
    for emailAddress in emailAddresses:
        logger.info("Sending email to " + emailAddress)
        p1 = subprocess.Popen(
            ['/bin/echo', body], stdout=subprocess.PIPE
        )  #Set up the echo command and direct the output to a pipe
        p2 = subprocess.Popen([
            '/usr/bin/mail', '-s', '[raspwave-alarm] ' + subject, emailAddress
        ],
                              stdin=p1.stdout)  #send p1's output to p2
        p1.stdout.close(
        )  #make sure we close the output so p2 doesn't hang waiting for more input
        output = p2.communicate()[0]  #run our commands
Esempio n. 3
0
#!/usr/bin/env python
# @author rouble matta

import sys
from RobotUtils import sendEmail
from SecurityUtils import getCurrentAlarmState
from ConfUtils import getNodeName,getMailto,isDoorWindowOrMotion
from Notification import *
from NotificationHandler import getNotificationFromNodeById,getNodeReport
from Utils import getTimeElapsed_HHMMSS
from SensorUtils import getSensorState
from LoggerUtils import setupRobotLogger

logger = setupRobotLogger()
mailto = getMailto()

# Always send an email, regardless of armed state
def EmailAlertAlways(nodeId, current, previous):
    name = getNodeName(nodeId)
    alarmState = getCurrentAlarmState()
    subject = "[" + str(alarmState) + "] " + str(name) + " is " + getSensorState(current.value) + " at " + str(current.time)
    body = name + " had been " + getSensorState(previous.value) + " for " + getTimeElapsed_HHMMSS(previous.time) + ".\n\n"
    body += "Current: " + str(current) + "\n"
    body += "Previous: " + str(previous) + "\n"
    body += getNodeReport(nodeId)
    sendEmail(mailto, subject, body);

def crux(*args):
    if not isDoorWindowOrMotion(args[2]):
        return 1
Esempio n. 4
0
def robotSleep(seconds, logger=setupRobotLogger()):
    secondsInt = int(seconds)
    while (secondsInt):
        logger.info("Sleeping for " + str(secondsInt) + " seconds")
        sleep(1)
        secondsInt -= 1
Esempio n. 5
0
def robotSleep (seconds, logger=setupRobotLogger()):
    secondsInt = int(seconds)
    while (secondsInt):
        logger.info("Sleeping for " + str(secondsInt) + " seconds")
        sleep(1)
        secondsInt -= 1