def create_yaml_file (self, name, data, schema = None): content = ( yamlx.encode ( schema, data)) return self.create_file ( name, content.strip ().split ("\n"))
def write_cache_metadata(self): self.cache_metadata["modified-index"] = (unicode(self.modified_index)) with open ("%s/metadata.temp" % self.cache_path, "w") \ as file_handle: file_handle.write(yamlx.encode(None, self.cache_metadata)) os.rename("%s/metadata.temp" % self.cache_path, "%s/metadata" % self.cache_path)
def set_yaml_if_not_modified ( self, key, value, index, schema = None): value_yaml = ( yamlx.encode ( schema, value)) self.set_raw_if_not_modified ( key, value_yaml, index)
def watch_thread(self): self.connection.value = None self.connection.ssl_context = None self.connection.servers = list(self.servers) while True: result, data, modified_index = (self.make_request( method="GET", url=self.key_url(""), query_data={ "recursive": "true", "wait": "true", "waitIndex": unicode(self.modified_index + 1), }, accept_response=[200])) log.output(yamlx.encode(None, data)) self.cache_metadata["modified-index"] = (modified_index) self.update_cache(data["node"], "")
def set_yaml_if_not_modified(self, key, value, index, schema=None): value_yaml = (yamlx.encode(schema, value)) self.set_raw_if_not_modified(key, value_yaml, index)
def set_yaml(self, key, value, schema=None): value_yaml = yamlx.encode(schema, value) self.set_raw(key, value_yaml)
def to_yaml(self, record_data): return yamlx.encode(self.schema, record_data)
def to_yaml (self, record_data): return yamlx.encode ( self.schema, record_data)
def set_yaml (self, key, value, schema = None): value_yaml = yamlx.encode (schema, value) self.set_raw (key, value_yaml)