Commit 1af1f5c2 authored by Jakob Luettgau's avatar Jakob Luettgau
Browse files

Add quick switch for verbose_discovery, refine cli argument parser to allow...

Add quick switch for verbose_discovery, refine cli argument parser to allow early exit and more debug control.
parent 67f10148
__version__ = '0.0.6'
__darshanutil_version__ = '3.2.1'
import logging
logger = logging.getLogger(__name__)
options = {
......@@ -5,7 +5,7 @@ import importlib
import sys
log = logging.getLogger(__name__)
logger = logging.getLogger(__name__)
......@@ -77,10 +77,35 @@ def main():
Darshan CLI wrapper, to expose individual commands as subcommands.
# early parsing for selected arguments
preparser = argparse.ArgumentParser(usage="darshan <command>", description='PyDarshan CLI Utilities', formatter_class=CustomHelpFormatter)
preparser.add_argument('--debug', help='', action='store_true', default=False)
preparser.add_argument('--version', help='', action='store_true', default=False)
# parse selected args early
args, unkown_args = preparser.parse_known_args()
# be verbose for debugging
if args.debug:
# TODO: Unfortunetly, this does not propagate to the libdarshan discovery utility process which already happened at this point
#for name in logging.root.manager.loggerDict:
# print(name)
# logging.getLogger(name).setLevel(logging.DEBUG)
if args.version:
import darshan
#parser = argparse.ArgumentParser(usage="darshan <command>", description='Darshan CLI Utilities', formatter_class=ArgumentDefaultsHelpFormatter)
parser = argparse.ArgumentParser(usage="darshan <command>", description='PyDarshan CLI Utilities', formatter_class=CustomHelpFormatter)
# Shared Optional Arguments
optionals = parser.add_argument_group()
optionals.add_argument("--config-file", dest='config_file', action='store', type=str,
......@@ -94,16 +119,17 @@ def main():
optionals.add_argument("--no-timestamp", dest='no_timestamp', action='store_true',
help='Removes timestamp from log events')
optionals.add_argument('--debug', help='', action='store_true')
optionals.add_argument('--debug', help='', action='store_true', default=False)
optionals.add_argument('--version', help='', action='store_true', default=False)
# setup parser for sub-commands
subparsers = parser.add_subparsers(dest='action')
# custom help messge
parser._positionals.title = "commands"
subcmds = discover_subcommands()
for subcmd in subcmds:
subcmd_parser = subparsers.add_parser(subcmd)
......@@ -112,18 +138,18 @@ def main():
args = parser.parse_args()
# be verbose for debugging (again now with full known options)
if args.debug:
# default behavior when no arguments provided: show help
if len(sys.argv) == 1:
# be verbose for debugging
if args.debug:
# route subcommands
if args.action in subcmds:
mod = importlib.import_module('darshan.cli.{0}'.format(args.action))
......@@ -9,6 +9,12 @@ import logging
logger = logging.getLogger(__name__)
verbose_discovery = False
if verbose_discovery:
logging.basicConfig() # ensure out streams exist
logger.setLevel(logging.DEBUG) # set log-level
def check_version(ffi=None, libdutil=None):
Get version from shared library or pkg-config and return info.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment