-
Notifications
You must be signed in to change notification settings - Fork 24
/
disable_wifi_and_bluetooth.py
61 lines (45 loc) · 1.74 KB
/
disable_wifi_and_bluetooth.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import os
from time import sleep
def disable_wifi_and_bluetooth():
# Block WIFI and Bluetooth
os.system('sudo rfkill block wifi')
os.system('sudo rfkill block bluetooth')
# Check status of WIFI and Bluetooth
print_out = os.popen('sudo rfkill list').read()
print_out_cleaned = ''
for i in print_out:
if ord(i) == 10:
print_out_cleaned += ' '
elif ord(i) == 9:
print_out_cleaned += ''
else:
print_out_cleaned += i
print(f'Status print out: {print_out_cleaned}')
# Report WIFI Status
if "Wireless LAN Soft blocked: yes" in print_out_cleaned:
wifi_response = "Wifi Disabled."
elif "Wireless LAN Soft blocked: no":
wifi_response = "Warning! Wifi is still enabled."
else:
wifi_response = "Warning! Wifi status could not be determined."
# Report Bluetooth Status
if "Bluetooth Soft blocked: yes" in print_out_cleaned:
bluetooth_response = "Bluetooth Disabled."
elif "Bluetooth Soft blocked: no":
bluetooth_response = "Warning! Bluetooth is still enabled."
else:
bluetooth_response = "Warning! Bluetooth status could not be determined."
return wifi_response, bluetooth_response
if __name__ == "__main__":
from text_to_speech import speaker
wifi_response, bluetooth_response = disable_wifi_and_bluetooth()
speaker.add_to_queue(f'{wifi_response} {bluetooth_response}')
sleep(1) # wait for speaker to get started
# wait for the speaker to finish
for n in range(200):
if speaker.isSpeaking:
sleep(.01)
else:
break
speaker.release()
print('Ending demo.')