Skip to content
Snippets Groups Projects
Commit e3f96988 authored by Björn Vonheiden's avatar Björn Vonheiden
Browse files

fix problem when no configuration parameters are set

parent 72496237
No related branches found
No related tags found
No related merge requests found
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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment