def _load_acknowledgements(self, lock=False): return store.load_data_from_file(self._ack_path, {}, lock=lock)
def _load_ip_lookup_cache(lock): # type: (bool) -> IPLookupCache return _convert_legacy_ip_lookup_cache( store.load_data_from_file(_cache_path(), default={}, lock=lock))
def test_load_data_not_locked(tmp_path): locked_file = tmp_path / "locked_file" locked_file.write_text(u"[1, 2]", encoding="utf-8") store.load_data_from_file(str(locked_file)) assert store.have_lock(str(locked_file)) is False
def _load_single_oid_cache(snmp_config): # type: (snmp_utils.SNMPHostConfig) -> Dict[str, str] cache_path = "%s/%s.%s" % (cmk.utils.paths.snmp_scan_cache_dir, snmp_config.hostname, snmp_config.ipaddress) return store.load_data_from_file(cache_path, {})
def _load_site_replication_status(site_id, lock=False): return store.load_data_from_file(_site_replication_status_path(site_id), {}, lock)
def test_save_data_to_file(tmpdir): f = tmpdir.join("test") path = "%s" % f store.save_data_to_file(path, [2, 3]) assert store.load_data_from_file(path) == [2, 3]
def test_load_data_from_file_not_existing(tmpdir): data = store.load_data_from_file("%s/x" % tmpdir) assert data is None data = store.load_data_from_file("%s/x" % tmpdir, "DEFAULT") assert data == "DEFAULT"
def test_load_data_from_file_not_existing(tmp_path, path_type): data = store.load_data_from_file(path_type(tmp_path / "x")) assert data is None data = store.load_data_from_file(path_type(tmp_path / "x"), "DEFAULT") assert data == "DEFAULT"
def load_acknowledgements(): return store.load_data_from_file(acknowledgement_path, [])
def load_from(self, filepath): raw_tree = store.load_data_from_file(filepath) return self.create_tree_from_raw_tree(raw_tree)
def _load_site_state(self, site_id): return store.load_data_from_file(self.site_state_path(site_id), {})
def _load_activation(self): self.__dict__.update(store.load_data_from_file(self._info_path(), {}))
def _last_activation_state(self, site_id): manager = ActivateChangesManager() site_state_path = os.path.join(manager.activation_persisted_dir, manager.site_filename(site_id)) return store.load_data_from_file(site_state_path, {})
def test_save_data_to_file(tmp_path, path_type): path = path_type(tmp_path / "test") store.save_data_to_file(path, [2, 3]) assert store.load_data_from_file(path) == [2, 3]
def test_load_data_from_file_empty(tmpdir): locked_file = tmpdir.join("test") locked_file.write("") data = store.load_data_from_file("%s/x" % tmpdir, "DEF") assert data == "DEF"
def test_save_file(tmp_path, path_type): path = path_type(tmp_path.joinpath("lala")) data = ['luläla'] store.save_file(path, repr(data)) assert store.load_data_from_file(str(path)) == data
def test_load_data_not_locked(tmpdir): locked_file = tmpdir.join("locked_file") locked_file.write("[1, 2]") store.load_data_from_file("%s" % locked_file) assert store.have_lock("%s" % locked_file) is False
def test_load_data_from_file_empty(tmp_path, path_type): locked_file = tmp_path / "test" locked_file.write_text(u"", encoding="utf-8") data = store.load_data_from_file(path_type(tmp_path / "x"), "DEF") assert data == "DEF"
def _do_load_legacy_bookmarks(cls): path = config.user.confdir + "/bookmarks.mk" return store.load_data_from_file(path, [])