+ return loadedFromCache
+
+ def _load_from_cache(self):
+ if self._cachePath is None:
+ return False
+ cachePath = os.path.join(self._cachePath, "%s.cache" % self._username)
+
+ try:
+ with open(cachePath, "rb") as f:
+ dumpedData = pickle.load(f)
+ except (pickle.PickleError, IOError, EOFError, ValueError):
+ _moduleLogger.exception("Pickle fun loading")
+ return False
+ except:
+ _moduleLogger.exception("Weirdness loading")
+ return False
+
+ (
+ version, build,
+ contacts, messages, history, dnd, callback
+ ) = dumpedData
+
+ if misc_utils.compare_versions(
+ self._OLDEST_COMPATIBLE_FORMAT_VERSION,
+ misc_utils.parse_version(version),
+ ) <= 0:
+ _moduleLogger.info("Loaded cache")
+ self._contacts = contacts
+ self._messages = messages
+ self._history = history
+ self._dnd = dnd
+ self._callback = callback
+ return True
+ else:
+ _moduleLogger.debug(
+ "Skipping cache due to version mismatch (%s-%s)" % (
+ version, build
+ )
+ )
+ return False
+