Example #1
0
    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, ImportError):
            _moduleLogger.exception("Pickle fun loading")
            return False
        except:
            _moduleLogger.exception("Weirdness loading")
            return False

        try:
            version, build = dumpedData[0:2]
        except ValueError:
            _moduleLogger.exception("Upgrade/downgrade fun")
            return False
        except:
            _moduleLogger.exception("Weirdlings")
            return False

        if misc_utils.compare_versions(self._OLDEST_COMPATIBLE_FORMAT_VERSION, misc_utils.parse_version(version)) <= 0:
            try:
                (version, build, messages, messageUpdateTime, history, historyUpdateTime, dnd, callback) = dumpedData
            except ValueError:
                _moduleLogger.exception("Upgrade/downgrade fun")
                return False
            except:
                _moduleLogger.exception("Weirdlings")
                return False

            _moduleLogger.info("Loaded cache")
            self._messages = messages
            self._alert_on_messages(self._messages)
            self._messageUpdateTime = messageUpdateTime
            self._history = history
            self._historyUpdateTime = historyUpdateTime
            self._dnd = dnd
            self._callback = callback
            return True
        else:
            _moduleLogger.debug("Skipping cache due to version mismatch (%s-%s)" % (version, build))
            return False
Example #2
0
    def load(self, path):
        _moduleLogger.debug("Loading cache")
        assert not self._numbers
        try:
            with open(path, "rb") as f:
                fileVersion, fileBuild, contacts = pickle.load(f)
        except (pickle.PickleError, IOError, EOFError, ValueError, Exception):
            _moduleLogger.exception("While loading")
            return

        if (
            contacts
            and misc_utils.compare_versions(
                self.OLDEST_COMPATIBLE_FORMAT_VERSION, misc_utils.parse_version(fileVersion)
            )
            <= 0
        ):
            _moduleLogger.info("Loaded cache")
            self._numbers = contacts
            self._loadedFromCache = True
        else:
            _moduleLogger.debug("Skipping cache due to version mismatch (%s-%s)" % (fileVersion, fileBuild))
Example #3
0
	def load(self, path):
		_moduleLogger.debug("Loading cache")
		assert not self._locations
		try:
			with open(path, "rb") as f:
				fileVersion, fileBuild, locs = pickle.load(f)
		except (pickle.PickleError, IOError, EOFError, ValueError, Exception):
			_moduleLogger.exception("While loading for %s" % self._name)
			return

		if misc_utils.compare_versions(
			self.OLDEST_COMPATIBLE_FORMAT_VERSION,
			misc_utils.parse_version(fileVersion),
		) <= 0:
			_moduleLogger.info("Loaded cache")
			self._locations = locs
		else:
			_moduleLogger.debug(
				"Skipping cache due to version mismatch (%s-%s)" % (
					fileVersion, fileBuild
				)
			)