#!/usr/bin/env python
# -*- encoding: utf-8 -*-

import sys
from kazoo.client import KazooClient

ZK_HOSTS = "ppcback01f.yandex.ru,ppcback01e.yandex.ru,ppcback01i.yandex.ru"
ZK_TIMEOUT = 10
ZK_RETRY = {"max_tries": 1, "delay": 1, "max_jitter": 1, "backoff": 1, "ignore_expire": False}
zkh = KazooClient(hosts=ZK_HOSTS, timeout=ZK_TIMEOUT, connection_retry=ZK_RETRY, command_retry=ZK_RETRY)


def run():
    if len(sys.argv) <= 1:
        sys.exit("there are no nodes to delete")

    zkh.start()
    for node in sys.argv[1:]:
        try:
            zkh.delete(node, recursive=True)
        except Exception as e:
            print "ERROR: can't remove %s, %s %s" % (node, type(e), e)

    zkh.stop()
    zkh.close()


if __name__ == '__main__':
     run()
