Exemple #1
0
def RulesInit():
    rules = ""
    try:
        with open(rpieGlobals.FILE_RULES, 'r') as f:
            rules = f.read()
    except:
        pass
    if rules != "":
        #print("Loading rules...")
        commands.splitruletoevents(rules)
    commands.rulesProcessing("System#Boot", rpieGlobals.RULE_SYSTEM)
Exemple #2
0
def RulesInit():
    rules = ""
    try:
        with open(pglobals.FILE_RULES, 'r', encoding="utf8") as f:
            rules = f.read()
    except:
        pass
    try:
        if rules != "":
            print("Loading rules...")
            commands.splitruletoevents(rules)
        commands.rulesProcessing("System#Boot", pglobals.RULE_SYSTEM)
    except Exception as e:
        print("Rule loading error:", str(e))
Exemple #3
0
def handle_rules(httpResponse, responsearr):
    ws.navMenuIndex = 5
    ws.TXBuffer = ""
    httpResponse.WriteResponseOk(headers=({
        'Cache-Control': 'no-cache'
    }),
                                 contentType='text/html',
                                 contentCharset='UTF-8',
                                 content="")
    ws.sendHeadandTail("TmplStd", ws._HEAD)

    rules = ""
    saved = ws.arg("Submit", responsearr)
    if (saved):
        rules = ws.arg("rules", responsearr)
        try:
            with open(pglobals.FILE_RULES, 'w') as f:
                f.write(rules)
        except:
            pass
        if len(rules) > 0:
            commands.splitruletoevents(rules)
    if rules == "":
        try:
            with open(pglobals.FILE_RULES, 'r') as f:
                rules = f.read()
        except:
            pass
    httpResponse._write(ws.TXBuffer, strEncoding='UTF-8')
    ws.TXBuffer = "<form name = 'frmselect' method = 'post'><table class='normal'><TR><TH align='left'>Rules<tr><td><textarea name='rules' rows='30' wrap='off'>{0}</textarea>".format(
        rules)
    ws.addFormSeparator(2)
    ws.addSubmitButton()
    ws.TXBuffer += "</table></form>"

    ws.sendHeadandTail("TmplStd", ws._TAIL)
    httpResponse._write(ws.TXBuffer, strEncoding='UTF-8')
    ws.TXBuffer = ""