Пример #1
0
    def exists(self, path, watcher=None):
        """Return the state of the node of the given path.

        If the watcher is not None and the call is successful (no exception is
        thrown), a watch will be left on the node with the given path. The
        watch will be triggered by a successful operation that creates/delete
        the node or sets the data on the node.

        :Parameters:
            - `path`: node path
            - `watcher`: (optional) watcher function

        :Returns:
            Stat object of the node of the given path; returns None if no such
            node exists.

        :Exceptions:
            TODO
        """
        if watcher:
            stat = _zookeeper.exists(self.zk_handle, path,
				     self._wrap_watcher(watcher))
        else:
            stat = _zookeeper.exists(self.zk_handle, path)

	if stat is not None:
	    return Stat(**stat)
	else:
	    return None
Пример #2
0
 def set_watcher():
     def fn(): self.callback_flag = True
     self.callback_flag = False
     zookeeper.exists(self.handle, "/zk-python-lose-scope-test",
                      self.create_callback( lambda handle, type, state, path: fn() )
                      )
Пример #3
0
 def test_sync_nexists(self):
     self.assertEqual(None, zookeeper.exists(self.handle, "/i-dont-exist", None))
Пример #4
0
 def test_sync_exists(self):
     self.assertEqual(self.connected, True)
     ret = zookeeper.exists(self.handle, "/zk-python-existstest", None)
     self.assertNotEqual(ret, None, "/zk-python-existstest does not exist (possibly means creation failure)")