def parse_arguments(argv: Sequence[str]) -> argparse.Namespace: """Parse arguments needed to construct an URL and for connection conditions""" parser = argparse.ArgumentParser() parser.add_argument("--hostname", required=True, help="Host to query") parser.add_argument("--port", "-p", type=int, help='IPv4 port to connect to') parser.add_argument("--basic-auth", "-u", type=str, help='username:password for basic_auth') parser.add_argument("--no-tls", action="store_true", help="Use http instead of https") parser.add_argument("--no-cert-check", action="store_true") parser.add_argument( "--timeout", "-t", type=float, default=20, help='API call timeout in seconds', ) parser.add_argument("--debug", action="store_true", help="Keep some exceptions unhandled") parser.add_argument("--verbose", "-v", action="count", default=0) parser.add_argument("--vcrtrace", action=vcrtrace(filter_headers=[('authorization', '****')])) return parser.parse_args(argv)
def parse_arguments(argv): parser = argparse.ArgumentParser( description=__doc__, formatter_class=argparse.RawTextHelpFormatter) parser.add_argument( "--vcrtrace", action=vcrtrace(before_record_request=Server.filter_credentials), ) parser.add_argument( "--no-cert-check", action="store_true", help="Disables the checking of the servers ssl certificate.", ) parser.add_argument("--debug", action="store_true", help="Raise Python exceptions.") parser.add_argument("-u", "--username", required=True, help="The username.") parser.add_argument("-p", "--password", required=True, help="The password.") parser.add_argument("hostname") return parser.parse_args(argv)
def parse_arguments(argv): sections = ["instance", "jobs", "nodes", "queue"] parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawTextHelpFormatter) parser.add_argument("--vcrtrace", action=vcrtrace(filter_headers=[('authorization', '****')])) parser.add_argument("-u", "--user", default=None, help="Username for jenkins login") parser.add_argument("-s", "--password", default=None, help="Password for jenkins login") parser.add_argument("-P", "--proto", default="https", help="Use 'http' or 'https' for connection to jenkins (default=https)") parser.add_argument("-p", "--port", default=443, type=int, help="Use alternative port (default: 443)") parser.add_argument( "-m", "--sections", default=sections, help="Comma separated list of data to query. Possible values: %s (default: all)" % ",".join(sections)) parser.add_argument("--debug", action="store_true", help="Debug mode: let Python exceptions come through") parser.add_argument("hostname", metavar="HOSTNAME", help="Name of the jenkins instance to query.") return parser.parse_args(argv)
def parse_arguments(argv): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument( "--debug", action="store_true", help="debug mode: let Python exceptions come through", ) parser.add_argument("--vcrtrace", action=vcrtrace()) parser.add_argument("-v", "--verbose", action="store_true", help="verbose mode") parser.add_argument( "-t", "--timeout", metavar="SEC", type=int, default=10, help="set the timeout for each query to <SEC> seconds (default: 10)", ) parser.add_argument( "host_address", metavar="HOST", help="host name or IP address of your FRITZ!Box", ) return parser.parse_args(argv)
def parse_arguments(argv): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("-v", "--verbose", action="count", help="""Verbose mode""") parser.add_argument("--debug", action="store_true", help="Debug mode: let python exceptions come through") parser.add_argument( "--vcrtrace", action=vcrtrace(**mk_jolokia.JolokiaInstance.FILTER_SENSITIVE)) opts_with_help: List[List[str]] = [] for opt in mk_jolokia.DEFAULT_CONFIG_TUPLES: if len(opt) == 3: opts_with_help.append([str(elem) for elem in opt]) for key, default, help_str in opts_with_help: if default is not None: help_str += " Default: %s" % default parser.add_argument("--%s" % key, default=default, help=help_str) # now add some arguments we cannot define in the way above: parser.add_argument( "--no-cert-check", action="store_true", help="""Skip SSL certificate verification (not recommended)""", ) return parser.parse_args(argv)
def parse_arguments(argv): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("-v", "--verbose", action="count", help="Enable verbose logging.") parser.add_argument("--debug", action="store_true", help="Raise python exceptions.") parser.add_argument("--vcrtrace", action=vcrtrace(filter_headers=[('authorization', '****')])) parser.add_argument("-t", "--timeout", default=10, help="Timeout for API-calls in seconds. Default: 10") parser.add_argument("-b", "--buckets", default=[], action='append', help="Gives a bucket to monitor. Can be used multiple times.") parser.add_argument("-P", "--port", default=8091, help="Gives the port for API-calls. Default: 8091") parser.add_argument("-u", "--username", default=None, help="The username for authentication at the API.") parser.add_argument("-p", "--password", default=None, help="The password for authentication at the API.") parser.add_argument("hostname", help="Host or ip address to contact.") return parser.parse_args(argv)
def parse_arguments(argv: List[str]) -> argparse.Namespace: parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("--vcrtrace", "--tracefile", action=vcrtrace(filter_headers=[('authorization', '****')])) parser.add_argument("user", metavar="USER", help="""Username for Observer Role""") parser.add_argument("password", metavar="PASSWORD", help="""Password for Observer Role""") parser.add_argument("-p", "--port", default=443, type=int, help="Use alternative port (default: 443)") parser.add_argument( "--verify_ssl", action="store_true", default=False, ) parser.add_argument('--verbose', '-v', action="count", default=0) parser.add_argument("--debug", action="store_true", help="Debug mode: let Python exceptions come through") parser.add_argument("host", metavar="HOST", help="""APPLIANCE-ADDRESS of HP StoreOnce""") return parser.parse_args(argv)
def create_default_argument_parser(description: Optional[str]) -> argparse.ArgumentParser: parser = argparse.ArgumentParser(description=description) parser.formatter_class = argparse.RawTextHelpFormatter parser.add_argument("--debug", "-d", action="store_true", help="Enable debug mode (keep some exceptions unhandled)") parser.add_argument("--verbose", '-v', action="count", default=0) parser.add_argument("--vcrtrace", "--tracefile", action=vcrtrace(filter_headers=[('authorization', '****')])) return parser
def parse_arguments(argv: Sequence[str]) -> Args: """parse command line arguments and return argument object""" parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("--vcrtrace", action=vcrtrace(filter_headers=[("authorization", "****")])) parser.add_argument("--timeout", "-t", type=int, default=20, help="API call timeout") parser.add_argument("--port", type=int, default=8006, help="IPv4 port to connect to") parser.add_argument("--username", "-u", type=str, help="username for connection") parser.add_argument("--password", "-p", type=str, help="password for connection") parser.add_argument("--verbose", "-v", action="count", default=0) # TODO: warn if log-cutoff-weeks is shorter than actual log length or # shorter than configured check parser.add_argument( "--log-cutoff-weeks", type=int, default=2, help="Fetch logs N weeks back in time", ) parser.add_argument("--no-cert-check", action="store_true") parser.add_argument("--debug", action="store_true", help="Keep some exceptions unhandled") parser.add_argument("hostname", help="Name of the Proxmox instance to query.") return parser.parse_args(argv)
def parse_arguments(argv): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("--debug", action="store_true", help='''Debug mode: raise Python exceptions''') parser.add_argument( "-v", "--verbose", action="count", default=0, help='''Verbose mode (for even more output use -vvv)''') parser.add_argument( "--vcrtrace", action=vcrtrace(filter_post_data_parameters=[('client_secret', '****')]), help='''(implies --sequential)''') parser.add_argument("--sequential", action="store_true", help='''Sequential mode: do not use multiprocessing''') parser.add_argument("--dump-config", action="store_true", help='''Dump parsed configuration and exit''') parser.add_argument( "--timeout", default=10, type=int, help='''Timeout for individual processes in seconds (default 10)''') parser.add_argument( "--piggyback_vms", default="grouphost", choices=["grouphost", "self"], help= '''Send VM piggyback data to group host (default) or the VM iteself''') parser.add_argument("--subscription", dest="subscriptions", action="append", default=[], help="Azure subscription IDs") # REQUIRED parser.add_argument("--client", required=True, help="Azure client ID") parser.add_argument("--tenant", required=True, help="Azure tenant ID") parser.add_argument("--secret", help="Azure authentication secret") # CONSTRAIN DATA TO REQUEST parser.add_argument( "--require-tag", default=[], metavar='TAG', action='append', help='''Only monitor resources that have the specified TAG. To require multiple tags, provide the option more than once.''') parser.add_argument( "--require-tag-value", default=[], metavar=("TAG", "VALUE"), nargs=2, action='append', help='''Only monitor resources that have the specified TAG set to VALUE. To require multiple tags, provide the option more than once.''') parser.add_argument( "--explicit-config", default=[], nargs='*', help= '''list of arguments providing the configuration in <key>=<value> format. If omitted, all groups and resources are fetched. If specified, every 'group=<name>' argument starts a new group configuration, and every 'resource=<name>' arguments specifies a resource.''') args = parser.parse_args(argv) if args.vcrtrace: args.sequential = True # LOGGING if args.verbose >= 3: # this will show third party log messages as well fmt = "%(levelname)s: %(name)s: %(filename)s: %(lineno)s: %(message)s" lvl = logging.DEBUG elif args.verbose == 2: # be verbose, but silence msrest, urllib3 and requests_oauthlib fmt = "%(levelname)s: %(funcName)s: %(lineno)s: %(message)s" lvl = logging.DEBUG logging.getLogger('msrest').setLevel(logging.WARNING) logging.getLogger('urllib3').setLevel(logging.WARNING) logging.getLogger('requests_oauthlib').setLevel(logging.WARNING) elif args.verbose == 1: fmt = "%(levelname)s: %(funcName)s: %(message)s" lvl = logging.INFO else: fmt = "%(levelname)s: %(message)s" lvl = logging.WARNING logging.basicConfig(level=lvl, format=fmt) # V-VERBOSE INFO for key, value in vars(args).items(): if key == "secret": value = '****' LOGGER.debug('argparse: %s = %r', key, value) return args