def get_sms_cb(rawsms): try: sms = pdu_to_message(rawsms[0].group('pdu')) sms.where = int(rawsms[0].group('storedat')) sms.index = index except IndexError: # handle bogus CMTI notifications, see #180 return None return sms
def get_all_sms_cb(messages): sms_list = [] for rawsms in messages: # ShortMessage obj try: sms = pdu_to_message(rawsms.group('pdu')) except ValueError, traceback: # raise ex.MalformedSMSError(rawsms.group('pdu')) pass else: sms.index = int(rawsms.group('id')) sms.where = int(rawsms.group('storedat')) sms_list.append(sms)