@@ -0,0 +1,2635 @@
+#%0A# arcus-python-client - Arcus python client drvier%0A# Copyright 2014 NAVER Corp.%0A#%0A# Licensed under the Apache License, Version 2.0 (the %22License%22);%0A# you may not use this file except in compliance with the License.%0A# You may obtain a copy of the License at%0A#%0A# http://www.apache.org/licenses/LICENSE-2.0%0A#%0A# Unless required by applicable law or agreed to in writing, software%0A# distributed under the License is distributed on an %22AS IS%22 BASIS,%0A# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A# See the License for the specific language governing permissions and%0A# limitations under the License.%0A#%0A %0Afrom kazoo.client import KazooClient%0Aimport kazoo%0Aimport sys, os, time%0Aimport re%0Afrom optparse import OptionParser%0A%0A%0Adef do_zookeeper_read(addr, path):%0A%09print(path)%0A%09zk = KazooClient(addr)%0A%09zk.start()%0A%09data, stat = zk.get(path)%0A%09print('node info:', data)%0A%09print('node stat:', stat)%0A%0A%09children = zk.get_children(path)%0A%09print('node children:', children)%0A%0Adef do_zookeeper_create(addr, path, value):%0A%09print(path)%0A%09zk = KazooClient(addr)%0A%09zk.start()%0A%09zk.create(path, bytes(value, 'utf-8'))%0A%0A%09do_zookeeper_read(addr, path)%0A%0Adef do_zookeeper_delete(addr, path):%0A%09print(path)%0A%09zk = KazooClient(addr)%0A%09zk.start()%0A%09zk.delete(path)%0A%0A%09try:%0A%09%09do_zookeeper_read(addr, path)%0A%09except kazoo.exceptions.NoNodeError:%0A%09%09print('deleted')%0A%09%0Adef do_zookeeper_update(addr, path, value):%0A%09print(path)%0A%09zk = KazooClient(addr)%0A%09zk.start()%0A%09zk.set(path, bytes(value, 'utf-8'))%0A%0A%09do_zookeeper_read(addr, path)%0A%0A%0Aif __name__ == '__main__':%0A%0A%0A%09usage = %22usage: %25prog %5Boptions%5D%22%0A%09parser = OptionParser(usage=usage, version=%22%25prog 1.0%22)%0A%09parser.add_option('-a', '--address', dest='address', default='', help='zookeeper address')%0A%09parser.add_option('-n', '--node', dest='node', default='', help='zookeeper node path')%0A%09parser.add_option('-r', '--read', dest='read', default=False, help='zookeeper node read', action='store_true')%0A%09parser.add_option('-c', '--create', dest='create', default='', help='zookeeper node create')%0A%09parser.add_option('-d', '--delete', dest='delete', default=False, help='zookeeper node delete', action='store_true')%0A%09parser.add_option('-u', '--update', dest='update', default='', help='zookeeper node update')%0A%0A%09(options, args) = parser.parse_args()%0A%0A%09if options.read:%0A%09%09do_zookeeper_read(options.address, options.node)%0A%09elif options.create != '':%0A%09%09do_zookeeper_create(options.address, options.node, options.create)%0A%09elif options.delete:%0A%09%09do_zookeeper_delete(options.address, options.node)%0A%09elif options.update != '':%0A%09%09do_zookeeper_update(options.address, options.node, options.update)%0A%0A%0A%09parser.print_usage();%0A%0A

add zk_util.py