Fix up some bugs in kv handling

This commit is contained in:
Joshua Boniface 2018-09-28 19:34:35 -04:00
parent 2fda346f9b
commit b6eeb5c264
1 changed files with 6 additions and 2 deletions

View File

@ -41,7 +41,11 @@ def writedata(zk_conn, kv):
zk_transaction = zk_conn.transaction()
# Proceed one KV pair at a time
for key, data in kv.items():
for key in sorted(kv):
data = kv[key]
if not data:
data = ''
# Check if this key already exists or not
if not zk_conn.exists(key):
# We're creating a new key
@ -61,7 +65,7 @@ def writedata(zk_conn, kv):
try:
zk_transaction.check(key, new_version)
except TypeError:
print('Zookeeper key "{}" does not match expected version'.format(first_key))
print('Zookeeper key "{}" does not match expected version'.format(key))
return False
# Commit the transaction