Last active
March 29, 2018 10:50
-
-
Save miguel-amaral/af7e7a7c0923a2c8922ce1b4535d9671 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
# from Command import Command | |
from time import sleep | |
class CreateConnectionToWifi(): | |
def run(self): | |
while True: | |
# for x in range(3): | |
# print(x) | |
print("DOES NOT EXIST SSID") | |
subprocess.call(['nmcli', 'dev', 'wifi', 'connect','RPI-Wifi2you-DOES-NOT-EXISTS','password', '45nonono65','ifname','wlan0'], stdout=subprocess.PIPE) | |
self.sleepingABit() | |
print("WRONG PASSWORD") | |
subprocess.call(['nmcli', 'dev', 'wifi', 'connect','RPI-Wifi2you','password', 'WRONG PASS','ifname','wlan0'], stdout=subprocess.PIPE) | |
self.sleepingABit() | |
self.connectedTo("RPI-Wifi2you") | |
# subprocess.call(['nmcli', 'dev', 'wifi', 'connect','RPI-Wifi2you','password', '45nonono65','ifname','wlan0'], stdout=subprocess.PIPE) | |
def removeOld(self): | |
print("Will remove") | |
subprocess.call(['nmcli', 'c', 'delete', 'RPI-Wifi2you'], stdout=subprocess.PIPE) | |
print("Called") | |
def connectedTo(self,SSID): | |
proc = subprocess.call(['nmcli','dev','wifi'],stdout=subprocess.PIPE) | |
output = proc.stdout.read() | |
print(output) | |
def sleepingABit(self): | |
print("Sleep: 5") | |
sleep(5) | |
print("Sleeped") | |
if __name__ == '__main__': | |
CreateConnectionToWifi().run() | |
# | |
# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment