-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsend_sms.py
executable file
·45 lines (36 loc) · 1.11 KB
/
send_sms.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
#!/usr/bin/python
#
# Send SMS from CLI using most appropriate SMS sending provider
#
# Author: Arie Skliarouk <skliarie@gmail.com>
import ConfigParser
import os
import sys
config = ConfigParser.ConfigParser()
#config.readfp(open('defaults.cfg'))
config.read(['arapim.cfg', os.path.expanduser('~/.myapp.cfg')])
if len(sys.argv) == 1:
print "Usage: send_sms [message text] [phone number]"
sys.exit(1)
text_str = sys.argv[1]
recipient = sys.argv[2]
# TBD: Detect best SMS provider to send SMS through
# For now just hardcode the whole thing
assert(recipient[0] == "+")
recipient = recipient.replace("-", "")
# TBD: Verify that a given provider is configured in the
# configuration file before using it
if recipient[:4] == "+972":
provider="cellact"
import cellact
sms = cellact.sms_sender(config)
elif recipient[:2] == "+1":
provider="cdyne"
import cdyne
sms = cdyne.sms_sender(config)
else:
provider="clickatell"
import clickatell
sms = clickatell.sms_sender(config)
print "Debug: got number [%s], using provider [%s]" % (recipient, provider)
result = sms.send(text_str, recipient)