本文整理汇总了Python中messaging.sms.SmsSubmit类的典型用法代码示例。如果您正苦于以下问题:Python SmsSubmit类的具体用法?Python SmsSubmit怎么用?Python SmsSubmit使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SmsSubmit类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_encoding_class
def test_encoding_class(self):
number = "+34654123456"
text = "hey yo"
expected_0 = "0001000B914356143254F6001006E8721E947F03"
expected_1 = "0001000B914356143254F6001106E8721E947F03"
expected_2 = "0001000B914356143254F6001206E8721E947F03"
expected_3 = "0001000B914356143254F6001306E8721E947F03"
sms = SmsSubmit(number, text)
sms.ref = 0x0
sms.klass = 0
pdu = sms.to_pdu()[0]
self.assertEqual(pdu.pdu, expected_0)
sms.klass = 1
pdu = sms.to_pdu()[0]
self.assertEqual(pdu.pdu, expected_1)
sms.klass = 2
pdu = sms.to_pdu()[0]
self.assertEqual(pdu.pdu, expected_2)
sms.klass = 3
pdu = sms.to_pdu()[0]
self.assertEqual(pdu.pdu, expected_3)
示例2: test_encoding_class
def test_encoding_class(self):
number = '2b3334363534313233343536'.decode('hex')
text = "hey yo"
expected_0 = "0001000B914356143254F6001006E8721E947F03"
expected_1 = "0001000B914356143254F6001106E8721E947F03"
expected_2 = "0001000B914356143254F6001206E8721E947F03"
expected_3 = "0001000B914356143254F6001306E8721E947F03"
sms = SmsSubmit(number, text)
sms.ref = 0x0
sms.klass = 0
pdu = sms.to_pdu()[0]
self.assertEqual(pdu.pdu, expected_0)
sms.klass = 1
pdu = sms.to_pdu()[0]
self.assertEqual(pdu.pdu, expected_1)
sms.klass = 2
pdu = sms.to_pdu()[0]
self.assertEqual(pdu.pdu, expected_2)
sms.klass = 3
pdu = sms.to_pdu()[0]
self.assertEqual(pdu.pdu, expected_3)
示例3: to_pdu
def to_pdu(self, store=False):
"""Returns the PDU representation of this message"""
sms = SmsSubmit(self.number, self.text)
sms.csca = self.csca
sms.request_status = self.status_request
if store:
sms.validity = None
return sms.to_pdu()
示例4: test_encoding_request_status
def test_encoding_request_status(self):
# tested with pduspy.exe and http://www.rednaxela.net/pdu.php
number = "+34654123456"
text = "hey yo"
expected = "0021000B914356143254F6000006E8721E947F03"
sms = SmsSubmit(number, text)
sms.ref = 0x0
sms.request_status = True
pdu = sms.to_pdu()[0]
self.assertEqual(pdu.pdu, expected)
示例5: test_encoding_request_status
def test_encoding_request_status(self):
# tested with pduspy.exe and http://www.rednaxela.net/pdu.php
number = codecs.decode(b'2b3334363534313233343536', 'hex')
text = "hey yo"
expected = "0021000B914356143254F6000006E8721E947F03"
sms = SmsSubmit(number, text)
sms.ref = 0x0
sms.request_status = True
pdu = sms.to_pdu()[0]
self.assertEqual(pdu.pdu, expected)
示例6: test_encoding_8bit_message
def test_encoding_8bit_message(self):
number = "01000000000"
csca = "+44000000000"
text = "Hi there..."
expected = "07914400000000F001000B811000000000F000040B48692074686572652E2E2E"
sms = SmsSubmit(number, text)
sms.ref = 0x0
sms.csca = csca
sms.fmt = 0x04 # 8 bits
pdu = sms.to_pdu()[0]
self.assertEqual(pdu.pdu, expected)
示例7: send_sms
def send_sms(self, msisdn, text):
sms = SmsSubmit(msisdn, text)
# NOTE: The use of the Deferred here is a bit wonky
# I'm using it like this because it makes adding callbacks
# in a for-loop easier since we're potentially sending
# SMSs bigger than 160 chars.
d = Deferred()
for pdu in sms.to_pdu():
d.addCallback(self.next("AT+CMGS=%d" % (pdu.length,), expect="> "))
d.addCallback(self.next("%s%s" % (pdu.pdu, self.CTRL_Z)))
d.callback([])
return d
示例8: send_sms
def send_sms(self, number, text, callback_index=None):
if self.mode == 0:
sms = SmsSubmit(number, text)
pdu = sms.to_pdu()[0]
message_list = [("AT+CMGS=%d" % (pdu.length,),
pdu.pdu,
callback_index)]
else:
message_list = [("AT+CMGS=%s" % (number,),
text,
callback_index)]
self._pending.extend(message_list)
self._write_next()
示例9: pduformat
def pduformat(phonenumber, message):
"""
Formats SMS using pdu encoding
:param phonenumber: Phone number to insert in pdu
:param message: Text message
:return: pdustring, pdulenght
"""
sms = SmsSubmit(phonenumber, message)
pdu = sms.to_pdu()[0]
pdustring = pdu.pdu
pdulength = pdu.length
# debug output
# print(phonenumber, message)
# print(pdu.length, pdu.pdu)
return pdustring, pdulength
示例10: test_encoding_csca
def test_encoding_csca(self):
number = "+34616585119"
text = "hola"
csca = "+34646456456"
expected = "07914346466554F601000B914316565811F9000004E8373B0C"
expected_len = 17
sms = SmsSubmit(number, text)
sms.csca = csca
sms.ref = 0x0
pdu = sms.to_pdu()[0]
self.assertEqual(pdu.pdu, expected)
self.assertEqual(pdu.length, expected_len)
self.assertEqual(pdu.cnt, 1)
self.assertEqual(pdu.seq, 1)
示例11: sendLongMessage
def sendLongMessage(modem, number, message):
modem.write('AT+CMGF=0\r')
time.sleep(0.5)
sms = SmsSubmit(number, message)
for pdu in sms.to_pdu():
print('sending')
strS = 'AT+CMGS=' + str(len(pdu.pdu) / 2 - 1) + '\r\n'
modem.write(strS)
time.sleep(0.5)
modem.write(pdu.pdu + '\r');
time.sleep(0.5)
modem.write(chr(26))
time.sleep(0.5)
print('done')
modem.write('AT+CMGF=1\r')
time.sleep(0.5)
示例12: test_encoding_csca
def test_encoding_csca(self):
number = codecs.decode(b'2b3334363136353835313139', 'hex').decode()
text = "hola"
csca = "+34646456456"
expected = "07914346466554F601000B914316565811F9000004E8373B0C"
expected_len = 17
sms = SmsSubmit(number, text)
sms.csca = csca
sms.ref = 0x0
pdu = sms.to_pdu()[0]
self.assertEqual(pdu.pdu, expected)
self.assertEqual(pdu.length, expected_len)
self.assertEqual(pdu.cnt, 1)
self.assertEqual(pdu.seq, 1)
示例13: send
def send(self):
self.pdu = SmsSubmit(self.recipient, self.content)
for xpdu in self.pdu.to_pdu():
command = "AT+CMGS=%d\r" % xpdu.length
self.SendCommand(command, len(str(xpdu.length)) + 14)
command = "%s\x1a" % xpdu.pdu
self.SendCommand(command, len(xpdu.pdu) + 20)
self.logfile.write(str(datetime.now()))
self.logfile.write(" after send a sms \n")
示例14: send
def send(self):
self.pdu = SmsSubmit(self.recipient, self.content)
for xpdu in self.pdu.to_pdu():
command = "AT+CMGS=%d\r" % xpdu.length
a = self.SendCommand(command, len(str(xpdu.length)) + 14)
command = "%s\x1a" % xpdu.pdu
b = self.SendCommand(command, len(xpdu.pdu) + 20)
data = str(a) + str(b)
self.insertSentitem(self.recipient, self.content, data)
return data
示例15: test_encoding_multipart_7bit
def test_encoding_multipart_7bit(self):
# text encoded with umts-tools
text = "Or walk with Kings - nor lose the common touch, if neither foes nor loving friends can hurt you, If all men count with you, but none too much; If you can fill the unforgiving minute With sixty seconds' worth of distance run, Yours is the Earth and everything thats in it, And - which is more - you will be a Man, my son"
number = "655345678"
expected = [
"005100098156355476F80000AAA00500038803019E72D03DCC5E83EE693A1AB44CBBCF73500BE47ECB41ECF7BC0CA2A3CBA0F1BBDD7EBB41F4777D8C6681D26690BB9CA6A3CB7290F95D9E83DC6F3988FDB6A7DD6790599E2EBBC973D038EC06A1EB723A28FFAEB340493328CC6683DA653768FCAEBBE9A07B9A8E06E5DF7516485CA783DC6F7719447FBF41EDFA18BD0325CDA0FCBB0E1A87DD",
"005100098156355476F80000AAA005000388030240E6349B0DA2A3CBA0BADBFC969FD3F6B4FB0C6AA7DD757A19744DD3D1A0791A4FCF83E6E5F1DB4D9E9F40F7B79C8E06BDCD20727A4E0FBBC76590BCEE6681B2EFBA7C0E4ACF41747419540CCBE96850D84D0695ED65799E8E4EBBCF203A3A4C9F83D26E509ACE0205DD64500B7447A7C768507A0E6ABFE565500B947FD741F7349B0D129741",
"005100098156355476F80000AA14050003880303C2A066D8CD02B5F3A0F9DB0D",
]
sms = SmsSubmit(number, text)
sms.ref = 0x0
sms.rand_id = 136
sms.validity = timedelta(days=4)
ret = sms.to_pdu()
cnt = len(ret)
for i, pdu in enumerate(ret):
self.assertEqual(pdu.pdu, expected[i])
self.assertEqual(pdu.seq, i + 1)
self.assertEqual(pdu.cnt, cnt)