def main(): """Function: main Description: Initializes program-wide used variables and processes command line arguments and values. Variables: dir_chk_list -> contains options which will be directories. func_dict -> dictionary list for the function calls or other options. opt_req_list -> contains options that are required for the program. opt_val_list -> contains options which require values. opt_xor_dict -> contains dict with key that is xor with it's values. Arguments: (input) argv -> Arguments from the command line. """ cmdline = gen_libs.get_inst(sys) dir_chk_list = ["-d"] func_dict = {"-M": process_message, "-C": check_nonprocess} opt_req_list = ["-c", "-d"] opt_val_list = ["-c", "-d", "-y"] opt_xor_dict = {"-M": ["-C"], "-C": ["-M"]} # Process argument list from command line. args_array = arg_parser.arg_parse2(cmdline.argv, opt_val_list) if not gen_libs.help_func(args_array, __version__, help_message) \ and not arg_parser.arg_require(args_array, opt_req_list) \ and arg_parser.arg_xor_dict(args_array, opt_xor_dict) \ and not arg_parser.arg_dir_chk_crt(args_array, dir_chk_list): run_program(args_array, func_dict)
def main(): """Function: main Description: Initializes program-wide used variables and processes command line arguments and values. Variables: dir_chk_list -> contains options which will be directories. file_chk_list -> contains the options which will have files included. func_dict -> dictionary list for the function calls or other options. opt_arg_list-> contains list of optional arguments for command line. opt_arg_rep -> contains list of replaceable arguments for command line. opt_con_req_list -> contains the options that require other options. opt_multi_list -> contains the options that will have multiple values. opt_req_list -> contains the options that are required for the program. opt_val_list -> contains options which require values. opt_xor_dict -> contains options which are XOR with its values. xor_noreq_list -> contains options that are XOR, but are not required. Arguments: (input) argv -> Arguments from the command line. """ dir_chk_list = ["-d", "-p"] file_chk_list = ["-f"] func_dict = {"-I": insert_doc, "-D": delete_docs, "-T": truncate_coll} opt_arg_list = {"-a": "--authenticationDatabase=", "-b": "--db=", "-t": "--collection="} opt_arg_rep = {"-f": "--file="} opt_con_req_list = {"-k1": ["-l1"]} opt_multi_list = ["-f", "-l1", "-l2", "-l3", "-l4", "-l5"] opt_req_list = ["-b", "-c", "-d", "-t"] opt_val_list = ["-a", "-b", "-c", "-d", "-f", "-k1", "-l1", "-p", "-t", "-k2", "-l2", "-k3", "-l3", "-k4", "-l4", "-k5", "-l5"] opt_xor_dict = {"-D": ["-I", "-T"], "-I": ["-D", "-T"], "-T": ["-D", "-I"]} xor_noreq_list = {"-k1": "-f"} # Process argument list from command line. args_array = arg_parser.arg_parse2(sys.argv, opt_val_list, multi_val=opt_multi_list) # Remove dupe files. if "-f" in args_array: args_array["-f"] = gen_libs.rm_dup_list(args_array["-f"]) if not gen_libs.help_func(args_array, __version__, help_message) \ and not arg_parser.arg_require(args_array, opt_req_list) \ and not arg_parser.arg_dir_chk_crt(args_array, dir_chk_list) \ and arg_parser.arg_xor_dict(args_array, opt_xor_dict) \ and arg_parser.arg_cond_req(args_array, opt_con_req_list) \ and arg_parser.arg_noreq_xor(args_array, xor_noreq_list) \ and not arg_parser.arg_file_chk(args_array, file_chk_list): run_program(args_array, func_dict, opt_arg=opt_arg_list, opt_rep=opt_arg_rep)
def main(): """Function: main Description: Initializes program-wide used variables and processes command line arguments and values. Variables: dir_chk_list -> contains options which will be directories. func_dict -> dictionary list for the function calls or other options. opt_arg_list -> contains arguments to add to command line by default. opt_con_req_list -> contains the options that require other options. opt_req_list -> contains the options that are required for the program. opt_val_list -> contains options which require values. opt_valid_val -> contains list of types of values to be validated. opt_xor_dict -> contains options which are XOR with its values. Arguments: (input) argv -> Arguments from the command line. """ cmdline = gen_libs.get_inst(sys) dir_chk_list = ["-d", "-p"] func_dict = {"-L": fetch_log_pos, "-D": fetch_log_entries, "-R": load_log} opt_arg_list = ["--force-read", "--read-from-remote-server"] opt_con_req_list = {"-R": ["-e"]} opt_req_list = ["-c", "-d"] opt_val_list = ["-c", "-e", "-d", "-f", "-g", "-p", "-s", "-t", "-y"] opt_valid_val = { "-s": gen_libs.validate_date, "-t": gen_libs.validate_date } opt_xor_dict = {"-L": ["-D", "-R"], "-D": ["-L", "-R"], "-R": ["-D", "-L"]} # Process argument list from command line. args_array = arg_parser.arg_parse2(cmdline.argv, opt_val_list) if not gen_libs.help_func(args_array, __version__, help_message) \ and not arg_parser.arg_require(args_array, opt_req_list) \ and arg_parser.arg_xor_dict(args_array, opt_xor_dict) \ and not arg_parser.arg_dir_chk_crt(args_array, dir_chk_list) \ and arg_parser.arg_validate(args_array, opt_valid_val) \ and arg_parser.arg_cond_req(args_array, opt_con_req_list): try: prog_lock = gen_class.ProgramLock(cmdline.argv, args_array.get("-y", "")) run_program(args_array, func_dict, opt_arg_list) del prog_lock except gen_class.SingleInstanceException: print( "WARNING: lock in place for mysql_log_admin with id of: %s" % (args_array.get("-y", "")))
def main(): """Function: main Description: Initializes program-wide used variables and processes command line arguments and values. Variables: dir_chk_list -> contains options which will be directories. func_dict -> dictionary list for the function calls or other options. opt_req_list -> contains the options that are required for the program. opt_val_list -> contains options which require values. opt_xor_dict -> contains dict with key that is xor with it's values. Arguments: (input) argv -> Arguments from the command line. """ cmdline = gen_libs.get_inst(sys) dir_chk_list = ["-d"] func_dict = { "-B": show_best_slave, "-D": show_slave_delays, "-F": promote_best_slave, "-G": promote_designated_slave } opt_req_list = ["-d", "-s"] opt_val_list = ["-d", "-s", "-G", "-y"] opt_xor_dict = { "-B": ["-D", "-F", "-G"], "-D": ["-B", "-F", "-G"], "-F": ["-B", "-D", "-G"], "-G": ["-B", "-D", "-F"] } # Process argument list from command line. args_array = arg_parser.arg_parse2(cmdline.argv, opt_val_list) if not gen_libs.help_func(args_array, __version__, help_message) \ and not arg_parser.arg_require(args_array, opt_req_list) \ and arg_parser.arg_xor_dict(args_array, opt_xor_dict) \ and not arg_parser.arg_dir_chk_crt(args_array, dir_chk_list): try: prog_lock = gen_class.ProgramLock(cmdline.argv, args_array.get("-y", "")) run_program(args_array, func_dict) del prog_lock except gen_class.SingleInstanceException: print( "WARNING: Lock in place for mysql_rep_failover with id: %s" % (args_array.get("-y", "")))
def main(): """Function: main Description: Initializes program-wide used variables and processes command line arguments and values. Variables: dir_chk_list -> contains options which will be directories. func_dict -> dictionary list for the function calls or other options. opt_con_req_dict -> contains options requiring other options. opt_multi_list -> contains the options that will have multiple values. opt_req_list -> contains options that are required for the program. opt_val -> List of options that allow 0 or 1 value for option. opt_val_list -> contains options which require values. opt_xor_dict -> contains dict with key that is xor with it's values. Arguments: (input) argv -> Arguments from the command line. """ cmdline = gen_libs.get_inst(sys) dir_chk_list = ["-d"] func_dict = { "-C": create_repo, "-D": initate_dump, "-L": list_dumps, "-R": list_repos } opt_con_req_dict = {"-C": ["-l"], "-i": ["-D"]} opt_multi_list = ["-i"] opt_req_list = ["-c", "-d"] opt_val = ["-D", "-L"] opt_val_list = ["-c", "-d", "-i", "-l", "-C"] opt_xor_dict = { "-C": ["-D", "-L", "-R"], "-D": ["-C", "-L", "-R"], "-L": ["-C", "-D", "-R"], "-R": ["-C", "-D", "-L"] } # Process argument list from command line. args_array = arg_parser.arg_parse2(cmdline.argv, opt_val_list, opt_val=opt_val, multi_val=opt_multi_list) if not gen_libs.help_func(args_array, __version__, help_message) \ and not arg_parser.arg_require(args_array, opt_req_list) \ and arg_parser.arg_xor_dict(args_array, opt_xor_dict) \ and arg_parser.arg_cond_req_or(args_array, opt_con_req_dict) \ and not arg_parser.arg_dir_chk_crt(args_array, dir_chk_list): run_program(args_array, func_dict)
def main(): """Function: main Description: Initializes program-wide used variables and processes command line arguments and values. Variables: dir_chk_list -> contains options which will be directories. func_dict -> dictionary list for the function calls or other options. opt_con_req_list -> contains the options that require other options. opt_req_list -> contains the options that are required for the program. opt_val_list -> contains options which require values. opt_xor_dict -> contains dict with key that is xor with it's values. slv_key -> contains dict with keys to be converted to data types. Arguments: (input) argv -> Arguments from the command line. """ cmdline = gen_libs.get_inst(sys) dir_chk_list = ["-d"] func_dict = {"-M": move_slave, "-R": move_slave, "-S": move_slave_up} opt_con_req_list = { "-M": ["-m", "-n"], "-R": ["-m", "-n"], "-S": ["-m", "-n"] } opt_req_list = ["-c", "-d", "-s"] opt_val_list = ["-c", "-d", "-m", "-n", "-s", "-y"] opt_xor_dict = {"-M": ["-R", "-S"], "-R": ["-M", "-S"], "-S": ["-M", "-R"]} slv_key = { "sid": "int", "port": "int", "cfg_file": "None", "ssl_client_ca": "None", "ssl_ca_path": "None", "ssl_client_key": "None", "ssl_client_cert": "None", "ssl_client_flag": "int", "ssl_disabled": "bool", "ssl_verify_id": "bool", "ssl_verify_cert": "bool" } # Process argument list from command line. args_array = arg_parser.arg_parse2(cmdline.argv, opt_val_list) if not gen_libs.help_func(args_array, __version__, help_message) \ and not arg_parser.arg_require(args_array, opt_req_list) \ and arg_parser.arg_xor_dict(args_array, opt_xor_dict) \ and arg_parser.arg_cond_req(args_array, opt_con_req_list) \ and not arg_parser.arg_dir_chk_crt(args_array, dir_chk_list): try: proglock = gen_class.ProgramLock(cmdline.argv, args_array.get("-y", "")) run_program(args_array, func_dict, slv_key=slv_key) del proglock except gen_class.SingleInstanceException: print( "WARNING: lock in place for mysql_rep_change with id of: %s" % (args_array.get("-y", "")))
def main(): """Function: main Description: Initializes program-wide used variables and processes command line arguments and values. Variables: dir_chk_list -> contains options which will be directories. file_chk_list -> contains the options which will have files included. file_crt_list -> contains options which require files to be created. func_dict -> dictionary list for the function calls or other options. opt_con_req_list -> contains the options that require other options. opt_def_dict -> contains options with their default values. opt_multi_list -> contains the options that will have multiple values. opt_req_list -> contains the options that are required for the program. opt_val_list -> contains options which require values. opt_xor_dict -> contains options which are XOR with its values. sys_dbs -> contains a list of system databases that will be skipped over for some functions. Arguments: (input) argv -> Arguments from the command line. """ cmdline = gen_libs.get_inst(sys) dir_chk_list = ["-d"] file_chk_list = ["-o"] file_crt_list = ["-o"] func_dict = {"-A": analyze, "-C": check, "-D": optimize, "-S": checksum, "-M": status, "-L": listdbs} opt_con_req_list = {"-i": ["-m"], "-s": ["-e"], "-u": ["-e"]} opt_def_dict = {"-t": None, "-A": [], "-C": [], "-D": [], "-S": [], "-i": "sysmon:mysql_db_status"} opt_multi_list = ["-A", "-C", "-D", "-S", "-t", "-e", "-s"] opt_req_list = ["-c", "-d"] opt_val_list = ["-c", "-d", "-t", "-A", "-C", "-D", "-S", "-i", "-m", "-o", "-e", "-s", "-y"] opt_xor_dict = {"-A": ["-C", "-D", "-M", "-S", "-L"], "-C": ["-A", "-D", "-M", "-S", "-L"], "-D": ["-A", "-C", "-M", "-S", "-L"], "-S": ["-A", "-C", "-D", "-M", "-L"], "-M": ["-A", "-C", "-D", "-S", "-L"], "-L": ["-A", "-C", "-D", "-S", "-M"]} sys_dbs = ["performance_schema", "information_schema", "mysql", "sys"] # Process argument list from command line. args_array = arg_parser.arg_parse2(cmdline.argv, opt_val_list, opt_def_dict, multi_val=opt_multi_list) # Set JSON format for certain option settings if "-i" in args_array.keys() and "-m" in args_array.keys() \ and "-j" not in args_array.keys(): args_array["-j"] = True if not gen_libs.help_func(args_array, __version__, help_message) \ and not arg_parser.arg_require(args_array, opt_req_list) \ and arg_parser.arg_xor_dict(args_array, opt_xor_dict) \ and arg_parser.arg_cond_req(args_array, opt_con_req_list) \ and not arg_parser.arg_dir_chk_crt(args_array, dir_chk_list) \ and not arg_parser.arg_file_chk(args_array, file_chk_list, file_crt_list): try: proglock = gen_class.ProgramLock(cmdline.argv, args_array.get("-y", "")) run_program(args_array, func_dict, sys_dbs=sys_dbs, multi_val=opt_multi_list) del proglock except gen_class.SingleInstanceException: print("WARNING: lock in place for mysql_db_admin with id of: %s" % (args_array.get("-y", "")))
def main(): """Function: main Description: Initializes program-wide used variables and processes command line arguments and values. Variables: dir_chk_list -> contains options which will be directories. file_chk_list -> contains the options which will have files included. file_crt_list -> contains options which require files to be created. func_dict -> dictionary list for the function calls or other options. opt_arg_list -> contains optional arguments for the command line. opt_con_req_dict -> contains options requiring one or more options. opt_con_req_list -> contains the options that require other options. opt_def_dict -> contains options with their default values. opt_multi_list -> contains the options that will have multiple values. opt_req_list -> contains the options that are required for the program. opt_val_list -> contains options which require values. opt_valid_val -> contains a list of valid values for options. opt_xor_dict -> contains dict with key that is xor with it's values. Arguments: (input) argv -> Arguments from the command line. """ cmdline = gen_libs.get_inst(sys) dir_chk_list = ["-d", "-n"] file_chk_list = ["-o"] file_crt_list = ["-o"] func_dict = {"-C": defrag, "-D": dbcc, "-R": repair_db, "-M": status, "-L": rotate, "-G": get_log} opt_con_req_dict = {"-j": ["-M", "-G"]} opt_con_req_list = {"-i": ["-m"], "-n": ["-L"], "-l": ["-G"], "-f": ["-D"], "-s": ["-e"]} opt_def_dict = {"-C": [], "-D": [], "-R": [], "-G": "global", "-i": "sysmon:mongo_db_status"} opt_multi_list = ["-C", "-D", "-R", "-t", "-e", "-s"] opt_req_list = ["-c", "-d"] opt_val_list = ["-c", "-d", "-t", "-C", "-D", "-R", "-i", "-m", "-o", "-G", "-n", "-e", "-s", "-y"] opt_valid_val = {"-G": ["global", "rs", "startupWarnings"]} opt_xor_dict = {"-R": ["-C", "-M", "-D"], "-C": ["-D", "-M", "-R"], "-D": ["-C", "-M", "-R"], "-M": ["-C", "-D", "-R", "-G"], "-G": ["-M"], "-j": ["-l"], "-l": ["-j"]} # Process argument list from command line. args_array = arg_parser.arg_parse2(cmdline.argv, opt_val_list, opt_def_dict, multi_val=opt_multi_list) if not gen_libs.help_func(args_array, __version__, help_message) \ and not arg_parser.arg_require(args_array, opt_req_list) \ and arg_parser.arg_valid_val(args_array, opt_valid_val) \ and arg_parser.arg_xor_dict(args_array, opt_xor_dict) \ and arg_parser.arg_cond_req_or(args_array, opt_con_req_dict) \ and arg_parser.arg_cond_req(args_array, opt_con_req_list) \ and not arg_parser.arg_dir_chk_crt(args_array, dir_chk_list) \ and not arg_parser.arg_file_chk(args_array, file_chk_list, file_crt_list): try: prog_lock = gen_class.ProgramLock(cmdline.argv, args_array.get("-y", "")) run_program(args_array, func_dict) del prog_lock except gen_class.SingleInstanceException: print("WARNING: lock in place for mongo_db_admin with id of: %s" % (args_array.get("-y", "")))
def main(): """Function: main Description: Initializes program-wide used variables and processes command line arguments and values. Variables: dir_chk_list -> contains options which will be directories. dir_crt_list -> contain options that require directory to be created. opt_arg_list -> contains arguments to add to command line by default. opt_con_req_dict -> contains options requiring other options. opt_dump_list -> contains optional arguments to mysqldump. opt_multi_list -> contains the options that will have multiple values. opt_req_list -> contains the options that are required for the program. opt_val_list -> contains options which require values. opt_xor_dict -> contains options which are XOR with its values. Arguments: (input) argv -> Arguments from the command line. """ cmdline = gen_libs.get_inst(sys) dir_chk_list = ["-o", "-d", "-p"] dir_crt_list = ["-o"] # --ignore-table=mysql.event -> Skips dumping the event table. opt_arg_list = ["--ignore-table=mysql.event"] opt_con_req_dict = { "-t": ["-e"], "-A": ["-o"], "-B": ["-o"], "-D": ["-o"], "-u": ["-e"] } opt_dump_list = { "-s": "--single-transaction", "-D": ["--all-databases", "--triggers", "--routines", "--events"], "-r": "--set-gtid-purged=OFF" } opt_multi_list = ["-B", "-e", "-t"] opt_req_list = ["-c", "-d"] opt_val_list = ["-B", "-c", "-d", "-o", "-p", "-y", "-e", "-t"] opt_xor_dict = {"-A": ["-B", "-D"], "-B": ["-A", "-D"], "-D": ["-A", "-B"]} # Process argument list from command line. args_array = arg_parser.arg_parse2(cmdline.argv, opt_val_list, multi_val=opt_multi_list) if not gen_libs.help_func(args_array, __version__, help_message) \ and not arg_parser.arg_require(args_array, opt_req_list) \ and arg_parser.arg_xor_dict(args_array, opt_xor_dict) \ and not arg_parser.arg_dir_chk_crt(args_array, dir_chk_list, dir_crt_list) \ and arg_parser.arg_cond_req_or(args_array, opt_con_req_dict): try: prog_lock = gen_class.ProgramLock(cmdline.argv, args_array.get("-y", "")) run_program(args_array, opt_arg_list, opt_dump_list) del prog_lock except gen_class.SingleInstanceException: print("WARNING: Lock in place for mysql_db_dump with id: %s" % (args_array.get("-y", "")))