def tearDown(self): client = doozer.connect() try: delete_all(client, self.TESTROOT) except NoEntity: pass client.disconnect() TestBase.tearDown(self)
def test_doozerdata(): client = doozer.connect() d = DoozerData(client, callback=print_change) d.set('foo1', 'bar1') d.set('foo2', 'bar2') d.set('foo3', 'bar3') # create a second client client2 = doozer.connect() d2 = DoozerData(client2, callback=print_change) d2.set('foo4', 'bar4') # let the second client change values to # those should be printed. cv = gevent.spawn(change_value, d2) for path, rev, value in d.items(): print path, '->', value print d.get('foo1').value print d.get('foo2').value d.delete_all() # should be empty. print '--------' for di in d.items(): print di assert [k for k, v in d.items()] == [] print '--------' # the change value adds content over time.. gevent.sleep(3) print 'data in d1' for di in d.items(): print di print 'data in d2' for dii in d2.items(): print dii # there is content. in both instances. # because the change_value job adds data later. cv.join(cv) d.delete_all()
def test_doozerdata(): client = doozer.connect() d = DoozerData(client, callback=print_change) d.set('foo1', 'bar1') d.set('foo2', 'bar2') d.set('foo3', 'bar3') #create a second client client2 = doozer.connect() d2 = DoozerData(client2, callback=print_change) d2.set('foo4', 'bar4') #let the second client change values to #those should be printed. cv = gevent.spawn(change_value, d2) for path, rev, value in d.items(): print path, '->', value print d.get('foo1') print d.get('foo2') d.delete_all() #should be empty. for di in d.items(): print di #the change value function added content over time.. gevent.sleep(3) print 'data in d1' for di in d.items(): print di print 'data in d2' for dii in d2.items(): print dii # there is content. in both instances. # because the change_value job adds data later. cv.join(cv)
def test_doozerdata(): client = doozer.connect() d = DoozerData(client, callback=print_change) d.set("foo1", "bar1") d.set("foo2", "bar2") d.set("foo3", "bar3") # create a second client client2 = doozer.connect() d2 = DoozerData(client2, callback=print_change) d2.set("foo4", "bar4") # let the second client change values to # those should be printed. cv = gevent.spawn(change_value, d2) for path, rev, value in d.items(): print path, "->", value print d.get("foo1") print d.get("foo2") d.delete_all() # should be empty. for di in d.items(): print di # the change value function added content over time.. gevent.sleep(3) print "data in d1" for di in d.items(): print di print "data in d2" for dii in d2.items(): print dii # there is content. in both instances. # because the change_value job adds data later. cv.join(cv)
# @@protoc_insertion_point(class_scope:server.Response) # @@protoc_insertion_point(module_scope) ########NEW FILE######## __FILENAME__ = client #!/usr/bin/python import os import sys sys.path.append(os.path.dirname(__file__) + "/..") import doozer client = doozer.connect() rev = client.set("/foo", "test", 0).rev print "Setting /foo to test with rev %s" % rev foo = client.get("/foo") print "Got /foo with %s" % foo.value root = client.getdir("/") print "Directly under / is %s" % ', '.join([file.path for file in root]) client.delete("/foo", rev) print "Deleted /foo" foo = client.get("/foo") print repr(foo)
import os import sys sys.path.append(os.path.dirname(__file__) + "/..") import gevent import doozer import simplejson from gevent import Timeout client = doozer.connect() #clean out the foo dir. walk = client.walk("/foo/**") for node in walk: client.delete(node.path, node.rev) rev = client.set("/foo/bar", "test", 0).rev def watch_test(rev): while True: try: change = client.wait("/foo/**", rev ) print "saw change at %s with %s" % ( change.rev, change.value) rev = change.rev+1 except Timeout, t: change = None print t rev = client.rev().rev #rev =+1
def __init__(self, doozer_uri, schema, root='/configdb', timeout=30): self.conn = doozer.connect(doozer_uri, timeout) self.schema = schema self.root = root