def save(cls): """Save all the phone contacts""" logger.info("Saving phone messages") messages = tichy.Service('Messages').messages data = [c.to_dict() for c in messages if isinstance(c, PhoneMessage)] tichy.Persistance('messages/Phone').save(data) yield None
def save(cls): """Save all the phone contacts""" LOGGER.info("Saving phone contacts") contacts = tichy.Service('Contacts').contacts data = [c.to_dict() for c in contacts if isinstance(c, PhoneContact)] tichy.Persistance('contacts/phone').save(data) yield None
def _save_all(self): logger.info("save all messages") #for x in self.messages: #print x.msg_hash #print x.sim_index data = [x.to_dict() for x in self.messages] #print dir(data) #print data.keys() tichy.Persistance('messages/phone').save(data) yield None
def load(cls): """Load all the phone contacts Return a list of all the contacts """ LOGGER.info("Loading phone contacts") ret = [] data = tichy.Persistance('contacts/phone').load() for kargs in data: contact = PhoneContact(**kargs) ret.append(contact) yield ret
def load(cls): """Load all the phone contacts Return a list of all the contacts """ logger.info("Loading phone messages") ret = [] data = tichy.Persistance('messages/phone').load() for kargs in data: message = PhoneMessage(**kargs) ret.append(message) yield ret
def _load_logs(self): """Load all the logs""" LOGGER.info("Loading call logs") data = tichy.Persistance('calls/logs').load() if not data: return # TODO: add some checks for data consistency logs = [] for kargs in data: #print kargs call = Call(**kargs) logs.append(call) self.logs[:] = logs
def load_all(cls): """Load all the phone msgs Return a list of all the contacts """ logger.info("Loading phone messages") ret = [] data = tichy.Persistance('messages/phone').load() for kargs in data: try: message = PhoneMessage(**kargs) ret.append(message) except Exception, ex: logger.error("can't create message : %s", ex)
def _load_all(self): logger.info("load all messages") """load all the messages from all sources""" # TODO: make this coherent with contacts service method data = tichy.Persistance('messages').load() if not data: yield None # TODO: check for data coherence all_messages = [] for kargs in data: message = Message(**kargs) all_messages.append(message) logger.info("got %d messages", len(all_messages)) for m in all_messages: # XXX: we need to rethink all this stuff... if m.direction == 'in': self.add_to_inbox(m) elif m.direction == 'out': self.add_to_outbox(m)
def _save_logs(self): """Save the logs into a file""" LOGGER.info("Saving call logs") data = [c.to_dict() for c in self.logs] tichy.Persistance('calls/logs').save(data)
def _save_all(self): logger.info("save all messages") data = [x.to_dict() for x in self.inbox + self.outbox] tichy.Persistance('messages').save(data) yield None