Exemple #1
0
    def _load_cache(self):
        """Load existing cache and merge for updating if required."""
        if not self._disable_cache and os.path.exists(self._cache_path):
            _LOGGER.debug("Cache found at: %s", self._cache_path)
            loaded_cache = UTILS.load_cache(self._cache_path)

            UTILS.update(self._cache, loaded_cache)

        self._save_cache()
Exemple #2
0
    def _load_cache(self):
        """Load existing cache and merge for updating if required."""
        if not self._disable_cache:
            if os.path.exists(self._cache_path):
                _LOGGER.debug("Cache found at: %s", self._cache_path)
                if os.path.getsize(self._cache_path) > 0:
                    loaded_cache = UTILS.load_cache(self._cache_path)
                    UTILS.update(self._cache, loaded_cache)
                else:
                    _LOGGER.debug("Cache file is empty.  Removing it.")
                    os.remove(self._cache_path)

        self._save_cache()
Exemple #3
0
    def update(self,
               device_json=None,
               info_json=None,
               settings_json=None,
               avatar_json=None):
        """Update the internal device json data."""
        if device_json:
            UTILS.update(self._device_json, device_json)

        if avatar_json:
            UTILS.update(self._avatar_json, avatar_json)

        if info_json:
            UTILS.update(self._info_json, info_json)

        if settings_json:
            UTILS.update(self._settings_json, settings_json)
Exemple #4
0
 def update_cache(self, data):
     """Update a cached value."""
     UTILS.update(self._cache, data)
     self._save_cache()