Exemplo n.º 1
0
def crux(*args):
    logger.info('AutoStateSet: If Current State has been ' + args[1] +
                ' for more than ' + args[2] + ' seconds then set state to: ' +
                args[3])

    processArguments()
    if (len(sys.argv) > 4):
        if (args[4].lower() == 'false'):
            persistent = isPersistent()
            if persistent:
                logger.info(
                    "AutoStateSet will not set state since persistent is enabled."
                )
                return 0

    alarmState = getCurrentAlarmState()
    if (alarmState == args[1]):
        lastStateChangeTimeDelta = getLastStateChangeTimeDelta()
        secondsInCurrentState = lastStateChangeTimeDelta.total_seconds()
        if (secondsInCurrentState > int(args[2])):
            logger.info('AutoStateSet: Current State has been ' + alarmState +
                        ' for ' + str(secondsInCurrentState) +
                        ' seconds. Auto setting state to: ' + args[3])
            setAlarmState(args[3])
        else:
            logger.info(
                "AutoStateSet will not set state since current state has been "
                + alarmState + ' for only ' + str(secondsInCurrentState) +
                ' seconds')
    else:
        logger.info("AutoStateSet will not set state since current state is " +
                    alarmState)
    return 0
Exemplo n.º 2
0
def crux(*args):
    logger.info('AutoStateSet: If Current State has been ' + args[1] + ' for more than ' + args[2] + ' seconds then set state to: ' + args[3])

    processArguments()
    if (len(sys.argv) > 4):
        if (args[4].lower() == 'false'):
            persistent = isPersistent()
            if persistent:
                logger.info("AutoStateSet will not set state since persistent is enabled.")
                return 0

    alarmState = getCurrentAlarmState()
    if (alarmState == args[1]):
        lastStateChangeTimeDelta = getLastStateChangeTimeDelta()
        secondsInCurrentState = lastStateChangeTimeDelta.total_seconds()
        if (secondsInCurrentState > int(args[2])):
            logger.info('AutoStateSet: Current State has been ' + alarmState + ' for ' + str(secondsInCurrentState) + ' seconds. Auto setting state to: ' + args[3])
            setAlarmState(args[3])
        else:
            logger.info("AutoStateSet will not set state since current state has been " + alarmState + ' for only ' + str(secondsInCurrentState) + ' seconds')
    else:
        logger.info("AutoStateSet will not set state since current state is " + alarmState)
    return 0
Exemplo n.º 3
0
from SecurityUtils import getCurrentAlarmState,isPanic,getLastStateChangeTime,getLastPanicTime,getLastAlertTime,getPreviousAlarmState,getDesiredAlarmState,getDesiredAlarmStateDelay,getAlertPanicTime,getGuiUpdateTime,isPersistent

from LoggerUtils import setupSecurityLogger
import cgi, cgitb
from controlpanel import getBaseUrl

cgitb.enable()

logger = setupSecurityLogger()

alarmState = getCurrentAlarmState()
alarmPanic = isPanic()
report = ""
report += "Alarm State: " + alarmState + "\n"
report += "Alarm Panic: " + str(alarmPanic) + "\n"
report += "Persistence: " + str(isPersistent()) + "\n"
report += "Last Panic time: " + str(getLastPanicTime()) + "\n"
report += "Last Alert time: " + str(getLastAlertTime()) + "\n"
report += "Last State Change time: " + str(getLastStateChangeTime()) + "\n"
report += "Previous State: " + str(getPreviousAlarmState()) + "\n"
report += "Desired State: " + str(getDesiredAlarmState()) + "\n"
report += "Desired State Delay: " + str(getDesiredAlarmStateDelay()) + "\n"
report += "Alert will become panic at: " + str(getAlertPanicTime()) + "\n"
report += "GUI needs to be updated last at: " + str(getGuiUpdateTime()) + "\n\n"

print 'Content-Type: text/html'
print # HTTP says you have to have a blank line between headers and content
print '<html>'
print '  <head>'
print '    <title> Detail Alarm Status </title>'
print '  </head>' 
Exemplo n.º 4
0
     print '      <br><br>'
 print '      <h3> Panic/UnPanic</h3>'
 color = ""
 if isPanic():
     #color = "color:red;border-style:inset;"
     color = "color:red;"
 print '      <button type="button" id="PANIC" onClick=\'panic("PANIC")\' style="' + color + 'font: bold 60px Arial">PANIC</button>'
 print '      <br><br>'
 print '      <button type="button" id="UNPANIC" onClick=\'panic("UNPANIC")\' style="font: bold 60px Arial">UNPANIC</button>'
 print '      Alarm Code:'
 print '      <input type="password" id="AlarmCodeUnpanic" style="font: bold 60px Arial" maxlength="10" size="8">'
 print '      <br><br>'
 print '      </form>'
 print '      <h3>Advanced Features</h3>'
 color = ""
 if isPersistent():
     #color = "color:red;border-style:inset;"
     color = "color:red;"
 print '      <button type="button" id="PERSISTENT" onClick=\'persistent()\' style="' + color + 'font: bold 60px Arial">PERSISTENT</button>'
 print '      <br><br>'
 print '      <h3> Detailed Status</h3>'
 print '      <button id="ALARMSTATUS" onClick="window.location=\'' + getBaseUrl(
 ) + '/raspwave/alarmstatus.py\'" style="font: bold 30px Arial">Alarm Status</button>'
 print '      <button id= "DETAILALARMSTATUS" onClick="window.location=\'' + getBaseUrl(
 ) + '/raspwave/detailalarmstatus.py\'" style="font: bold 30px Arial">Detail Alarm Status</button>'
 print '      <br><br>'
 print '      <button iD="NODEREPORT" onClick="window.location=\'' + getBaseUrl(
 ) + '/raspwave/nodereport.py\'" style="font: bold 30px Arial">Node Report</button>'
 print '      <button iD="DETAILNODEREPORT" onClick="window.location=\'' + getBaseUrl(
 ) + '/raspwave/detailnodereport.py\'" style="font: bold 30px Arial">Detail Node Report</button>'
 print '    </div>'
Exemplo n.º 5
0
from SecurityUtils import getCurrentAlarmState, isPanic, getLastStateChangeTime, getLastPanicTime, getLastAlertTime, getPreviousAlarmState, getDesiredAlarmState, getDesiredAlarmStateDelay, getAlertPanicTime, getGuiUpdateTime, isPersistent

from LoggerUtils import setupSecurityLogger
import cgi, cgitb
from controlpanel import getBaseUrl

cgitb.enable()

logger = setupSecurityLogger()

alarmState = getCurrentAlarmState()
alarmPanic = isPanic()
report = ""
report += "Alarm State: " + alarmState + "\n"
report += "Alarm Panic: " + str(alarmPanic) + "\n"
report += "Persistence: " + str(isPersistent()) + "\n"
report += "Last Panic time: " + str(getLastPanicTime()) + "\n"
report += "Last Alert time: " + str(getLastAlertTime()) + "\n"
report += "Last State Change time: " + str(getLastStateChangeTime()) + "\n"
report += "Previous State: " + str(getPreviousAlarmState()) + "\n"
report += "Desired State: " + str(getDesiredAlarmState()) + "\n"
report += "Desired State Delay: " + str(getDesiredAlarmStateDelay()) + "\n"
report += "Alert will become panic at: " + str(getAlertPanicTime()) + "\n"
report += "GUI needs to be updated last at: " + str(
    getGuiUpdateTime()) + "\n\n"

print 'Content-Type: text/html'
print  # HTTP says you have to have a blank line between headers and content
print '<html>'
print '  <head>'
print '    <title> Detail Alarm Status </title>'
Exemplo n.º 6
0
     print '      <br><br>'
 print '      <h3> Panic/UnPanic</h3>'
 color = ""
 if isPanic():
     #color = "color:red;border-style:inset;" 
     color = "color:red;" 
 print '      <button type="button" id="PANIC" onClick=\'panic("PANIC")\' style="' + color + 'font: bold 60px Arial">PANIC</button>'
 print '      <br><br>'
 print '      <button type="button" id="UNPANIC" onClick=\'panic("UNPANIC")\' style="font: bold 60px Arial">UNPANIC</button>'
 print '      Alarm Code:'
 print '      <input type="password" id="AlarmCodeUnpanic" style="font: bold 60px Arial" maxlength="10" size="8">' 
 print '      <br><br>'
 print '      </form>'
 print '      <h3>Advanced Features</h3>'
 color = ""
 if isPersistent():
     #color = "color:red;border-style:inset;" 
     color = "color:red;" 
 print '      <button type="button" id="PERSISTENT" onClick=\'persistent()\' style="' + color + 'font: bold 60px Arial">PERSISTENT</button>'
 print '      <br><br>'
 print '      <h3> Detailed Status</h3>'
 print '      <button id="ALARMSTATUS" onClick="window.location=\'' + getBaseUrl() + '/raspwave/alarmstatus.py\'" style="font: bold 30px Arial">Alarm Status</button>'
 print '      <button id= "DETAILALARMSTATUS" onClick="window.location=\'' + getBaseUrl() + '/raspwave/detailalarmstatus.py\'" style="font: bold 30px Arial">Detail Alarm Status</button>'
 print '      <br><br>'
 print '      <button iD="NODEREPORT" onClick="window.location=\'' + getBaseUrl() + '/raspwave/nodereport.py\'" style="font: bold 30px Arial">Node Report</button>'
 print '      <button iD="DETAILNODEREPORT" onClick="window.location=\'' + getBaseUrl() + '/raspwave/detailnodereport.py\'" style="font: bold 30px Arial">Detail Node Report</button>'
 print '    </div>'
 print '  <style>'
 print '    html, body {'
 print '      height: 100%;'
 print '      width: 100%;'
Exemplo n.º 7
0
#!/usr/bin/python -u
# @author rouble matta

import sys
sys.path.append('/etc/raspwave/pylib')
from SecurityUtils import isPersistent
import cgi, cgitb

cgitb.enable()

if __name__ == '__main__':
    print 'Content-Type: text/html'
    print ''
    print isPersistent()