-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from spacefisch/develop
v1.5.0
- Loading branch information
Showing
57 changed files
with
1,483 additions
and
1,274 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from unittest import TestCase | ||
|
||
|
||
class TestGlobalManager(TestCase): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
VERSION_NAME = "tmtccmd" | ||
VERSION_MAJOR = 1 | ||
VERSION_MINOR = 4 | ||
VERSION_REVISION = 4 | ||
VERSION_MINOR = 5 | ||
VERSION_REVISION = 0 | ||
|
||
# I think this needs to be in string representation to be parsed so we can't | ||
# use a formatted string here. | ||
__version__ = "1.4.4" | ||
|
||
__version__ = "1.5.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,59 @@ | ||
import json | ||
|
||
from tmtccmd.utility.tmtcc_logger import get_logger | ||
|
||
from tmtccmd.utility.logger import get_logger | ||
from tmtccmd.utility.json_handler import check_json_file, JsonKeyNames | ||
from tmtccmd.config.definitions import ComIFDictT | ||
|
||
LOGGER = get_logger() | ||
|
||
|
||
def determine_com_if(integer_to_string_dict: dict, json_cfg_path: str) -> int: | ||
prompt_com_if = False | ||
def determine_com_if(com_if_dict: ComIFDictT, json_cfg_path: str) -> str: | ||
do_prompt_com_if = False | ||
if not check_json_file(json_cfg_path=json_cfg_path): | ||
prompt_com_if = True | ||
|
||
if not prompt_com_if: | ||
do_prompt_com_if = True | ||
if not do_prompt_com_if: | ||
with open(json_cfg_path, "r") as read: | ||
com_if_string = "" | ||
try: | ||
load_data = json.load(read) | ||
com_if_string = load_data[JsonKeyNames.COM_IF.value] | ||
except KeyError: | ||
prompt_com_if = True | ||
com_if_value = convert_com_if_string_to_integer(com_if_string) | ||
if com_if_value != -1: | ||
return com_if_value | ||
else: | ||
prompt_com_if = True | ||
if prompt_com_if: | ||
while True: | ||
for integer_rep, string_rep in integer_to_string_dict.items(): | ||
print(f"{integer_rep}: {string_rep}") | ||
com_if_key = input("Please enter the desired communication interface by key: ") | ||
if not com_if_key.isdigit(): | ||
print("Key is not a digit, try again") | ||
continue | ||
com_if_key = int(com_if_key) | ||
if com_if_key in integer_to_string_dict: | ||
com_if_string = integer_to_string_dict[com_if_key] | ||
break | ||
else: | ||
print("Invalid key, try again.") | ||
do_prompt_com_if = True | ||
com_if_string = str(com_if_string) | ||
if do_prompt_com_if: | ||
com_if_string = prompt_com_if(com_if_dict=com_if_dict) | ||
save_to_json = input("Do you want to store the communication interface? (y/n): ") | ||
if save_to_json.lower() in ['y', "yes", "1"]: | ||
with open(json_cfg_path, "r+") as file: | ||
data = json.load(file) | ||
data[JsonKeyNames.COM_IF.value] = com_if_string | ||
file.seek(0) | ||
json.dump(data, file, indent=4) | ||
LOGGER.info( | ||
"Communication interface was stored in the JSON file config/tmtcc_config.json" | ||
) | ||
LOGGER.info("Delete this file or edit it manually to edit the communication interface") | ||
return com_if_key | ||
|
||
|
||
def convert_com_if_string_to_integer(com_if_string: str) -> int: | ||
from tmtccmd.core.definitions import CoreComInterfacesString | ||
for com_if_int, com_if_string_in_dict in CoreComInterfacesString.items(): | ||
if com_if_string == com_if_string_in_dict: | ||
return com_if_int | ||
return -1 | ||
store_com_if_json(com_if_string=com_if_string, json_cfg_path=json_cfg_path) | ||
return com_if_string | ||
|
||
|
||
def prompt_com_if(com_if_dict: dict) -> str: | ||
while True: | ||
com_if_list = [] | ||
for index, com_if_value in enumerate(com_if_dict.items()): | ||
print(f"{index}: {com_if_value}") | ||
com_if_list.append(com_if_value) | ||
com_if_key = input("Please enter the desired communication interface by key: ") | ||
if not com_if_key.isdigit(): | ||
print("Key is not a digit, try again") | ||
continue | ||
com_if_key = int(com_if_key) | ||
if com_if_key >= len(com_if_list): | ||
print("Key invalid, try again.") | ||
continue | ||
com_if_string = com_if_list[com_if_key][0] | ||
break | ||
return com_if_string | ||
|
||
|
||
def store_com_if_json(com_if_string: str, json_cfg_path: str): | ||
with open(json_cfg_path, "r+") as file: | ||
data = json.load(file) | ||
data[JsonKeyNames.COM_IF.value] = com_if_string | ||
file.seek(0) | ||
json.dump(data, file, indent=4) | ||
LOGGER.info( | ||
f"Communication interface was stored in the JSON file {json_cfg_path}" | ||
) | ||
LOGGER.info("Delete this file or edit it manually to edit the communication interface") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.