test: enhance SMS send util to accept validity and SMSC address
This commit is contained in:
@@ -19,11 +19,29 @@ import sys
|
|||||||
import dbus
|
import dbus
|
||||||
import os
|
import os
|
||||||
|
|
||||||
if len(sys.argv) != 3:
|
arglen = len(sys.argv)
|
||||||
print "Usage: %s <number> <message>" % sys.argv[0]
|
if arglen != 4 and arglen != 6 and arglen != 8:
|
||||||
|
print "Usage: %s --number <number> [--smsc <smsc>] [--validity <5 minute units>] <message>" % sys.argv[0]
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
number = sys.argv[1]
|
number = None
|
||||||
|
validity = None
|
||||||
|
smsc = None
|
||||||
|
message = None
|
||||||
|
x = 1
|
||||||
|
while x < arglen - 1:
|
||||||
|
if sys.argv[x] == "--number":
|
||||||
|
x += 1
|
||||||
|
number = sys.argv[x].strip()
|
||||||
|
elif sys.argv[x] == "--validity":
|
||||||
|
x += 1
|
||||||
|
validity = int(sys.argv[x])
|
||||||
|
elif sys.argv[x] == "--smsc":
|
||||||
|
x += 1
|
||||||
|
smsc = sys.argv[x].strip()
|
||||||
|
else:
|
||||||
|
raise ValueError("Unknown option '%s'" % sys.argv[x])
|
||||||
|
x += 1
|
||||||
|
|
||||||
try:
|
try:
|
||||||
lang = os.getenv("LANG")
|
lang = os.getenv("LANG")
|
||||||
@@ -32,7 +50,8 @@ try:
|
|||||||
lang = lang[idx + 1:]
|
lang = lang[idx + 1:]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
lang = "utf-8"
|
lang = "utf-8"
|
||||||
message = unicode(sys.argv[2], "utf-8")
|
message = unicode(sys.argv[arglen - 1], "utf-8")
|
||||||
|
|
||||||
|
|
||||||
bus = dbus.SystemBus()
|
bus = dbus.SystemBus()
|
||||||
|
|
||||||
@@ -47,10 +66,19 @@ proxy = bus.get_object('org.freedesktop.ModemManager', modems[0])
|
|||||||
modem = dbus.Interface(proxy, dbus_interface='org.freedesktop.ModemManager.Modem')
|
modem = dbus.Interface(proxy, dbus_interface='org.freedesktop.ModemManager.Modem')
|
||||||
modem.Enable(True)
|
modem.Enable(True)
|
||||||
|
|
||||||
msg_dict = dbus.Dictionary({ dbus.String('number') : dbus.String(number),
|
msg_dict = dbus.Dictionary(
|
||||||
dbus.String('text') : dbus.String(message)
|
{
|
||||||
},
|
dbus.String('number') : dbus.String(number),
|
||||||
signature=dbus.Signature("sv"))
|
dbus.String('text') : dbus.String(message)
|
||||||
|
},
|
||||||
|
signature=dbus.Signature("sv")
|
||||||
|
)
|
||||||
|
|
||||||
|
if smsc:
|
||||||
|
msg_dict[dbus.String('smsc')] = dbus.String(smsc)
|
||||||
|
|
||||||
|
if validity:
|
||||||
|
msg_dict[dbus.String('validity')] = dbus.UInt32(validity)
|
||||||
|
|
||||||
sms_iface = dbus.Interface(proxy, dbus_interface='org.freedesktop.ModemManager.Modem.Gsm.SMS')
|
sms_iface = dbus.Interface(proxy, dbus_interface='org.freedesktop.ModemManager.Modem.Gsm.SMS')
|
||||||
try:
|
try:
|
||||||
|
Reference in New Issue
Block a user