Ejemplo n.º 1
0
def main():
    if len(sys.argv) >= 2:
        if sys.argv[1] == "--ssid" or sys.argv[1] == "-s":
            listWifi()

        elif (sys.argv[1] == "--connect" or sys.argv[1] == "-c") and len(
                sys.argv) == 4:
            ssid = sys.argv[2]
            psk = sys.argv[3]
            wifi = Wifi()

            p = scanWifi()

            wifi = next((x for x in wifis if x.ssid == ssid), None)
            if wifi != None:
                wifi.password = psk

                wifi.connect()
                print(wifi.ssid)
                print(wifi.channel)
                print(wifi.signal)
                print(wifi.encryption_type)

            else:
                print("SSID not found.")
        else:
            print("Wrong command.")