From d119e748c92039e34dac42f64a01295608de7ae8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Vonheiden?= <bjoern.vonheiden@hotmail.de> Date: Mon, 30 Nov 2020 12:15:48 +0100 Subject: [PATCH] fix problem when no configuration parameters are set --- execution/lib/cli_parser.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/execution/lib/cli_parser.py b/execution/lib/cli_parser.py index a9c51139f..63896efe9 100644 --- a/execution/lib/cli_parser.py +++ b/execution/lib/cli_parser.py @@ -1,6 +1,7 @@ import argparse import os + def env_list_default(env, tf): """ Makes a list from an environment string. @@ -17,7 +18,7 @@ def key_values_to_dict(kvs): """ my_dict = {} for kv in kvs: - k,v = kv.split("=") + k, v = kv.split("=") my_dict[k] = v return my_dict @@ -29,15 +30,19 @@ def env_dict_default(env): v = os.environ.get(env) if v is not None: return key_values_to_dict(v.split(',')) + else: + return dict() class StoreDictKeyPair(argparse.Action): - def __init__(self, option_strings, dest, nargs=None, **kwargs): - self._nargs = nargs - super(StoreDictKeyPair, self).__init__(option_strings, dest, nargs=nargs, **kwargs) - def __call__(self, parser, namespace, values, option_string=None): - my_dict = key_values_to_dict(values) - setattr(namespace, self.dest, my_dict) + def __init__(self, option_strings, dest, nargs=None, **kwargs): + self._nargs = nargs + super(StoreDictKeyPair, self).__init__( + option_strings, dest, nargs=nargs, **kwargs) + + def __call__(self, parser, namespace, values, option_string=None): + my_dict = key_values_to_dict(values) + setattr(namespace, self.dest, my_dict) def default_parser(description): @@ -81,7 +86,8 @@ def default_parser(description): help='Only resets the environment. Ignores all other parameters') parser.add_argument('--prometheus', metavar='<URL>', - default=os.environ.get('PROMETHEUS_BASE_URL', 'http://localhost:9090'), + default=os.environ.get( + 'PROMETHEUS_BASE_URL', 'http://localhost:9090'), help='Defines where to find the prometheus instance') parser.add_argument('--path', metavar='<path>', @@ -96,6 +102,7 @@ def default_parser(description): help='Defines the environment variables for the UC') return parser + def benchmark_parser(description): """ Parser for the overall benchmark execution @@ -125,6 +132,7 @@ def benchmark_parser(description): help='The benchmarking search strategy. Can be set to default, linear-search or binary-search') return parser + def execution_parser(description): """ Parser for executing one use case -- GitLab