Пример #1
0
 def test_cme_errors_string(self):
     raw = '\r\n+CME ERROR: SIM interface not started\r\n'
     self.assertEqual(extract_error(raw)[0], E.SimNotStarted)
     raw2 = 'AT+CPIN=1330\r\n\r\n+CME ERROR: operation not allowed\r\n'
     self.assertEqual(extract_error(raw2)[0], E.OperationNotAllowed)
     raw3 = '\r\n+CME ERROR: SIM busy\r\n'
     self.assertEqual(extract_error(raw3)[0], E.SimBusy)
Пример #2
0
 def test_cme_errors_numeric(self):
     raw = '\r\n+CME ERROR: 30\r\n'
     self.assertEqual(extract_error(raw)[0], E.NoNetwork)
     raw = '\r\n+CME ERROR: 100\r\n'
     self.assertEqual(extract_error(raw)[0], E.Unknown)
     raw = '\r\n+CME ERROR: 14\r\n'
     self.assertEqual(extract_error(raw)[0], E.SimBusy)
Пример #3
0
 def test_cms_errors(self):
     raw = '\r\n+CMS ERROR: 500\r\n'
     self.assertEqual(extract_error(raw)[0], E.CMSError500)
     raw2 = '\r\n+CMS ERROR: 301\r\n'
     self.assertEqual(extract_error(raw2)[0], E.CMSError301)
Пример #4
0
                # 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
                log.msg("%s: no callback registered" % self.state)
                self.notify_success(self.waitbuf)
                self.waitbuf = self.waitbuf.replace(match.group(), '', 1)

            self.transition_to_idle()
        else:
            # there is no end of response detected, so we have either an error
            # or a split command (like send_sms, save_sms, etc.)
            match = E.extract_error(self.waitbuf)
            if match:
                exception, error, m = match
                e = exception(error)
                log.err(e, "waiting")
                # send the failure back
                self.notify_failure(Failure(e))
                # remove the exception string from the waitbuf
                self.waitbuf = self.waitbuf.replace(m.group(), '', 1)
                self.transition_to_idle()
            else:
                match = SPLIT_PROMPT.search(data)
                if match:
                    log.msg("waiting: split command prompt detected")
                    self.send_splitcmd()
                    self.waitbuf = self.waitbuf.replace(match.group(), '', 1)