本文整理汇总了Python中messaging.sms.SmsSubmit.to_pdu方法的典型用法代码示例。如果您正苦于以下问题:Python SmsSubmit.to_pdu方法的具体用法?Python SmsSubmit.to_pdu怎么用?Python SmsSubmit.to_pdu使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类messaging.sms.SmsSubmit
的用法示例。
在下文中一共展示了SmsSubmit.to_pdu方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_encoding_class
# 需要导入模块: from messaging.sms import SmsSubmit [as 别名]
# 或者: from messaging.sms.SmsSubmit import to_pdu [as 别名]
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)
示例2: test_encoding_class
# 需要导入模块: from messaging.sms import SmsSubmit [as 别名]
# 或者: from messaging.sms.SmsSubmit import to_pdu [as 别名]
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)
示例3: to_pdu
# 需要导入模块: from messaging.sms import SmsSubmit [as 别名]
# 或者: from messaging.sms.SmsSubmit import to_pdu [as 别名]
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
# 需要导入模块: from messaging.sms import SmsSubmit [as 别名]
# 或者: from messaging.sms.SmsSubmit import to_pdu [as 别名]
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
# 需要导入模块: from messaging.sms import SmsSubmit [as 别名]
# 或者: from messaging.sms.SmsSubmit import to_pdu [as 别名]
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
# 需要导入模块: from messaging.sms import SmsSubmit [as 别名]
# 或者: from messaging.sms.SmsSubmit import to_pdu [as 别名]
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: generateSmsSubmitPdu
# 需要导入模块: from messaging.sms import SmsSubmit [as 别名]
# 或者: from messaging.sms.SmsSubmit import to_pdu [as 别名]
def generateSmsSubmitPdu(self):
smsPdus = []
smsDelvObj = SmsSubmit(self._address, self._smsText)
smsDelvObj._set_csca(self._smscAddress)
print("Encoding Type:", self._encodingType)
if ( self._encodingType == 0):
smsDelvObj.dcs = 0x00
if ( self._encodingType == 8):
smsDelvObj.dcs = 0x08
for i in smsDelvObj.to_pdu():
smsPdus.append(i.pdu)
return smsPdus
示例8: send_sms
# 需要导入模块: from messaging.sms import SmsSubmit [as 别名]
# 或者: from messaging.sms.SmsSubmit import to_pdu [as 别名]
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
示例9: test_encoding_message_with_latin1_chars
# 需要导入模块: from messaging.sms import SmsSubmit [as 别名]
# 或者: from messaging.sms.SmsSubmit import to_pdu [as 别名]
def test_encoding_message_with_latin1_chars(self):
# tested with pduspy.exe
number = "+34654123456"
text = u"Hölä"
expected = "0011000B914356143254F60000AA04483E7B0F"
sms = SmsSubmit(number, text)
sms.ref = 0x0
sms.validity = timedelta(days=4)
pdu = sms.to_pdu()[0]
self.assertEqual(pdu.pdu, expected)
# tested with pduspy.exe
number = "+34654123456"
text = u"BÄRÇA äñ@"
expected = "0001000B914356143254F6000009C2AD341104EDFB00"
sms = SmsSubmit(number, text)
sms.ref = 0x0
pdu = sms.to_pdu()[0]
self.assertEqual(pdu.pdu, expected)
示例10: test_encoding_ucs2_message
# 需要导入模块: from messaging.sms import SmsSubmit [as 别名]
# 或者: from messaging.sms.SmsSubmit import to_pdu [as 别名]
def test_encoding_ucs2_message(self):
number = "+34616585119"
text = u'あ叶葉'
csca = '+34646456456'
expected = "07914346466554F601000B914316565811F9000806304253F68449"
sms = SmsSubmit(number, text)
sms.ref = 0x0
sms.csca = csca
pdu = sms.to_pdu()[0]
self.assertEqual(pdu.pdu, expected)
text = u"Русский"
number = "655345678"
expected = "001100098156355476F80008AA0E0420044304410441043A04380439"
sms = SmsSubmit(number, text)
sms.ref = 0x0
sms.validity = timedelta(days=4)
pdu = sms.to_pdu()[0]
self.assertEqual(pdu.pdu, expected)
示例11: test_encoding_ucs2_message
# 需要导入模块: from messaging.sms import SmsSubmit [as 别名]
# 或者: from messaging.sms.SmsSubmit import to_pdu [as 别名]
def test_encoding_ucs2_message(self):
number = codecs.decode(b'2b3334363136353835313139', 'hex').decode()
text = u'あ叶葉'
csca = '+34646456456'
expected = "07914346466554F601000B914316565811F9000806304253F68449"
sms = SmsSubmit(number, text)
sms.ref = 0x0
sms.csca = csca
pdu = sms.to_pdu()[0]
self.assertEqual(pdu.pdu, expected)
text = u"Русский"
number = codecs.decode(b'363535333435363738', 'hex').decode()
expected = "001100098156355476F80008AA0E0420044304410441043A04380439"
sms = SmsSubmit(number, text)
sms.ref = 0x0
sms.validity = timedelta(days=4)
pdu = sms.to_pdu()[0]
self.assertEqual(pdu.pdu, expected)
示例12: send_sms
# 需要导入模块: from messaging.sms import SmsSubmit [as 别名]
# 或者: from messaging.sms.SmsSubmit import to_pdu [as 别名]
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()
示例13: test_encoding_validity
# 需要导入模块: from messaging.sms import SmsSubmit [as 别名]
# 或者: from messaging.sms.SmsSubmit import to_pdu [as 别名]
def test_encoding_validity(self):
# no validity
number = "+34616585119"
text = "hola"
expected = "0001000B914316565811F9000004E8373B0C"
sms = SmsSubmit(number, text)
sms.ref = 0x0
pdu = sms.to_pdu()[0]
self.assertEqual(pdu.pdu, expected)
# absolute validity
number = "+34616585119"
text = "hola"
expected = "0019000B914316565811F900000170520251930004E8373B0C"
sms = SmsSubmit(number, text)
sms.ref = 0x0
sms.validity = datetime(2010, 7, 25, 20, 15, 39)
pdu = sms.to_pdu()[0]
self.assertEqual(pdu.pdu, expected)
# relative validity
number = "+34616585119"
text = "hola"
expected = "0011000B914316565811F90000AA04E8373B0C"
expected_len = 18
sms = SmsSubmit(number, text)
sms.ref = 0x0
sms.validity = timedelta(days=4)
pdu = sms.to_pdu()[0]
self.assertEqual(pdu.pdu, expected)
self.assertEqual(pdu.length, expected_len)
示例14: pduformat
# 需要导入模块: from messaging.sms import SmsSubmit [as 别名]
# 或者: from messaging.sms.SmsSubmit import to_pdu [as 别名]
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
示例15: test_encoding_csca
# 需要导入模块: from messaging.sms import SmsSubmit [as 别名]
# 或者: from messaging.sms.SmsSubmit import to_pdu [as 别名]
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)