コード例 #1
0
ファイル: __init__.py プロジェクト: duncf/zkpython
    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
ファイル: callback_test.py プロジェクト: duncf/zkpython
 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
ファイル: exists_test.py プロジェクト: duncf/zkpython
 def test_sync_nexists(self):
     self.assertEqual(None, zookeeper.exists(self.handle, "/i-dont-exist", None))
コード例 #4
0
ファイル: exists_test.py プロジェクト: duncf/zkpython
 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)")