コード例 #1
0
ファイル: unpanic.py プロジェクト: roubles/raspwave2
#!/usr/bin/env python
# @author rouble matta

import os
import sys
sys.path.append('/etc/raspwave/pylib')
from LoggerUtils import setupSecurityLogger
from alarmcode import testCode
import cgi, cgitb
cgitb.enable()

logger = setupSecurityLogger()

if __name__ == '__main__':
    print 'Content-Type: text/html'
    print # HTTP says you have to have a blank line between headers and content
    (retVal,code) = testCode(cgi.FieldStorage())
    if retVal == 1:
        logger.info("Invalid code [" + code + "]. Cannot unpanic without code.")
        print "Invalid code [" + code + "]. Cannot unpanic without code."
    elif retVal == 2:
        logger.info("No code queryparam specified (but code is set). Cannot unpanic without code.")
        print "No code queryparam specified (but code is set). Cannot unpanic without code."
    elif retVal == 0:
        logger.info("No alarm code set. Unpanic without code.")
        print "No alarm code set. Unpanic without code."
    elif retVal == 3:
        logger.info("Valid code. Unpanic-ing...")
        print "Valid code. Unpanic-ing..."

    if retVal == 0 or retVal == 3:
コード例 #2
0
ファイル: SecurityUtils.py プロジェクト: roubles/raspwave2
import ConfigParser
import datetime
from CacheUtils import readStringValue, writeStringValue
from ConfUtils import getConfValue, getMailto, getSirens, getPanicMailto
from RobotUtils import sendEmail
from NotificationHandler import getNodeReport
from Utils import getNowStr, convert_timedelta_str, secondsLeftFromString
from UserSpecific import beep, longbeep
from setBoolValue import setBoolValue
from time import sleep
import threading
import hashlib
from LoggerUtils import setupSecurityLogger

logger = setupSecurityLogger()

alarmStateKey = "ALARM_STATE"
alarmDesiredStateKey = "ALARM_DESIRED_STATE"
alarmDesiredStateDelay = "ALARM_DESIRED_STATE_DELAY"
alarmPreviousStateKey = "ALARM_PREVIOUS_STATE"
alarmCodeKey = "ALARM_CODE"
alarmPanicKey = "ALARM_PANIC"
statePersistentKey = "STATE_PERSISTENT"
lastPanicTimeKey = "LAST_PANIC_TIME"
lastAlertTimeKey = "LAST_ALERT_TIME"
alertPanicTimeKey = "ALERT_PANIC_TIME"
guiUpdateTimeKey = "GUI_UPDATE_TIME"
lastStateChangeTimeKey = "LAST_STATECHANGE_TIME"
ignoreRePanicWithinSeconds = 30