def _generic_callback(async_result, handle, code, *args): if code != zookeeper.OK: exc = err_to_exception(code) async_result.set_exception(exc) else: if not args: result = None elif len(args) == 1: if isinstance(args[0], dict): # It's a node struct, put it in a ZnodeStat result = ZnodeStat(**args[0]) else: result = args[0] else: # if there's two, the second is a stat object args = list(args) if len(args) == 2 and isinstance(args[1], dict): args[1] = ZnodeStat(**args[1]) result = tuple(args) async_result.set(result)
def _exists_callback(async_result, handle, code, stat): if code not in (zookeeper.OK, zookeeper.NONODE): exc = err_to_exception(code) async_result.set_exception(exc) else: async_result.set(stat)
def _makeOne(self, *args, **kwargs): from kazoo.exceptions import err_to_exception return err_to_exception(*args, **kwargs)