コード例 #1
0
def main(blocking=True):
    # FIXME: check for all ports (unix, js, stm)
    # what is available in os module
    # maybe we can check it without try-except
    try:
        os.mkdir(storage_root)
    except:
        pass
    # schedules display autoupdates if blocking=False
    # it may cause GUI crashing when out of memory
    # but perfect to debug
    gui.init(blocking)
    ret = Secret.load_secret()
    if ret == False:
        Secret.generate_secret()
    screens.ask_pin(not ret, show_init)
    if blocking:
        ioloop()
コード例 #2
0
 def cb(obj, event):
     nonlocal first_time_usage
     if event == lv.EVENT.RELEASED:
         c = obj.get_active_btn_text()
         if c is None:
             return
         if c == lv.SYMBOL.CLOSE:
             pin_lbl.set_text("")
             antiphish_label.set_text(antiphishing_word(""))
         elif c == lv.SYMBOL.OK:
             # FIXME: check PIN len
             Key.generate_key(pin_lbl.get_text())
             if first_time_usage:
                 Secret.save_secret(alert)
                 callback()
             else:
                 Pin.counter -= 1
                 Pin.save_counter(alert)
                 if Pin.is_pin_valid():
                     Pin.reset_counter(alert)
                     callback()
                 else:
                     instruct_label.set_text(
                         "#f07070 Wrong pin: %d/%d #" %
                         (Pin.counter, Pin.ATTEMPTS_MAX))
                     if Pin.counter <= 0:
                         Factory_settings.restore(alert)
                         Secret.generate_secret()
                         alert("Security", "Device has been factory reset!")
                         first_time_usage = True
                         title_lbl.set_text(first_time_title)
                         instruct_label.set_text(instruct_txt)
             pin_lbl.set_text("")
             antiphish_label.set_text(antiphishing_word(""))
         else:
             instruct_label.set_text(instruct_txt)
             pin_lbl.add_text(c)
             word = antiphishing_word(pin_lbl.get_text())
             antiphish_label.set_text(antiphish_label.get_text() + " " +
                                      word)