def parse_args()

in adot/utils/soak/soak.py [0:0]


def parse_args():
    # default setting
    _soaking_time, _emitter_interval, _cpu_threshold, _memory_threshold = 10000, 5, 60, 45
    argument_list = sys.argv[1:]
    short_options = "i:t:e:n:c:m:"
    long_options = [
        "interval=",
        "time=",
        "endpoint=",
        "name=",
        "cpu-threshold=",
        "memory-threshold=",
    ]

    try:
        arguments, values = getopt.getopt(argument_list, short_options, long_options)
    except getopt.error as err:
        print(str(err))
        sys.exit(2)

    for current_argument, current_value in arguments:
        if current_argument in ("-i", "--interval"):
            _emitter_interval = int(current_value)
        elif current_argument in ("-t", "--time"):
            _soaking_time = int(current_value)
        elif current_argument in ("-e", "--endpoint"):
            _endpoint = current_value
        elif current_argument in ("-n", "--name"):
            _name = current_value
        elif current_argument in ("-c", "--cpu-threshold"):
            _cpu_threshold = int(current_value)
        elif current_argument in ("-m", "--memory-threshold"):
            _memory_threshold = int(current_value)

    print(
        (
            "Soak test gets started on Lambda function: %s\n"
            "endpoint:\t%s\n"
            "soak time:\t%s sec\n"
            "invoke interval:\t%s sec\n"
            "alarm cpu threshold:\t%s ns\n"
            "alarm memory threshold:\t%s%%"
        )
        % (
            _name,
            _endpoint,
            _soaking_time,
            _emitter_interval,
            _cpu_threshold,
            _memory_threshold,
        )
    )

    return (
        _name,
        _endpoint,
        _soaking_time,
        _emitter_interval,
        _cpu_threshold,
        _memory_threshold,
    )