Beispiel #1
0
def chooseFTS():
    polyterminal.reset("PolyOS - Audio Setup")
    print("")
    print("Please select the audio output:")
    print("-----------------------------------------")
    print("")
    print("0 -\t TOSLINK \t(ZERO)")
    print("1 -\t ANALOG  \t(ZERO)")
    print("2 -\t AMPLIFIER\t(AMP1)")
    print("3 -\t DAC\t\t(M1-0006)")
    print("4 -\t SPDIF\t\t(M1-0006 + M1-0007)")
    print("5 -\t I2S\t\t(M1-0007)")

    print("")
    user = input("Enter either 0, 1, 2, 3 or 4 to configure audio output: ")
    if "0" in user:
        selectSPDIF()
    elif "1" in user:
        selectLINE()
    elif "2" in user:
        selectAMP1()
    elif "3" in user:
        selectLINE()
    elif "4" in user:
        selectSPDIF()
    elif "5" in user:
        selectI2S()
    else:
        print("SOMETHING WENT WRONG - TRY AGAIN: ", user)
        time.sleep(1)
        chooseFTS()
Beispiel #2
0
def selectNetwork(wifi_info):
    polyterminal.reset("PolyOS - Wireless Connectivity")
    i = 2
    print("0 :\t  Rescan for networks")
    print("1 :\t  Skip WiFi Setup")
    print("2 :\t  Reserved for future use")
    print("-------------------------------------------------------------")
    for ssid in wifi_info[0]:
        i = i + 1
        print(i, ":\t", polyterminal.text_colors.BLUE, ssid,
              polyterminal.text_colors.END)

    print("")
    choice = -1
    while 1:
        try:
            if i == 2:
                choice = int(
                    input(
                        "\nEnter 0 to rescan for networks.\nEnter 1 to exit: ")
                )
            elif i == 3:
                choice = int(
                    input(
                        "\nEnter 0 to rescan for networks.\nEnter 1 to exit.\nEnter 3 to choose %s: "
                        % wifi_info[0][0]))
            else:
                choice = int(
                    input(
                        "\nEnter 0 to rescan for networks.\nEnter 1 to exit.\nEnter a number between 3 to %s to choose one of the listed network SSIDs: "
                        % i))
        except TypeError:
            choice = -1
        except ValueError:
            choice = -1

        if choice == 0:
            break
        elif choice == 1:
            break
        elif choice == 2:
            break
        elif choice > 2 and choice <= i and polyterminal.verified(
                wifi_info[0][choice - 3]):
            wifi_name = wifi_info[0][choice - 3]
            wifi_password = getPassword()
            wifi_id = wifi_info[1][choice - 3]
            wifi_conf = []
            wifi_conf.append(wifi_id)
            wifi_conf.append(wifi_name)
            wifi_conf.append(wifi_password)
            writeConf(wifi_conf)
            break

    return choice
Beispiel #3
0
def scanForNetworks():
    polyterminal.reset("PolyOS - Wireless Connectivity")
    stdout.write("Starting scan\r")
    stdout.flush()
    subprocess.check_output(["systemctl", "enable", "connman"],
                            stderr=subprocess.STDOUT)
    subprocess.check_output(["systemctl", "start", "connman"],
                            stderr=subprocess.STDOUT)
    subprocess.check_output(["connmanctl", "enable", "wifi"],
                            stderr=subprocess.STDOUT)
    r = range(4, 0, -1)
    for i in r:
        stdout.write("Scanning for networks: %s seconds left \r" % i)
        stdout.flush()
        if i == 4:
            subprocess.check_output(["connmanctl", "scan", "wifi"],
                                    stderr=subprocess.STDOUT)
        time.sleep(1)

    wifi_names = []
    wifi_ids = []
    wifi_signals = []

    bus = dbus.SystemBus()

    manager = dbus.Interface(bus.get_object("net.connman", "/"),
                             "net.connman.Manager")

    for path, properties in manager.GetServices():
        service = dbus.Interface(bus.get_object("net.connman", path),
                                 "net.connman.Service")
        identifier = path[path.rfind("/") + 1:]
        id = str("%s" % (identifier))
        wifi_ids.append(id)

        for key in properties.keys():
            if key in ["Strength"]:
                wifi_signals.append(int(properties[key]))
            elif key in ["Name"]:
                wifi_names.append(str("%s" % (properties[key])))
            else:
                val = properties[key]

    wifi_info = [[], [], []]
    wifi_info[0] = wifi_names
    wifi_info[1] = wifi_ids
    wifi_info[2] = wifi_signals

    return (wifi_info)
Beispiel #4
0
def chooseFTS():
    polyterminal.reset("PolyOS - Audio Setup")
    print("")
    print("Please select the audio output:")
    print("-----------------------------------------")
    print("")
    print("0 -\t TOSLINK \t(ZERO)")
    print("1 -\t ANALOG  \t(ZERO)")
    print("2 -\t AMPLIFIER\t(AMP1)")
    print("")
    user = input("Enter either 0 or 1 or 2 to configure audio output: ")
    if user == "0":
        selectSPDIF()
    if user == "1":
        selectLINE()
    if user == "2":
        selectAMP1()
    else:
        selectLINE()
Beispiel #5
0
def checkNetwork():
    polyterminal.reset("PolyOS - Wireless Connectivity")
    i = 60
    print("")
    while 1:
        waiting = "Connecting to your WiFi: %s seconds left         \r" % i
        stdout.write(waiting)
        stdout.flush()
        time.sleep(1)
        address = os.popen("ifconfig | grep -A1 'wlan0' | grep 'inet'| awk -F' ' '{ print $2 }' | awk -F':' '{ print $2 }'").read().rstrip()
        if not address == "":
            polyterminal.reset("PolyOS - Wireless Connectivity")
            print("")
            print("CONNECTED! IP address: "+address)
            break
        if i == 0:
            print("Not connected. Something went wrong. Please try again.")
            break
        i = i-1

    print("")
    user = input("Hit [enter] to continue")