def create_yaml_file (self, name, data, schema = None):

		content = (
			yamlx.encode (
				schema,
				data))

		return self.create_file (
			name,
			content.strip ().split ("\n"))
Exemple #2
0
    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)
Exemple #4
0
    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"], "")
Exemple #5
0
    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)
Exemple #6
0
    def set_yaml(self, key, value, schema=None):

        value_yaml = yamlx.encode(schema, value)

        self.set_raw(key, value_yaml)
Exemple #7
0
    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)