def restore_zk(handle, zk_persist_file):
  for line in zk_persist_file.readlines():
    pair = json.loads(line)
    path = pair.keys()[0]
    value = pair.values()[0].decode('base64')
    try:
      handle.create(path, bytes(value), makepath=True)
      logging.debug("Created '{0}'".format(path))
    except kazoo.exceptions.NodeExistsError:
      try:
        handle.set(path, bytes(value))
        logging.debug("Updated '{0}'".format(path))
      except kazoo.exceptions.BadArgumentsError:
        logging.warning("BadArgumentsError for path '{0}'".format(path))
    except kazoo.exceptions.NoNodeError:
      logging.warning("NoNodeError for path '{0}'. Parent nodes are "
        "missing".format(path))
    except kazoo.exceptions.ZookeeperError:
      logging.warning("ZookeeperError for path '{0}'".format(path))
Restores Zookeeper data from a fixed file in the local FS.
dataset/ETHPy150Open AppScale/appscale/AppDB/backup/zookeeper_backup.py/restore_zk