Ejemplo n.º 1
0
 def aliases_content():
     os.system("cat ./resources/aliases.txt | tee -a ~/.bashrc")
     parser.set('added_functions', 'aliases_1', '1')
     parser.set('added_functions', 'aliases_2', '1')
     parser_write(parser, config)
     print("\n\n\t\t    Aliases added successfully")
     sleep(3)
     features_menu(parser, config)
Ejemplo n.º 2
0
def end(parser, config):
    parser_write(parser, config)
    clear_the_screen()
    print("\n\n")
    ota_image()
    print("\t\t\t\t   " + Bcolors.BOLD + "Happy flyin'!" + Bcolors.ENDC + "\n")
    sleep(1.3)
    clear_the_screen()
    sys.exit()
Ejemplo n.º 3
0
def log_send(parser, config):
    while True:
        selection = input(
            "\n\n\tDo you want to send a log file for a review to the developer? [y/n] "
        )
        if selection == 'y' or selection == 'yes':
            if not parser.getint('added_functions', 'curl_installed'):
                if not os.system("sudo apt install curl cowsay"):
                    parser.set('added_functions', 'curl_installed', '1')
                    parser_write(parser, config)
            log_name = input(
                "\n\tPlease enter your name so we know who sent a log file: ")
            print("\n\tPlease wait, file is being uploaded...\n")
            os.system("rm ./log_data/log_name.txt > /dev/null 2>&1")
            os.system("rm ./log_data/log_code.txt > /dev/null 2>&1")
            os.system("echo {log_name} > ./log_data/log_name.txt".format(
                log_name=log_name))
            os.system(
                "curl --upload-file ./log_data/log.txt https://transfer.sh/{log_name}_log.txt \
                 | tee -a ./log_data/log_code.txt".format(log_name=log_name))
            print("\n")
            os.system(
                "sed -i 's/https:\/\/transfer.sh\///g' ./log_data/log_code.txt"
            )
            os.system(
                "sed -i 's/\/{log_name}_log.txt//g' ./log_data/log_code.txt".
                format(log_name=log_name))
            print("\n___________________________\n")
            print("\nTell your favourite developer those:\n")
            print("User name: {log_name}".format(log_name=log_name))
            f = open("./log_data/log_code.txt", "r")
            code = ''
            for line in f:
                code = line
            print("\nUser code: {code}".format(code=code))
            print("\n___________________________\n")
            input("\n\nHit 'Enter' to continue\n\n")
            if not os.system("cowsay You are awesome! Fly safe."):
                sleep(3)
            break
        if selection == 'n' or selection == 'no':
            print(
                "\n\n\tOK - you log file is stored under 'log.txt' name in RH-ota directory."
            )
            input("\n\n\tHit 'Enter' to continue\n\n")
            break
Ejemplo n.º 4
0
 def add_updater():
     clear_the_screen()
     logo_top(config.debug_mode)
     print("""
 Permissions required so 'zip' and 'unzip' program can be downloaded.
 Performed only during first instance of entering this sub-menu\n""")
     sleep(2)
     os.system("sudo echo")
     os.system("sudo apt install zip unzip")
     os.system(
         "echo 'alias updateupdater=\"cd ~ && cp ~/RH-ota/self.py ~/.ota_markers/self.py && \
      python ~/.ota_markers/self.py \"  # part of self updater' | tee -a ~/.bashrc >/dev/null"
     )
     os.system(
         "echo 'alias uu=\"cd ~ && cp ~/RH-ota/self.py ~/.ota_markers/self.py && python \
      ~/.ota_markers/self.py \"  # part of self updater' | tee -a ~/.bashrc >/dev/null"
     )
     parser.set('added_functions', 'updater_planted', '1')
     parser_write(parser, config)
Ejemplo n.º 5
0
 def serial_content():
     os.system("echo 'enable_uart=1'| sudo tee -a /boot/config.txt")
     os.system(
         "sudo sed -i 's/console=serial0,115200//g' /boot/cmdline.txt")
     parser.set('added_functions', 'serial_added', '1')
     parser_write(parser, config)
     print("""
     
     Serial port enabled successfully
     You have to reboot Raspberry now. Ok?
     
     r - Reboot now{yellow}
     b - Go back{endc}
         """.format(endc=Bcolors.ENDC, yellow=Bcolors.YELLOW_S))
     selection_2 = input()
     if selection_2 == 'r':
         os.system("sudo reboot")
     if selection_2 == 'b':
         return
Ejemplo n.º 6
0
def features_menu(parser, config):
    clear_the_screen()
    logo_top(config.debug_mode)
    features_menu = """

                    {red}{bold}{underline}FEATURES MENU{endc}

        {blue}{bold} 
                        1 - Install AVRDUDE
                        
                        2 - Enable serial protocol {endc} {bold}
                        
                        3 - Access Point and Internet 
                        
                        4 - Show actual Pi's GPIO
                        
                        5 - Useful aliases
                        
                        6 - Update OTA software {endc} {yellow}{bold}
                            
                        e - Exit to main menu {endc}

             """.format(bold=Bcolors.BOLD_S,
                        underline=Bcolors.UNDERLINE,
                        endc=Bcolors.ENDC,
                        blue=Bcolors.BLUE,
                        yellow=Bcolors.YELLOW_S,
                        red=Bcolors.RED_S,
                        orange=Bcolors.ORANGE_S)
    print(features_menu)
    selection = input()
    if selection == '1':
        avr_dude(config)
    if selection == '2':
        serial_menu(parser, config)
    if selection == '3':
        os.system("python3 ./net_and_ap.py")
    if selection == '4':
        if not parser.getint('added_functions', 'pinout_installed'):
            print(
                "Some additional software has to be added so action can be performed. Ok?\n[yes/no]\n"
            )
            while True:
                selection = input()
                if selection == 'y' or selection == 'yes':
                    if not os.system("sudo apt-get install python3-gpiozero"):
                        parser.set('added_functions', 'pinout_installed', '1')
                        parser_write(parser, config)
                        break
                    else:
                        print("\nFailed to install required package.\n")
                        sleep(2)
                        break
                if selection == 'n' or selection == 'no':
                    break
                else:
                    continue
        if parser.getint('added_functions', 'pinout_installed'):
            os.system("pinout")
            selection = input("\nDone? Hit 'Enter'\n")
        else:
            print("\nAdditional software needed. Please re-enter this menu.\n")
            sleep(3)
    if selection == '5':
        aliases_menu(parser, config)
    if selection == '6':
        self_updater(parser, config)
    if selection == 'e':
        main_menu(parser, config)
    else:
        features_menu(parser, config)