How to use create_new_config_file method in tox

Best Python code snippet using tox_python

kafka_config.py

Source:kafka_config.py Github

copy

Full Screen

...64 '#schema.registry.url=http://localhost:8081\n': uncomment,65 'bootstrap.servers=PLAINTEXT://localhost:9092\n': get_hosts_with_tag_bk,66 '# ksql.schema.registry.url=http://localhost:8081\n': uncomment,67}68def create_new_config_file(source, dist, hosts, id):69 dist_file = open(dist, 'w')70 with open(source, 'r') as cfg:71 line = cfg.readline()72 while line:73 update_func = update_switcher.get(line, None)74 if update_func != None:75 strs = line.split('=')76 if update_func.__name__ == 'uncomment':77 dist_file.write(uncomment(line))78 elif update_func.__name__ == 'get_id':79 dist_file.write(strs[0] + '=' + update_func(id) + newline_tag)80 else:81 # check is commented or not82 if strs[0][:1] == comment_tag:83 strs[0] = strs[0][1:]84 dist_file.write(strs[0] + '=' + update_func(hosts) + newline_tag)85 else:86 dist_file.write(line)87 line = cfg.readline()88 dist_file.close()89# /etc/kafka/connect-distributed.properties90# same config file for all nodes91def create_connect(source, dist, hosts):92 create_new_config_file(source, dist, hosts, '')93# /etc/kafka/zookeeper.properties94# same config file for all nodes95def create_zookeeper(source, dist, hosts):96 create_new_config_file(source, dist, hosts, '1')97 with open(dist, 'a') as output:98 # append the following:99 output.write('# multi-node\ntickTime=2000\ninitLimit=5\nsyncLimit=2\n')100 output.write(get_hosts_with_tag_zk(hosts))101 output.write('autopurge.snapRetainCount=3\nautopurge.purgeInterval=24\n')102# /etc/kafka-rest/kafka-rest.properties103# same config for all nodes104def create_kafka_rest(source, dist, hosts):105 create_new_config_file(source, dist, hosts, '')106# /etc/ksqldb/ksql-server.properties107# same config for all nodes108def create_ksqldb(source, dist, hosts):109 create_new_config_file(source, dist, hosts, '')110#================================================================111# /etc/kafka/server.properties112# different config file for each node113def create_kafka(source, dist, hosts):114 for id in range(1, len(hosts)+1):115 create_new_config_file(source, dist + '.' + str(id), hosts, str(id))116 # append default replication factor117 with open(dist + '.' + str(id), 'a') as output:118 output.write('default.replication.factor=1\n')119# /var/lib/zookeeper/myid120# different myid for each node121def create_myid(dist, hosts):122 for id in range(1, len(hosts)+1):123 with open(dist + '.' + str(id), 'w') as output:124 output.write(str(id))125#=============================================================126configs = {127 'connect' : '/kafka/connect-distributed.properties',128 'kafka' : '/kafka/server.properties',129 'zookeeper' : '/kafka/zookeeper.properties',...

Full Screen

Full Screen

change_config.py

Source:change_config.py Github

copy

Full Screen

...20 else:21 xml_file += line22 old_xml_file.close()23 return xml_file24def create_new_config_file(file):25 new_xml_file = open(args.new_file, "w", encoding="utf-8")26 new_xml_file.writelines(file)27 new_xml_file.close()...

Full Screen

Full Screen

create_config.py

Source:create_config.py Github

copy

Full Screen

2from tyko.run import init_database3from sqlalchemy import create_engine4CONFIG_FILE = "config.cfg"5SQLLITE_FILE = "tyko.db"6def create_new_config_file(config_file: str, db_uri: str) -> None:7 print("making a config file")8 with open(config_file, "w", encoding="utf-8") as f:9 f.write(f"SQLALCHEMY_DATABASE_URI = '{db_uri}'")10def main():11 config_file = CONFIG_FILE12 db_file = os.path.join(os.path.abspath("."), SQLLITE_FILE)13 db_uri = f'sqlite:///{db_file}'14 if not os.path.exists(config_file):15 create_new_config_file(config_file, db_uri)16 print(f"Generated: {config_file}")17 if os.path.exists(db_file):18 os.remove(db_file)19 init_database(create_engine(db_uri))20 print(f"Initialized db file {db_file}")21if __name__ == '__main__':...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tox automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful