def test_cme_errors(self):
     raw = '\r\n+CME ERROR: SIM interface not started\r\n'
     self.assertEqual(extract_error(raw)[0], ex.CMEErrorSIMNotStarted)
     raw2 = 'AT+CPIN=1330\r\n\r\n+CME ERROR: operation not allowed\r\n'
     self.assertEqual(extract_error(raw2)[0], ex.CMEErrorOperationNotAllowed)
     raw3 = '\r\n+CME ERROR: SIM busy\r\n'
     self.assertEqual(extract_error(raw3)[0], ex.CMEErrorSIMBusy)
Beispiel #2
0
 def test_cme_errors(self):
     raw = '\r\n+CME ERROR: SIM interface not started\r\n'
     self.assertEqual(extract_error(raw)[0], ex.CMEErrorSIMNotStarted)
     raw2 = 'AT+CPIN=1330\r\n\r\n+CME ERROR: operation not allowed\r\n'
     self.assertEqual(
         extract_error(raw2)[0], ex.CMEErrorOperationNotAllowed)
     raw3 = '\r\n+CME ERROR: SIM busy\r\n'
     self.assertEqual(extract_error(raw3)[0], ex.CMEErrorSIMBusy)
    def handle_waiting(self, data):
        self.waitbuf += data
        
        self.waitbuf = self.process_notifications(self.waitbuf)
        if not self.waitbuf:
            return

        cmdinfo = self.custom.cmd_dict[self.cmd.name]
        match = cmdinfo['end'].search(self.waitbuf)
        if match: # end of response
            log.msg("%s::WAITING: EOR detected, firing deferred" % self)
            if 'echo' in cmdinfo and cmdinfo['echo']:
                m = cmdinfo['echo'].match(self.waitbuf)
                if m:
                    self.waitbuf = self.waitbuf.replace(m.group(), '', 1)
            
            if cmdinfo['extract']:
                # There's an regex to extract info from data
                response = list(re.finditer(cmdinfo['extract'], self.waitbuf))
                resp_repr = str([m.groups() for m in response])
                log.msg("%s::WAITING: CBK = %s" % (self, resp_repr))
                self.notify_success(response)
                
                # now clean self.waitbuf
                for _m in response:
                    self.waitbuf = self.waitbuf.replace(_m.group(), '', 1)
                # now clean end of command
                endmatch = cmdinfo['end'].search(self.waitbuf)
                if endmatch:
                    self.waitbuf = self.waitbuf.replace(endmatch.group(),
                                                        '', 1)
            else:
                # there's no regex in cmdinfo to extract info
                cdata = clean_data(self.waitbuf)
                log.msg("%s::WAITING: NO CBK REG, CBK= %s" % (self, cdata))
                self.notify_success(cdata)
                self.waitbuf = self.waitbuf.replace(match.group(), '', 1)
            
            self.transition_to_idle()
        else:
            match = extract_error(self.waitbuf)
            if match:
                excep, error, m = match
                log.err("%s::WAITING: ERROR received %r" % (self, m.group()))
                # send the failure back
                self.notify_failure(Failure(excep(error)))
                self.waitbuf = self.waitbuf.replace(m.group(), '', 1)
                self.transition_to_idle()
            else:
                match = SPLIT_PROMPT.match(data)
                if match:
                    log.msg("%s::WAITING: Split CMD detected" % self)
                    self.send_splitcmd()
                    self.waitbuf = self.waitbuf.replace(match.group(), '', 1)
                else:
                    msg  = "%s::WAITING: Data %s didn't match my regexp"
                    log.err(msg % (self, data))
    def handle_waiting(self, data):
        self.waitbuf += data

        self.waitbuf = self.process_notifications(self.waitbuf)
        if not self.waitbuf:
            return

        cmdinfo = self.custom.cmd_dict[self.cmd.name]
        match = cmdinfo['end'].search(self.waitbuf)
        if match:  # end of response
            log.msg("%s::WAITING: EOR detected, firing deferred" % self)
            if 'echo' in cmdinfo and cmdinfo['echo']:
                m = cmdinfo['echo'].match(self.waitbuf)
                if m:
                    self.waitbuf = self.waitbuf.replace(m.group(), '', 1)

            if cmdinfo['extract']:
                # There's an regex to extract info from data
                response = list(re.finditer(cmdinfo['extract'], self.waitbuf))
                resp_repr = str([m.groups() for m in response])
                log.msg("%s::WAITING: CBK = %s" % (self, resp_repr))
                self.notify_success(response)

                # now clean self.waitbuf
                for _m in response:
                    self.waitbuf = self.waitbuf.replace(_m.group(), '', 1)
                # now clean end of command
                endmatch = cmdinfo['end'].search(self.waitbuf)
                if endmatch:
                    self.waitbuf = self.waitbuf.replace(
                        endmatch.group(), '', 1)
            else:
                # there's no regex in cmdinfo to extract info
                cdata = clean_data(self.waitbuf)
                log.msg("%s::WAITING: NO CBK REG, CBK= %s" % (self, cdata))
                self.notify_success(cdata)
                self.waitbuf = self.waitbuf.replace(match.group(), '', 1)

            self.transition_to_idle()
        else:
            match = extract_error(self.waitbuf)
            if match:
                excep, error, m = match
                log.err("%s::WAITING: ERROR received %r" % (self, m.group()))
                # send the failure back
                self.notify_failure(Failure(excep(error)))
                self.waitbuf = self.waitbuf.replace(m.group(), '', 1)
                self.transition_to_idle()
            else:
                match = SPLIT_PROMPT.match(data)
                if match:
                    log.msg("%s::WAITING: Split CMD detected" % self)
                    self.send_splitcmd()
                    self.waitbuf = self.waitbuf.replace(match.group(), '', 1)
                else:
                    msg = "%s::WAITING: Data %s didn't match my regexp"
                    log.err(msg % (self, data))
Beispiel #5
0
 def test_cms_errors(self):
     raw = '\r\n+CMS ERROR: 500\r\n'
     self.assertEqual(extract_error(raw)[0], ex.CMSError500)
     raw2 = '\r\n+CMS ERROR: 301\r\n'
     self.assertEqual(extract_error(raw2)[0], ex.CMSError301)
 def test_cms_errors(self):
     raw = '\r\n+CMS ERROR: 500\r\n'
     self.assertEqual(extract_error(raw)[0], ex.CMSError500)
     raw2 = '\r\n+CMS ERROR: 301\r\n'
     self.assertEqual(extract_error(raw2)[0], ex.CMSError301)