-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtwillio.py
72 lines (50 loc) · 2.02 KB
/
twillio.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
62
63
64
65
66
67
68
69
70
71
import os
from twilio.rest import Client
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.ui import WebDriverWait
import time
import chromedriver_binary
import keyboard
import board
import digitalio
import os
def getLocation():
options = Options()
options.add_argument("--use--fake-ui-for-media-stream")
#driver = webdriver.Chrome(executable_path = './chromedriver_linux64',options=options) #Edit path of chromedriver accordingly
driver = webdriver.Chrome(options=options)
timeout = 0
driver.get("https://mycurrentlocation.net/")
wait = WebDriverWait(driver, timeout)
#time.sleep(0.1)
longitude = driver.find_elements_by_xpath('//*[@id="longitude"]') #Replace with any XPath
longitude = [x.text for x in longitude]
longitude = str(longitude[0])
latitude = driver.find_elements_by_xpath('//*[@id="latitude"]')
latitude = [x.text for x in latitude]
latitude = str(latitude[0])
# driver.quit()
return (latitude,longitude)
# Your Account Sid and Auth Token from twilio.com/console
# and set the environment variables. See http://twil.io/secure
def twilio_msg_snd():
account_sid = ''
auth_token = ''
client = Client(account_sid, auth_token)
latitude,longitude = getLocation()
message = client.messages \
.create(
body=f'testing for location sender Visual Impairment System https://www.google.com/maps/search/?api=1&query={latitude},{longitude}',
from_='',#twilio number
to='' #your number
)
#twilio_msg_snd()
button = digitalio.DigitalInOut(board.D4)
button.direction = digitalio.Direction.INPUT
# use an external pullup since we don't have internal PU's
button.pull = digitalio.Pull.UP
while True:
#print(button.value) # light when button is pressed!
if(button.value == False):
twilio_msg_snd()