_moduleLogger = logging.getLogger(__name__)
+class ConversationError(RuntimeError):
+
+ pass
+
+
class Conversations(object):
OLDEST_COMPATIBLE_FORMAT_VERSION = misc_utils.parse_version("0.8.0")
markAllAsRead = False
else:
markAllAsRead = True
+
try:
mergedConversations.append_conversation(conversation, markAllAsRead)
isConversationUpdated = True
+ except ConversationError, e:
+ isConversationUpdated = False
+ except AssertionError, e:
+ _moduleLogger.debug("%s Skipping conversation for %r because '%s'" % (self._name, key, e))
+ isConversationUpdated = False
except RuntimeError, e:
- if False:
- _moduleLogger.debug("%s Skipping conversation for %r because '%s'" % (self._name, key, e))
+ _moduleLogger.debug("%s Skipping conversation for %r because '%s'" % (self._name, key, e))
isConversationUpdated = False
if isConversationUpdated:
# * We cache to disk the history of messages sent/received
# * On first run we mark all server messages as read due to no cache
# * If not first load or from cache (disk or in-memory) then it must be unread
- if markAllAsRead:
- newConversation.isRead = True
- else:
- newConversation.isRead = False
+ if newConversation.type != newConversation.TYPE_VOICEMAIL:
+ if markAllAsRead:
+ newConversation.isRead = True
+ else:
+ newConversation.isRead = False
if newConversation.messages:
# must not have had all items removed due to duplicates
)
if newConversation.time <= self._conversations[-1].time:
- raise RuntimeError("Conversations got out of order")
+ raise ConversationError("Conversations got out of order")
def _find_related_conversation(self, convId):
similarConversations = (
if filteredConversations and self._lastMessageTimestamp < filteredConversations[0].time:
self._lastMessageTimestamp = filteredConversations[0].time
return filteredConversations
+
+
+def print_conversations(path):
+ import pprint
+
+ try:
+ with open(path, "rb") as f:
+ fileVersion, fileBuild, convs = pickle.load(f)
+ except (pickle.PickleError, IOError, EOFError, ValueError):
+ _moduleLogger.exception("")
+ else:
+ for key, value in convs.iteritems():
+ convs[key] = value.to_dict()
+ pprint.pprint((fileVersion, fileBuild))
+ pprint.pprint(convs)