Skip to content

Commit

Permalink
Merge pull request #58 from robamu-org/eive
Browse files Browse the repository at this point in the history
Important bugfixes
  • Loading branch information
robamu committed Mar 9, 2022
2 parents 031b92c + 1aeb44e commit 5ebc16a
Showing 1 changed file with 26 additions and 22 deletions.
48 changes: 26 additions & 22 deletions src/tmtccmd/config/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Argument parser modules for the TMTC commander core
"""
import argparse
import pprint
import sys

from prompt_toolkit.completion import WordCompleter
Expand Down Expand Up @@ -247,26 +248,29 @@ def handle_unspecified_args(args) -> None:

if args.mode is None:
args.mode = CoreModeStrings[CoreModeList.SEQUENTIAL_CMD_MODE]
service_op_code_dict = dict()
if args.service is None or args.op_code is None:
hook_obj = get_global_hook_obj()
service_op_code_dict = hook_obj.get_service_op_code_dictionary()
hook_obj = get_global_hook_obj()
service_op_code_dict = hook_obj.get_service_op_code_dictionary()
if service_op_code_dict is None:
LOGGER.warning("Invalid Service to Op-Code dictionary detected")
if args.service is None:
args.service = "0"
if args.op_code is None:
args.op_code = "0"
return
if args.service is None:
if args.mode == CoreModeStrings[CoreModeList.SEQUENTIAL_CMD_MODE]:
LOGGER.info("No service argument (-s) specified, prompting from user..")
# Try to get the service list from the hook base and prompt service from user
args.service = prompt_service(service_op_code_dict)
if args.op_code is None:
current_service = args.service
args.op_code = prompt_op_code(
service_op_code_dict=service_op_code_dict, service=current_service
)
elif args.op_code is None:
if args.op_code is None:
current_service = args.service
args.op_code = prompt_op_code(
service_op_code_dict=service_op_code_dict, service=current_service
)
if args.service is not None:
op_code_value = service_op_code_dict.get(args.service)
if op_code_value is None:
LOGGER.warning(f"No Service to Op-Code entry found for service {args.service}")
else:
op_code_value = service_op_code_dict[args.service][1]
op_code_options = op_code_value[args.op_code][1]
if op_code_options is not None and isinstance(op_code_options, dict):
Expand All @@ -281,17 +285,17 @@ def handle_unspecified_args(args) -> None:
"Detected op code listerner mode configuration but is "
"overriden by CLI argument"
)
timeout = op_code_options.get(OpCodeDictKeys.TIMEOUT)
if timeout is not None:
if args.tm_timeout is None:
LOGGER.info(
f"Detected op code configuration: Set custom timeout {timeout}"
)
args.tm_timeout = timeout
else:
LOGGER.warning(
"Detected op code timeout configuration but is overriden by CLI argument"
)
timeout = op_code_options.get(OpCodeDictKeys.TIMEOUT)
if timeout is not None:
if args.tm_timeout is None:
LOGGER.info(
f"Detected op code configuration: Set custom timeout {timeout}"
)
args.tm_timeout = timeout
else:
LOGGER.warning(
"Detected op code timeout configuration but is overriden by CLI argument"
)
if args.tm_timeout is None:
args.tm_timeout = 5.0
if args.listener is None:
Expand Down

0 comments on commit 5ebc16a

Please sign in to comment.