def post(self): formType = flask.request.form.get('formType') digitPass = "" if formType == "digitPassword" or "shutdown": required = [ 'firstdigit', 'seconddigit', 'thirddigit', 'fourthdigit' ] for r in required: digitPass += flask.request.form.get(r) if str(digitPass) == str(database().getFourDigit()): state = database().getState() if formType == "shutdown": if state == "True": flask.flash("Disarm system before shutting down!") return flask.redirect(flask.url_for('tongles')) else: print "Shutting Down..." database().writeLogs("System has been shutted down") shutdown() elif formType == "digitPassword": if state == "True": status().disarm() else: status().arm() else: flask.flash( "Something went totally wrong here, please try again!") return flask.redirect(flask.url_for('tongles')) else: flask.flash("Incorect Password, please try again!") return flask.redirect(flask.url_for('tongles'))
def keypads(): last_digit = None while True: list1 = [] #Initialize an empty list digit = None while len(list1) < 4: #The length of the passcode will be 4 digits while digit == last_digit or digit is None: #With this loop I prevent multiple press of a number digit = keypad().getKey() if digit is None: last_digit = None list1.append(digit) interact().button_Pressed() attempt = "".join(map(str, list1)) lcd.clear() lcd.message("Please type your\nPasscode: " + "*" * len(attempt)) last_digit = digit print "Given Passcode:", attempt #Verrification of the passcode if (attempt == passcode): sys_status = (database().getState()) print "Status:", sys_status if (sys_status == "True"): #systatusem was armed, disarm it status().disarm() else: status().arm() else: lcd.clear() lcd.message("Wrong Passcode!") os.system('mpg321 -q /home/pi/HomeSecPi/Speech/wrongpass.mp3 &') database().writeLogs("Wrong passcode has been given on the keypad") interact().indication() interact().askPass() time.sleep(0.5)
def power(): prevMode = status().pwr_mode() while True: currMode = status().pwr_mode() if prevMode != currMode: if currMode == "External Cable Powering (EPR)": os.system('mpg321 -q /home/pi/HomeSecPi/Speech/epr.mp3 &') lcd.clear() lcd.message("External Cable\nPowering (EPR)") time.sleep(3) elif currMode == "USB Cable Powering": os.system('mpg321 -q /home/pi/HomeSecPi/Speech/usb.mp3 &') lcd.clear() lcd.message("USB Cable\nPowering") time.sleep(3) elif currMode == "Raspberry Pi Powering": os.system('mpg321 -q /home/pi/HomeSecPi/Speech/pi.mp3 &') lcd.clear() lcd.message("Raspberry Pi\nPowering") time.sleep(3) elif currMode == "Battery Powering": os.system('mpg321 -q /home/pi/HomeSecPi/Speech/battery.mp3 &') lcd.clear() lcd.message("Battery\nPowering") time.sleep(3) elif currMode == "Battery Low Powering": os.system( 'mpg321 -q /home/pi/HomeSecPi/Speech/battery_low.mp3 &') lcd.clear() lcd.message("Battery Low\nPowering") time.sleep(3) elif currMode == "CPR Mode": os.system('mpg321 -q /home/pi/HomeSecPi/Speech/cpr.mp3 &') lcd.clear() lcd.message("Running on\nCPR Mode") time.sleep(3) elif currMode == "BPR Mode": os.system('mpg321 -q /home/pi/HomeSecPi/Speech/bpr.mp3 &') lcd.clear() lcd.message("Running on\nBPR Mode") time.sleep(3) else: os.system('mpg321 -q /home/pi/HomeSecPi/Speech/error.mp3 &') lcd.clear() lcd.message("Power Reading\nError!") time.sleep(3) print "Power source has been changed" database().writeLogs("Power source has been changed to " + currMode) interact().askPass() prevMode = currMode time.sleep(1)
def get(self): return flask.render_template('tongles.html', status=getStatus(), temp=GetTemp(), inIP=GetInIP(), exIP=GetExIP(), pmode=status().pwr_mode())
atividade = fn.menu(moedas) #1.Alimentar # 2.Armário # 3.loja # 4.Médico # 5.Dormir # 6.Passear # 7. Status if atividade == "1": fome, estoque = fn.alimentar(fome, estoque, moedas) elif atividade == "2": fn.armario(estoque) elif atividade == "3": moedas, estoque = fn.comprar(moedas, estoque) elif atividade == "4": saude, moedas = fn.irAoMedico(saude, moedas) elif atividade == "5": saude, fome, social = fn.dormir(saude, fome, social, moedas) elif atividade == "6": print("Passear") elif atividade == "7": fn.status(saude, fome, social, risco, vacina, moedas)
MESSAGE = "Second Dungeon Complete!" func.achievement(USER, 15, 100, MESSAGE) func.clear() BOSS = func.boss_battle(USER, C.map2_boss) if BOSS == 1: func.travel_map(USER, maps.map2, maps.desc2) else: pass func.output(messages.end_level2) func.travel_map(USER, maps.map3, maps.desc3) func.clear() MESSAGE = "Third Dungeon Complete!" func.achievement(USER, 50, 225, MESSAGE) func.clear() BOSS = func.boss_battle(USER, C.map3_boss) if BOSS == 1: func.travel_map(USER, maps.map3, maps.desc3) else: pass #################################################### func.output(messages.endgame) func.status(USER) func.clear()