Пример #1
0
 def _load_acknowledgements(self, lock=False):
     return store.load_data_from_file(self._ack_path, {}, lock=lock)
Пример #2
0
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))
Пример #3
0
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
Пример #4
0
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, {})
Пример #5
0
def _load_site_replication_status(site_id, lock=False):
    return store.load_data_from_file(_site_replication_status_path(site_id),
                                     {}, lock)
Пример #6
0
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]
Пример #7
0
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"
Пример #8
0
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"
Пример #9
0
def load_acknowledgements():
    return store.load_data_from_file(acknowledgement_path, [])
Пример #10
0
 def load_from(self, filepath):
     raw_tree = store.load_data_from_file(filepath)
     return self.create_tree_from_raw_tree(raw_tree)
Пример #11
0
 def _load_site_state(self, site_id):
     return store.load_data_from_file(self.site_state_path(site_id), {})
Пример #12
0
 def _load_activation(self):
     self.__dict__.update(store.load_data_from_file(self._info_path(), {}))
Пример #13
0
 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, {})
Пример #14
0
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]
Пример #15
0
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"
Пример #16
0
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
Пример #17
0
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
Пример #18
0
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"
Пример #19
0
 def _do_load_legacy_bookmarks(cls):
     path = config.user.confdir + "/bookmarks.mk"
     return store.load_data_from_file(path, [])