1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
|
import raw_opts
import raw_vars
import options_layout
import pprint
print "Converting raw_opts.py to opts.py"
def hack_option(option):
if option['name'] == 'validate_password_dictionary_file':
option['values'][0]['type'] = 'fileedit'
default = option['values'][0].get('default')
if not default:
option['values'][0]['default'] = '{configdir}/mysql_password_dictionary.txt'
elif option['name'] == 'ft_stopword_file':
option['values'][0]['type'] = 'fileedit'
default = option['values'][0].get('default')
if not default:
option['values'][0]['default'] = '{configdir}/mysql_ft_stopword_file.txt'
elif option['name'] == 'socket':
option['values'][0]['type'] = 'filebrowse'
elif option['name'] == 'innodb_data_file_path':
option['values'][0]['type'] = 'string'
elif option['name'] in ('slow_query_log_file', 'general_log_file', 'log_bin_basename', 'relay_log_basename',
'relay_log_info_file', ''):
option['values'][0]['type'] = 'filedownload'
elif option['name'] in ('plugin_dir', ):
for x in option['values']:
x['default'] = x['default'].replace('BASEDIR/', '{basedir}/')
option_dict = {}
for option in raw_opts.ropts:
option_dict[option['name']] = option
sys_vars = {}
stat_vars = {}
def find_var(varlist, option):
for v in varlist:
if v[0] == option:
return v
return None
print "Generating opts.py"
out=open("opts.py", "w+")
out.write("opts_list = [\n")
handled_options = set()
for section, section_items in options_layout.layout:
out.write("( '%s', [\n" % section)
for g, (group, group_items) in enumerate(section_items):
out.write("\t( '%s', [\n" % group)
for i, option in enumerate(group_items):
if option in option_dict and not option in handled_options:
handled_options.add(option)
info = option_dict[option]
hack_option(info)
out.write("\t\t"+repr(info))
if i < len(group_items)-1:
out.write(",\n")
out.write("])")
if g < len(section_items)-1:
out.write(",\n")
out.write("]),\n")
out.write("]\n")
unhandled_options = set(option_dict.keys()) - handled_options
if unhandled_options:
print "The following options were not handled:", "\n".join(sorted(list(unhandled_options)))
out.close()
def normalize_dict_keys(d):
return d
out = {}
for k, v in d.items():
out[k.replace("-","_")] = v
return out
from variable_groups import variable_groups
variable_groups = normalize_dict_keys(dict(variable_groups))
system_var_list = []
for var in raw_vars.system_vars_list:
system_var_list.append(tuple(list(var) + [variable_groups.get(var[0].replace("-","_"), [])]))
from status_groups import variable_groups
status_groups = normalize_dict_keys(dict(variable_groups))
status_var_list = []
for var in raw_vars.status_vars_list:
status_var_list.append(tuple(list(var) + [status_groups.get(var[0].replace("-","_"), [])]))
print "Generating wb_admin_variable_list.py"
out=open("wb_admin_variable_list.py", "w+")
pp = pprint.PrettyPrinter(indent=2, stream=out)
out.write("system_variable_list=")
pp.pprint(system_var_list)
out.write("\n\n\n")
out.write("status_variable_list=")
pp.pprint(status_var_list)
out.close()
|