Пример #1
0
 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
Пример #2
0
 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
Пример #3
0
    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
Пример #4
0
    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
Пример #5
0
    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
Пример #6
0
 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
Пример #7
0
    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)
Пример #8
0
 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)
Пример #9
0
 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)
Пример #10
0
 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