def main_loop(): # The Main Loop only ends when the option to reboot is chosen. # In all the Tasks, when the Admin Card is swiped, # the program returns to this Loop, where a new Task # can be selected using the OK and Down Buttons. Disp.initial_display() # if not Tasks.wifi_active(): # make sure that the Terminal is # Tasks.reset_wifi() # connected to a WiFi if not Odoo.user: # make sure that we have Tasks.reset_odoo() # access to an odoo db Tasks.selected() # when the terminal is switched on it goes # to the predefined Task (begin_option) B_OK.pressed = False # avoid false positives B_Down.pressed = False while not Tasks.reboot: Disp.display_msg(Tasks.option_name()) if B_OK.pressed: if Tasks.option_name() in Tasks.ask_twice: ask_twice() else: Tasks.selected() elif B_Down.pressed: Tasks.down() B_Down.scanning() # If no Button was Pressed B_OK.scanning() # continue scanning _logger.debug('Tasks.reboot = ' + str(Tasks.reboot)) Disp.display_msg('shut_down') time.sleep(1.5) Disp.clear_display() os.system('sudo reboot')
def main_loop(): # The Main Loop only ends when the option to reboot is chosen. # In all the Tasks, when the Admin Card is swiped, # the program returns to this Loop, where a new Task # can be selected using the OK and Down Buttons. try: Disp.initial_display() # if not Tasks.wifi_active(): # make sure that the Terminal is # Tasks.reset_wifi() # connected to a WiFi if not Odoo.user: # make sure that we have Tasks.reset_odoo() # access to an odoo db Tasks.selected() # when the terminal is switched on it goes # to the predefined Task (begin_option) B_OK.pressed = False # avoid false positives B_Down.pressed = False while not Tasks.reboot: Disp.display_msg(Tasks.option_name()) if B_OK.pressed: if Tasks.option_name() in Tasks.ask_twice: ask_twice() else: Tasks.selected() elif B_Down.pressed: Tasks.down() _logger.debug("Tasks.reboot = " + str(Tasks.reboot)) B_OK.pressed = False B_Down.pressed = False Disp.display_msg("shut_down") time.sleep(1.5) Disp.clear_display() os.system("sudo reboot") except Exception as e: buff = StringIO() traceback.print_exc(file=buff) _logger.error(buff.getvalue()) raise e
def ask_twice(): # user asked twice before executing -'are you sure?' Buz.Play("OK") Disp.display_msg("sure?") B_OK.pressed = False # avoid false positives B_Down.pressed = False time.sleep(0.4) # allow time to take the finger # away from the button while not (B_OK.pressed or B_Down.pressed): # wait answer pass if B_OK.pressed: # OK pressed for a second time Tasks.selected() # The selected Task is run. # When the Admin Card is swiped # the Program returns here again. else: Buz.Play("down") time.sleep(0.4) # allow time to take the finger # away from the button B_OK.pressed = False # avoid false positives B_Down.pressed = False