示例#1
0
cgitb.enable()

logger = setupSecurityLogger()

print "Content-type: text/html\n\n"

currentAlarmCode = getCurrentAlarmCode()
if currentAlarmCode is not None and currentAlarmCode is not "":
    existingCode = ""
    arguments = cgi.FieldStorage()
    if "existingcode" in arguments:
            existingCode = arguments["existingcode"].value
            if hashlib.md5(existingCode).hexdigest() != currentAlarmCode:
                print "existingcode does not match with what is set. Cannot update code."
                sys.exit(1)
    else:
        print "No existingcode queryparam specified. Cannot update code."
        sys.exit(1)

code = ""
arguments = cgi.FieldStorage()
if "code" in arguments:
    code = arguments["code"].value
    if code is not None:
        setAlarmCode(code)
        print "Alarm Code is set."
    else:
        print "No code specified. Nothing to set."
else:
    print "No code specified. Nothing to set."
示例#2
0
def setCode(alarmCode):
    setAlarmCode(alarmCode)
    logger.info("Alarm code has been updated.")
示例#3
0
def setCode(alarmCode):
    setAlarmCode(alarmCode)
    logger.info("Alarm code has been updated.")
示例#4
0
cgitb.enable()

logger = setupSecurityLogger()

print "Content-type: text/html\n\n"

currentAlarmCode = getCurrentAlarmCode()
if currentAlarmCode is not None and currentAlarmCode is not "":
    existingCode = ""
    arguments = cgi.FieldStorage()
    if "existingcode" in arguments:
        existingCode = arguments["existingcode"].value
        if hashlib.md5(existingCode).hexdigest() != currentAlarmCode:
            print "existingcode does not match with what is set. Cannot update code."
            sys.exit(1)
    else:
        print "No existingcode queryparam specified. Cannot update code."
        sys.exit(1)

code = ""
arguments = cgi.FieldStorage()
if "code" in arguments:
    code = arguments["code"].value
    if code is not None:
        setAlarmCode(code)
        print "Alarm Code is set."
    else:
        print "No code specified. Nothing to set."
else:
    print "No code specified. Nothing to set."