def _config_changed(self): """ Writes True or False to 'self._config_changed' depending if the config has changed The comparison are done over a sha1 checksum, which saved on the HD """ logging.info("Check if config-file has changed") self._hexdigest = get_hash(self._path_config) saved_hash = '' try: with open(self._path_hash, 'r') as f: saved_hash = f.read() saved_hash[:-1] except FileNotFoundError: logging.info("No hash key for config-file: '" + self._path_config + "'") if self._hexdigest == saved_hash: logging.info("config-file has not changed") self._config_changed = False else: logging.info("config-file has changed") self._config_changed = True
def get_hash(self, sub_path): return utils.get_hash("%s%s" % (self.path, sub_path))