# Add regexp add_regexp(parser) # Add ssl options add_ssl_options(parser) # Now we process the rest of the arguments. opt, args = parser.parse_args() # Fail if no db arguments or --all option. if len(args) == 0 and not opt.all: parser.error(PARSE_ERR_DB_MISSING_CMP) # Check security settings check_password_security(opt, args, "# ") # Warn if quiet and verbosity are both specified check_verbosity(opt) # Fail if the --all option and database arguments are both specified. check_all(parser, opt, args, "databases") # Process --exclude values to remove unnecessary quotes (when used) in # order to avoid further matching issues. exclude_list = None if opt.exclude: if not opt.all: if not opt.quiet: print(WARN_OPT_ONLY_USED_WITH.format(opt='--exclude', used_with='the --all'
type=int, default=10, help="Number of seconds to wait for spawned server to " "start. Default = 10.") # Add verbosity mode add_verbosity(parser, True) # Add ssl options add_ssl_options(parser) # Now we process the rest of the arguments. opt, args = parser.parse_args() # Check security settings check_password_security(opt, args) # Check for argument errors if not args: parser.error("Nothing to do. You must specify a list of paths or " "files to read. See --help for more information and " "examples.") if not opt.port and not opt.diagnostic: parser.error("The --port option is required for reading .frm files in " "the default mode.") if opt.diagnostic and opt.port: print("# WARNING The --port option is not used in the " "--diagnostic mode.")
help="start replication from the first event recorded " "in the binary logging of the master. Not valid " "with --master-log-file or --master-log-pos.", ) # Add ssl options add_ssl_options(parser) # Add verbosity add_verbosity(parser) # Now we process the rest of the arguments. opt, args = parser.parse_args() # Check security settings check_password_security(opt, args) # option --master is required (mandatory) if not opt.master: default_val = "root@localhost:3306" print(WARN_OPT_USING_DEFAULT.format(default=default_val, opt="--master")) # Print the WARNING to force determinism if a parser error occurs. sys.stdout.flush() # option --slave is required (mandatory) if not opt.slave: parser.error(PARSE_ERR_OPTS_REQ.format(opt="--slave")) # option --rpl-user is required (mandatory) if not opt.rpl_user: parser.error(PARSE_ERR_OPTS_REQ.format(opt="--rpl-user"))
add_verbosity(parser, True) # Add difftype option with SQL option add_difftype(parser, True) # Add the direction (changes-for) add_changes_for(parser, None) # Add show reverse option add_reverse(parser) # Now we process the rest of the arguments. opt, args = parser.parse_args() # Check security settings check_password_security(opt, args, "# ") # Warn if quiet and verbosity are both specified check_verbosity(opt) # Set options for database operations. options = { "quiet": opt.quiet, "verbosity": opt.verbosity, "difftype": opt.difftype, "force": opt.force, "width": opt.width, "changes-for": opt.changes_for, "reverse": opt.reverse, "skip_table_opts": opt.skip_tbl_opts, "compact": opt.compact,
metavar="PATTERN", default=[], help="match the '{0}' column of the PROCESSLIST table.".format( col)) parser.add_option( "--age", dest="age", default=None, help="show only processes that have been in the current state more " "than a given time.") (options, args) = parser.parse_args() # Check security settings check_password_security(options, args) # Print SQL if only --sql-body is given if options.sql_body: options.print_sql = True if (options.server is None or len(options.server) == 0) \ and not options.print_sql: parser.error("You need at least one server if you're not using the " "--sql option") elif options.server is not None and len(options.server) > 0 \ and options.print_sql: parser.error("You should not include servers in the call if you are " "using the --sql option") # If no option was supplied, we print the processes by default
dest="pattern", help="pattern to use when matching. Required if the pattern looks " "like a connection specification.") parser.add_option( "--database", dest="database_pattern", default=None, help="only look at objects in databases matching this pattern") # Output format add_format_option(parser, "display the output in either grid (default), " "tab, csv, or vertical format", "grid") options, args = parser.parse_args() # Check security settings check_password_security(options, args) _LOOKS_LIKE_CONNECTION_MSG = """Pattern '{pattern}' looks like a connection specification. Use --pattern if this is really what you want""" _AT_LEAST_ONE_SERVER_MSG = """You need at least one server if you're not using the --sql option""" _NO_SERVERS_ALLOWED_MSG = """You should not include servers in the call if you are using the --sql option""" # A --pattern is required. if not options.pattern: parser.error("No pattern supplied.")