From a1c9b3467cd9dd236b72a72983fc3afd08b8784b Mon Sep 17 00:00:00 2001 From: ICBMICBM Date: Mon, 26 Aug 2019 10:59:41 +0800 Subject: [PATCH] NETFLAG added for user in no connection wlan --- .DS_Store | Bin 0 -> 6148 bytes kickthemout.py | 40 +++++++++++++++++++++++++++------------- 2 files changed, 27 insertions(+), 13 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..f3c0f4e64cce7f5240a613fe255e96d222cbba12 GIT binary patch literal 6148 zcmeHKyG{c!5FCd{NfZf1G*Dhi0}?gO5t1SjP>>HeNCG0t6G$ZJuHhf}1-_3DfZ4Sb za(AJjKnU$h>#^6fK6`vRp8>e$a&QDR095IMr5cM3CjH_CD}{)3Ivt~rYxHr48zcp` z1^%J}vUhdvR)RU6xp!atmvqLnes4VMks+_gF@66-jWuA0>=_2!>jUB~OKDFTS+cgk zAto5)#(2w(v5gUiWRJ*~w`Rf-mYU1iWOLnaF1La+ba09`F3?3g$9~DNYq%uy1TCBs zH_Xkw=Q0|2;Ee7$pP|+!Y)v`0M`kbZghlp=s?Y11J{2-W&nfwZ)j*V3XIIIdbM>O+ z2EML-ozHYLQ@|831%9jm&up=3-J_MJfGJ=KtQ3&%Lqr#h1EwDJ)4@Wo0K_uGYOKr8 zqU1yY9WM50r72(v zWEI%*&4!%+?eFjZ*(7V30;a&fQoxm4-By!J3TJC!adOs1^eeiU@KTSf6jt;oCRdK) bJ-Qm>kyMCrz| {}(y/n): '.format(BLUE, WHITE, RED, END)) ans=input(header) if ans == "y": + NETFLAG=2 return True elif ans == "n": + NETFLAG=0 return False else: print("\n{}Invalid input.{}".format(RED, END)) @@ -143,8 +151,10 @@ def trySkipCheckInternetConnection(): # make sure there is an internet connection def checkInternetConnection(): + global NETFLAG try: urlopen('https://github.com', timeout=3) + NETFLAG=1 return True except URLError as err: trySkipCheckInternetConnection() @@ -228,19 +238,23 @@ def retrieveMACAddress(host): # resolve mac address of each vendor def resolveMac(mac): - try: - # send request to macvendors.co - url = "http://macvendors.co/api/vendorname/" - request = Request(url + mac, headers={'User-Agent': "API Browser"}) - response = urlopen(request) - vendor = response.read() - vendor = vendor.decode("utf-8") - vendor = vendor[:25] - return vendor - except KeyboardInterrupt: - shutdown() - except: - return "N/A" + global NETFLAG + if NETFLAG == 1: + try: + # send request to macvendors.co + url = "http://macvendors.co/api/vendorname/" + request = Request(url + mac, headers={'User-Agent': "API Browser"}) + response = urlopen(request) + vendor = response.read() + vendor = vendor.decode("utf-8") + vendor = vendor[:25] + return vendor + except KeyboardInterrupt: + shutdown() + except: + return "N/A" + elif NETFLAG == 2: + return "N/A"