def before_dispatch(self, raw_args): # We need to process the loglevel arguments before dispatch, so that we can # do logging during dispatch. That means that we need to cheat, and manually # check for the logging arguments. (We still register them in get_options, # so that they'll show up in the help message.) loglevel = logging.WARN for arg in raw_args: if arg == "--verbose-logging" or arg == "-v": if loglevel > logging.INFO: loglevel = logging.INFO if arg.startswith("--logging-level="): arg_bits = arg.split("=") # If the format here is wrong, argparse will generate error, so we just skip # it if it's incorrect. if len(arg_bits) == 2: try: loglevel = int(arg_bits[1]) except ValueError: print( "Invalid value for log level; must be an integer, but got %s" % arg_bits[1], file=sys.stderr ) raise setup_default_log_handlers(loglevel) self.logging_level = loglevel return raw_args
def before_dispatch(self, raw_args): # We need to process the loglevel arguments before dispatch, so that we can # do logging during dispatch. That means that we need to cheat, and manually # check for the logging arguments. (We still register them in get_options, # so that they'll show up in the help message.) loglevel = logging.WARN for arg in raw_args: if arg == "--verbose-logging" or arg == "-v": if loglevel > logging.INFO: loglevel = logging.INFO if arg.startswith("--logging-level="): arg_bits = arg.split("=") # If the format here is wrong, argparse will generate error, so we just skip # it if it's incorrect. if len(arg_bits) == 2: try: loglevel = int(arg_bits[1]) except ValueError: print( "Invalid value for log level; must be an integer, but got %s" % arg_bits[1], file=sys.stderr) raise setup_default_log_handlers(loglevel) self.logging_level = loglevel return raw_args
def execute(self, args): setup_default_log_handlers(logging.INFO) return self.commandline.execute(args[1:])
def execute(self, args): setup_default_log_handlers(logging.INFO) return self.commandline.execute(args[1:])