-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtext_cell.py
More file actions
31 lines (26 loc) · 1.23 KB
/
Copy pathtext_cell.py
File metadata and controls
31 lines (26 loc) · 1.23 KB
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
# Using Twilio (it's free)
# simple code to text my cell when my programs fail
from twilio.rest import Client
account_sid = 'account_sid'
auth_token = 'auth_token'
client = Client(account_sid, auth_token)
def text_my_cell(text='program failed',trent=False):
# text: String. This is the message to be texted
# trent = True
# Also send the message to my research advisor Trent
call = client.messages.create(
body=text,
to='input_your_number',
from_='input_twilio_number'
)
if trent:
call = client.messages.create(
body=text,
to='input_another_number',
from_='input_twilio_number'
)
# I use this code to send my self daily updates on the overall data collection every day
# Useful to catch random bugs in Twitter's API that result in a request timeout and need to be corrected manually
# simple function to put commas in an integer to make it easily readable
def int_comma(integer):
return ','.join([str(integer)[::-1][i:i+3] for i in range(0,len(str(integer)),3)])[::-1]