[pkg-fso-commits] [SCM] FSO frameworkd Debian packaging branch, master, updated. milestone4-368-g700ab82
Daniel Willmann
daniel at totalueberwachung.de
Mon Feb 2 18:51:16 UTC 2009
The following commit has been merged in the master branch:
commit a737603223cecb02a4108af7164717c28eaa1ed4
Author: Daniel Willmann <daniel at totalueberwachung.de>
Date: Fri Nov 14 01:11:15 2008 +0100
ogsmd: Introduce SMSError and use it
SMSError will be raised if SMS parsing/generation fails. Currently only
used if the PDU is malformed (which shouldn't happen, but does - see
http://trac.freesmartphone.org/ticket/227)
diff --git a/framework/subsystems/ogsmd/gsm/sms.py b/framework/subsystems/ogsmd/gsm/sms.py
index 726ea54..e524534 100644
--- a/framework/subsystems/ogsmd/gsm/sms.py
+++ b/framework/subsystems/ogsmd/gsm/sms.py
@@ -15,6 +15,9 @@ from ogsmd.gsm.convert import *
from ogsmd.gsm.const import CB_PDU_DCS_LANGUAGE
import math
+class SMSError(Exception):
+ pass
+
# ** Dekodieren
# smsobject = decodeSMS( pdu )
# print "von", smsobject.sender(), "um", smsobject.arrivalTime(), "via" smsobject.serviceCenter(), ...
@@ -29,7 +32,10 @@ import math
def decodeSMS( pdu, direction ):
# first convert the string into a bytestream
- bytes = [ int( pdu[i:i+2], 16 ) for i in range(0, len(pdu), 2) ]
+ try:
+ bytes = [ int( pdu[i:i+2], 16 ) for i in range(0, len(pdu), 2) ]
+ except ValueError:
+ raise SMSError, "PDU malformed"
sms = AbstractSMS( direction )
@@ -551,15 +557,18 @@ if __name__ == "__main__":
def testpdu(pdu, dir):
- sms = decodeSMS(pdu, dir)
- genpdu = sms.pdu()
- if pdu != genpdu:
- print "ERROR: Reencoded SMS doesn't match"
- print "Orig PDU: ", pdu
- print "ReencPDU: ", genpdu
+ try:
+ sms = decodeSMS(pdu, dir)
+ genpdu = sms.pdu()
+ if pdu != genpdu:
+ print "ERROR: Reencoded SMS doesn't match"
+ print "Orig PDU: ", pdu
+ print "ReencPDU: ", genpdu
+ print sms.repr()
+ sms = decodeSMS(genpdu, dir)
print sms.repr()
- sms = decodeSMS(genpdu, dir)
- print sms.repr()
+ except SMSError, e:
+ print "%s, PDU was: %s\n" % (e, pdu)
for pdu in pdus_MT:
testpdu(pdu, "MT")
--
FSO frameworkd Debian packaging
More information about the pkg-fso-commits
mailing list