Exemplo n.º 1
0
	def create_yaml_file (self, name, data, schema = None):

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

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

        value_yaml = yamlx.encode(schema, value)

        self.set_raw(key, value_yaml)
Exemplo n.º 7
0
    def to_yaml(self, record_data):

        return yamlx.encode(self.schema, record_data)
Exemplo n.º 8
0
	def to_yaml (self, record_data):

		return yamlx.encode (
			self.schema,
			record_data)
Exemplo n.º 9
0
	def set_yaml (self, key, value, schema = None):

		value_yaml = yamlx.encode (schema, value)

		self.set_raw (key, value_yaml)