From 7cadceb2afdaa1fa43229aabf01fcd7a330c1620 Mon Sep 17 00:00:00 2001 From: David Howells Date: Wed, 9 Apr 2014 15:43:22 +0100 Subject: [PATCH] Provide generic check for non-combinable parameters Provide generic check for non-combinable parameters in command py files. A list of tuples of pairs of argument names that don't interact is provided by the name cant_combine_arguments as a global var. Signed-off-by: David Howells --- suite/commands/vos/listvldb.py | 13 ++++++++----- suite/main.py | 5 +++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/suite/commands/vos/listvldb.py b/suite/commands/vos/listvldb.py index 2bbe782..a9fd153 100644 --- a/suite/commands/vos/listvldb.py +++ b/suite/commands/vos/listvldb.py @@ -43,6 +43,14 @@ command_arguments = [ [ "noresolve", get_dummy, "fn" ], ] +cant_combine_arguments = [ + ( "cell", "localauth" ), + ( "noauth", "localauth" ), + ( "name", "server" ), + ( "name", "partition" ), + ( "name", "locked" ), +] + description = r""" Displays a volume's VLDB entry """ @@ -114,16 +122,11 @@ def main(params): quiet = "quiet" in params if "name" in params: - if "server" in params or "partition" in params or "locked" in params: - raise RuntimeError("Can't combine -name with -server, -partition or -locked") ret = kafs.VL_GetEntryByName(z_conn, params["name"][0]) vldb = ret.entry print_record(params, vldb) return - if "name" in params: - raise RuntimeError("Can't combine -server, -partition or -locked with -name") - attributes = kafs.VldbListByAttributes() attributes.Mask = 0 diff --git a/suite/main.py b/suite/main.py index 9a6cb2a..aae8f83 100644 --- a/suite/main.py +++ b/suite/main.py @@ -154,6 +154,11 @@ def _main(): # Parse the parameters params = afs.argparse.parse_arguments(sys.argv[1:], command.command_arguments) + for i in command.cant_combine_arguments: + if i[0] in params and i[1] in params: + print("Can't combine -" + i[0], "with -" + i[1], file=sys.stderr) + sys.exit(2) + # Stick in the default cell if there isn't one if "cell" not in params: from afs.lib.cell import cell -- 2.49.0