Esempio n. 1
0
 def end_menu():
     selection = input()
     if selection == 'r':
         os.system("sudo reboot")
     if selection == 'e':
         json_dump()  # todo only to soft
         sys.exit()
     if selection == 'c':
         conf_ota()
         end_update()
     if selection == 's':
         clear_the_screen()
         os.chdir(f"/home/{user}/RH-ota")
         os.system(". ./open_scripts.sh; server_start")
     else:
         end_menu()
Esempio n. 2
0
def main_menu(config):
    while True:
        clear_the_screen()
        logo_top(config.debug_mode)
        config_check()
        main_menu_content = """
        
                    {red}{bold}{underline}MAIN MENU{endc}{blue}{bold}
                    
                             
                        1 - RotorHazard Manager
                            
                        2 - Nodes flash and update {endc}{bold}
                            
                        3 - Start the server now
                            
                        4 - Additional features
                            
                        5 - Info + first time here
                            
                        6 - Configuration wizard {endc}{yellow}
                            
                        e - Exit {endc}
                            
                """.format(bold=Bcolors.BOLD_S,
                           underline=Bcolors.UNDERLINE,
                           endc=Bcolors.ENDC,
                           blue=Bcolors.BLUE,
                           yellow=Bcolors.YELLOW_S,
                           red=Bcolors.RED_S)
        print(main_menu_content)
        selection = input()
        if selection == '1':
            print("todo: call rpi_update")
            # rpi_update(config) #TODO modulalize rpi-update
            # os.system("python3 ./rpi_update.py")  # opens raspberry updating file
        if selection == '2':
            print("todo: call node_update")
            # nodes_update(config) #TODO modulalize node-update (i2c_ !)
            # os.system("python3 ./nodes_update.py")  # opens nodes updating file
        if selection == '3':
            clear_the_screen()
            os.system(". ./scripts/server_start.sh")
        if selection == '4':
            features_menu(config)
        if selection == '5':
            first_time()
        if selection == '6':
            config = conf_ota(config)
        if selection == 'logme':
            log_to_dev(config)
        if selection == 'e':
            end()
Esempio n. 3
0
def show_about(config):
    while True:
        clear_the_screen()
        welcome_first_page = """{bold}  

    Please configure OTA software using a wizard after reading this page.

    This wizard will configure OTA software, not RotorHazard server itself. 
    Things like amount of LEDs or RotorHazard password should be configured 
    separately in {blue}RotorHazard Manager{endc}{bold} - see in Main Menu.



    Possible RotorHazard server versions that may be selected:

    > {blue}'stable'{endc}{bold}- last stable release (can be from before few days or few months){endc}{bold}

    > {blue}'beta'  {endc}{bold}- last 'beta' release (usually has about few weeks, quite stable){endc}{bold}

    > {blue}'master'{endc}{bold}- absolutely newest features implemented (even if not well tested){endc} 



    {green}c - Enter configuration wizard{endc}{yellow}

           e - Exit to menu {endc}

        """.format(green=Bcolors.GREEN_S, blue=Bcolors.BLUE, endc=Bcolors.ENDC,
                   yellow=Bcolors.YELLOW_S, bold=Bcolors.BOLD)
        print(welcome_first_page)
        selection = input()
        if selection == 'c':
            config = conf_ota(config)
            break
        elif selection == 'e':
            break

    return config
Esempio n. 4
0
def main_window(serv_installed_flag, server_version_name, conf_flag):
    sleep(0.1)
    welcome_text = """
        \n\n{red} {bold}
        AUTOMATIC UPDATE AND INSTALLATION OF ROTORHAZARD RACING TIMER SOFTWARE
            {endc}{bold}
        You can automatically install and update RotorHazard timing software. 
        Additional dependencies and libraries also will be installed or updated.
        Current database, configs and custom bitmaps will stay on their place.
        Source of the software is set to {underline}{blue}{server_version}{endc}{bold} version from the official 
        RotorHazard repository.
         
        Perform self-updating of this software, before updating server software.
        Also make sure that you are logged as user {underline}{blue}{user}{endc}{bold}.
        
        You can change those in configuration wizard in Main Menu.
        
        Server installed right now: {server} {bold}
        RotorHazard configuration state: {config_soft}\n\n
        """.format(bold=Bcolors.BOLD,
                   underline=Bcolors.UNDERLINE,
                   endc=Bcolors.ENDC,
                   blue=Bcolors.BLUE,
                   yellow=Bcolors.YELLOW,
                   red=Bcolors.RED,
                   orange=Bcolors.ORANGE,
                   server_version=server_version,
                   user=user,
                   config_soft=conf_flag,
                   server=server_version_name)
    print(welcome_text)
    if not conf_flag and serv_installed_flag:
        print(
            f"{Bcolors.GREEN}\t\t'c' - Configure RotorHazard server\n{Bcolors.ENDC}"
        )
    else:
        print("\t\t'c' - Reconfigure RotorHazard server\n")
    if not serv_installed_flag:
        print(
            f"\t\t{Bcolors.GREEN}'i' - Install software from scratch{Bcolors.ENDC}"
        )
    else:
        print("""\t\t'i' - Install software from scratch""")
    print("""
                'u' - Update existing installation\n {yellow}    
                'e' - Exit to Main Menu{endc}\n
            """.format(yellow=Bcolors.YELLOW, endc=Bcolors.ENDC))
    selection = input()
    if selection == 'c':
        if serv_installed_flag:
            conf_ota()
        else:
            print("\n\t\tPlease install server software first")
            sleep(1.5)
    if selection == 'i':
        if config[installation_done]:
            clear_the_screen()
            already_installed_prompt = """
            {bold}
    Looks like you already have RotorHazard server installed
    (or at least that your system was once configured).{endc}
    
    If that's the case please use {underline} update mode {endc} - 'u'
    or force installation {underline} without {endc} sys. config. - 'i'.
            
            {green} 
        'u' - Select update mode - recommended {endc}\n 
        'i' - Force installation without sys. config.\n
        'c' - Force installation and sys. config.\n {yellow}
        'a' - Abort both  \n {endc}""".format(bold=Bcolors.BOLD,
                                              endc=Bcolors.ENDC,
                                              underline=Bcolors.UNDERLINE,
                                              yellow=Bcolors.YELLOW,
                                              green=Bcolors.GREEN)
            print(already_installed_prompt)
            selection = input()
            if selection == 'u':
                update()
            if selection == 'i':
                conf_allowed = False
                installation()
            if selection == 'c':
                confirm_valid_options = ['y', 'yes', 'n', 'no', 'abort', 'a']
                while True:
                    confirm = input(
                        "\n\t\tAre you sure? [yes/abort]\t").strip()
                    if confirm in confirm_valid_options:
                        break
                    else:
                        print(
                            "\ntoo big fingers :( wrong command. try again! :)"
                        )
                if confirm == 'y' or confirm == 'yes':
                    conf_allowed = True
                    installation()
                if confirm in ['n', 'no', 'abort', 'a']:
                    pass
            if selection == 'a':
                clear_the_screen()
                image_show()
                sleep(0.5)
                sys.exit()
            else:
                main()
        else:
            conf_allowed = True
            installation()
    if selection == 'u':
        update()
    if selection == 'e':
        clear_the_screen()
        os.chdir(f"/home/{user}/RH-ota")
        image_show()
        sleep(0.3)
        sys.exit()
    else:
        main()