<commit_before>from kazoo.client import KazooClient
import json, os, random, string
import MySQLdb

def retrieveDbSettings(data):
	dbs = {}
	for db in data["servers"]:
		dbs[db["name"]] = {"host":db['host'], "port":db['port'], "user":db['user'], "password":db['password']}
	return dbs

def dbSetup(zk,data,zkNode):
	dbsProps = retrieveDbSettings(data)
	dbs = []
	for dbName in dbsProps:
		print "Setting up DB \'"+ dbName+"\'"
		db = dbsProps[dbName]
		addApiDb(dbName, db)
		jdbcString = "jdbc:mysql:replication://HOST:PORT,HOST:PORT/?characterEncoding=utf8&useServerPrepStmts=true&logger=com.mysql.jdbc.log.StandardLogger&roundRobinLoadBalance=true&transformedBitIsBoolean=true&rewriteBatchedStatements=true"
		jdbcString = jdbcString.replace("HOST", db["host"]).replace("PORT",str(db["port"]));
		del(db["host"])
		del(db["port"])
		db['jdbc'] = jdbcString
		db['name'] = dbName
		dbs.append(db)
	dbcpObj = {"dbs": dbs}
	zk.ensure_path(zkNode)
	zk.set(zkNode,json.dumps(dbcpObj))


def memcachedSetup(zk, data, zkNode):
	servers = []
	print "Setting up memcache servers"
	for server in data["servers"]:
		host = server['host']
		port = server['port']
		serverStr = host+":"+str(port)
		servers.append(serverStr)
	zk.ensure_path(zkNode)
	zk.set(zkNode,str(",".join(servers)))
<commit_msg>memcached zookeeper settings fixed to use the new format<commit_after>from kazoo.client import KazooClient
import json, os, random, string
import MySQLdb
import sys

def retrieveDbSettings(data):
	dbs = {}
	for db in data["servers"]:
		dbs[db["name"]] = {"host":db['host'], "port":db['port'], "user":db['user'], "password":db['password']}
	return dbs

def dbSetup(zk,data,zkNode):
	dbsProps = retrieveDbSettings(data)
	dbs = []
	for dbName in dbsProps:
		print "Setting up DB \'"+ dbName+"\'"
		db = dbsProps[dbName]
		addApiDb(dbName, db)
		jdbcString = "jdbc:mysql:replication://HOST:PORT,HOST:PORT/?characterEncoding=utf8&useServerPrepStmts=true&logger=com.mysql.jdbc.log.StandardLogger&roundRobinLoadBalance=true&transformedBitIsBoolean=true&rewriteBatchedStatements=true"
		jdbcString = jdbcString.replace("HOST", db["host"]).replace("PORT",str(db["port"]));
		del(db["host"])
		del(db["port"])
		db['jdbc'] = jdbcString
		db['name'] = dbName
		dbs.append(db)
	dbcpObj = {"dbs": dbs}
	zk.ensure_path(zkNode)
	zk.set(zkNode,json.dumps(dbcpObj))


def memcachedSetup(zk, data, zkNode):
	servers = []
	print "Setting up memcache servers"
	for server in data["servers"]:
		host = server['host']
		port = server['port']
		serverStr = host+":"+str(port)
		servers.append(serverStr)
        server_list=str(",".join(servers))
        zkNodeValueBuilder = {}
        zkNodeValueBuilder["servers"] = server_list
        zkNodeValueBuilder["numClients"] = 1
        zkNodeValue = json.dumps(zkNodeValueBuilder)
	zk.ensure_path(zkNode)
	zk.set(zkNode,zkNodeValue)

{'fraction_non_alphanumeric': 0.1678370786516854, 'fraction_numerical': 0.001053370786516854, 'mean_word_length': 6.069478908188586, 'pattern_counts': {'":': 12, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2096761', 'n_tokens_mistral': 1076, 'n_tokens_neox': 1035, 'n_words': 184}