def listen(self): try: sms = self.text_parser.one() except RuntimeError as e: logger.log_error(self, e.message) return False if sms is None: logger.log_error(self, "Connection to android device is broken") logger.log_error(self, "Exiting read loop, closing socket") self.cleanup() return False logger.log_receive(self, sms) self.receive_callback(sms)
def listen(self): sms_count = len(self.sms_queue) # if i'm out of things, i need to get some more! if sms_count == 0: sms_count = self.fill_queue() # but if it is _still_ 0... if sms_count == 0: time.sleep(self.POLL_TIMEOUT) else: received_sms = self.sms_queue.popleft() logger.log_receive(self, received_sms) self.receive_callback(received_sms) time.sleep(.1)
def listen(self): print "Enter Your SMS:" sms_dict = {} sms_dict['to_number'] = raw_input("To: ") sms_dict['from_number'] = raw_input("From: ") sms_dict['body'] = raw_input("Body:\n") if sms_dict['to_number'] == "DO:QUIT": return False sms = SMS.from_dictionary(sms_dict) logger.log_receive(self, sms) self.receive_callback(sms)
def listen(self): """ If there is an SMS in the queue, will pass it downstream. Otherwise, it will attempt to GET more SMSs. If it is unable, it will sleep for POLL_TIMEOUT seconds """ sms_count = len(self.sms_queue) # If the queue is empty, I must try to download more if sms_count == 0: sms_count = self.fill_queue() # If it is _still_ empty... if sms_count == 0: time.sleep(self.POLL_TIMEOUT) else: received_sms = self.sms_queue.popleft() logger.log_receive(self, received_sms) self.receive_callback(received_sms)
def listen(self): """ Used STDIN and STDOUT to get string values for the to, from, and body attributes of the sms to build. Will return False if the To parameter is 'DO:QUIT' """ print "Enter Your SMS:" sms_dict = {} sms_dict['to_number'] = raw_input("To: ") sms_dict['from_number'] = raw_input("From: ") sms_dict['body'] = raw_input("Body:\n") if sms_dict['to_number'] == "DO:QUIT": return False sms = SMS.from_dictionary(sms_dict) logger.log_receive(self, sms) self.receive_callback(sms)
def listen(self): """ Obtains one SMS from the TextParser. It handles parse errors (RuntimeError), but does handle socket errors that may appear. If the sms received from the parser is None, it will assume a broken connection, and, making no value judgements about it, quit, calling cleanup() in the process. """ try: sms = self.text_parser.one() except RuntimeError as e: logger.log_error(self, e.message) return False if sms is None: logger.log_error(self, "Connection to android device is broken") logger.log_error(self, "Exiting read loop, closing socket") self.cleanup() return False logger.log_receive(self, sms) self.receive_callback(sms)