Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #59

Merged
merged 13 commits into from
Oct 28, 2024
Prev Previous commit
Next Next commit
Added python gen_env_config.py script
i0gan committed Oct 4, 2024
commit 6da86b1ce24a719c84b2d6dd964a19bbb2b5d840
54 changes: 54 additions & 0 deletions script/gen_env_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#! /usr/bin/python3
import os
import collections
import sys

if len(sys.argv) < 2:
env='dev'
else:
env=sys.argv[1]

print('Gen env: ' + env)

package_list = {}
tmpl_path = '../config/tmpl'
tmpl_value_path = '../config/tmpl/env'
cfg_path = '../config/node'

cfg_map = {}
cfg_value_map = {}

def GetFileContent(path):
fd = open(path, 'r')
return fd.read()

for root, dirs, files in os.walk(tmpl_path):
for f in files:
if f.endswith('.json'):
print("json file: ", f)
cfg_map[f] = GetFileContent(tmpl_path + '/' + f)
elif f.endswith('.conf'):
print("conf file: ", f)
cfg_value_map[f] = GetFileContent(tmpl_path + '/env/' + f)


# replace
for k in cfg_value_map:
conf_file = cfg_value_map[k]
conf_arr = conf_file.split('\n')
for conf_line in conf_arr:
conf = conf_line.split('=')
if len(conf) < 2:
continue
key = conf[0]
value = conf[1]
for k2 in cfg_map:
tmp = cfg_map[k2]
tmp = tmp.replace('{' + key + '}', value)
cfg_map[k2] = tmp

# save
for k in cfg_map:
fd = open(cfg_path + '/' + k, 'w')
fd.write(cfg_map[k])
fd.close()
22 changes: 0 additions & 22 deletions script/sqkcli.sh

This file was deleted.