Skip to content

Commit

Permalink
Expanded configuration in management mode
Browse files Browse the repository at this point in the history
  • Loading branch information
connervieira committed Oct 19, 2023
1 parent 7959348 commit 94758d6
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -343,3 +343,4 @@ This update makes several changes to Predator that dramatically improve its proc
- Removed real-time object recognition.
- Refined the real-time mode interface to better accomodate multiple plates being displayed at once.
- Added multi-threaded debug messsage support.
- Expanded management mode capabilties to allow for setting deeper nested configuration values.
10 changes: 7 additions & 3 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@
"validation": {
"guesses": 15,
"confidence": 80,
"license_plate_format": ["AAA0000"],
"license_plate_format": [
"AAA0000"
],
"best_effort": false
}
},
"alerts": {
"alerts_ignore_validation": true,
"allow_duplicate_alerts": false,
"databases": ["https://v0lttech.com/predator/plates/emergency.json"]
"databases": [
"https://v0lttech.com/predator/plates/emergency.json"
]
},
"display": {
"ascii_art_header": true,
Expand All @@ -26,7 +30,7 @@
"enabled": false
},
"modes": {
"auto_start": "",
"auto_start": "0",
"enabled": {
"management": true,
"prerecorded": true,
Expand Down
52 changes: 52 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,58 @@
else:
print(" '" + style.italic + str(section) + style.end + "': '" + str(config[selection1][selection2][selection3][section]) + "'") # If the entry is not a dictionary (meaning it's an actual configuration value), display it in italics.
selection4 = prompt("=============== Selection (Tier 4): ", optional=False, input_type=str)
if (selection4 in config[selection1][selection2][selection3]): # Check to make sure the section entered by the user actually exists in the configuration database.
if (type(config[selection1][selection2][selection3][selection4]) is dict): # Check to make sure the current selection is a dictionary before trying to iterate through it.
for section in config[selection1][selection2][selection3][selection4]: # Iterate through each fourth-level section of the configuration database, and display them all to the user.
if (type(config[selection1][selection2][selection3][selection4][section]) is dict): # Check to see if the current section we're iterating over is a dictionary.
print(" '" + style.bold + str(section) + style.end + "'") # If the entry is a dictionary, display it in bold.
else:
print(" '" + style.italic + str(section) + style.end + "': '" + str(config[selection1][selection2][selection3][selection4][section]) + "'") # If the entry is not a dictionary (meaning it's an actual configuration value), display it in italics.
selection5 = prompt("=================== Selection (Tier 5): ", optional=False, input_type=str)
if (selection5 in config[selection1][selection2][selection3][selection4]): # Check to make sure the section entered by the user actually exists in the configuration database.
if (type(config[selection1][selection2][selection3][selection4][selection5]) is dict): # Check to make sure the current selection is a dictionary before trying to iterate through it.
for section in config[selection1][selection2][selection3][selection4][selection5]: # Iterate through each fifth-level section of the configuration database, and display them all to the user.
if (type(config[selection1][selection2][selection3][selection4][selection5][section]) is dict): # Check to see if the current section we're iterating over is a dictionary.
print(" '" + style.bold + str(section) + style.end + "'") # If the entry is a dictionary, display it in bold.
else:
print(" '" + style.italic + str(section) + style.end + "': '" + str(config[selection1][selection2][selection3][selection4][selection5][section]) + "'") # If the entry is not a dictionary (meaning it's an actual configuration value), display it in italics.
selection6 = prompt("======================= Selection (Tier 6): ", optional=False, input_type=str)
if (selection6 in config[selection1][selection2][selection3][selection4][selection5]): # Check to make sure the section entered by the user actually exists in the configuration database.
if (type(config[selection1][selection2][selection3][selection4][selection5][selection6]) is dict): # Check to make sure the current selection is a dictionary before trying to iterate through it.
for section in config[selection1][selection2][selection3][selection4][selection5][selection6]: # Iterate through each sixth-level section of the configuration database, and display them all to the user.
if (type(config[selection1][selection2][selection3][selection4][selection5][selection6][section]) is dict): # Check to see if the current section we're iterating over is a dictionary.
print(" '" + style.bold + str(section) + style.end + "'") # If the entry is a dictionary, display it in bold.
else:
print(" '" + style.italic + str(section) + style.end + "': '" + str(config[selection1][selection2][selection3][selection4][selection5][selection6][section]) + "'") # If the entry is not a dictionary (meaning it's an actual configuration value), display it in italics.
selection7 = prompt("=========================== Selection (Tier 7): ", optional=False, input_type=str)
if (selection7 in config[selection1][selection2][selection3][selection4][selection5][selection6]): # Check to make sure the section entered by the user actually exists in the configuration database.
if (type(config[selection1][selection2][selection3][selection4][selection5][selection6][selection7]) is dict): # Check to make sure the current selection is a dictionary before trying to iterate through it.
for section in config[selection1][selection2][selection3][selection4][selection5][selection6][selection7]: # Iterate through each sixth-level section of the configuration database, and display them all to the user.
if (type(config[selection1][selection2][selection3][selection4][selection5][selection6][selection7][section]) is dict): # Check to see if the current section we're iterating over is a dictionary.
print(" '" + style.bold + str(section) + style.end + "'") # If the entry is a dictionary, display it in bold.
else:
print(" '" + style.italic + str(section) + style.end + "': '" + str(config[selection1][selection2][selection3][selection4][selection5][selection6][selection7][section]) + "'") # If the entry is not a dictionary (meaning it's an actual configuration value), display it in italics.
selection8 = prompt("=============================== Selection (Tier 8): ", optional=False, input_type=str)
else: # If the current selection isn't a dictionary, assume that it's an configuration entry. (Tier 7)
print(" Current Value: " + str(config[selection1][selection2][selection3][selection4][selection5][selection6][selection7]))
config[selection1][selection2][selection3][selection4][selection5][selection6][selection7] = prompt(" New Value (" + str(type(config[selection1][selection2][selection3][selection4][selection5][selection6][selection7])) + "): ", optional=True, input_type=type(config[selection1][selection2][selection3][selection4][selection5][selection6][selection7]), default="")
elif (selection7 != ""):
display_message("Unknown configuration entry selected.", 3)
else: # If the current selection isn't a dictionary, assume that it's an configuration entry. (Tier 6)
print(" Current Value: " + str(config[selection1][selection2][selection3][selection4][selection5][selection6]))
config[selection1][selection2][selection3][selection4][selection5][selection6] = prompt(" New Value (" + str(type(config[selection1][selection2][selection3][selection4][selection5][selection6])) + "): ", optional=True, input_type=type(config[selection1][selection2][selection3][selection4][selection5][selection6]), default="")
elif (selection6 != ""):
display_message("Unknown configuration entry selected.", 3)
else: # If the current selection isn't a dictionary, assume that it's an configuration entry. (Tier 5)
print(" Current Value: " + str(config[selection1][selection2][selection3][selection4][selection5]))
config[selection1][selection2][selection3][selection4][selection5] = prompt(" New Value (" + str(type(config[selection1][selection2][selection3][selection4][selection5])) + "): ", optional=True, input_type=type(config[selection1][selection2][selection3][selection4][selection5]), default="")
elif (selection5 != ""):
display_message("Unknown configuration entry selected.", 3)
else: # If the current selection isn't a dictionary, assume that it's an configuration entry. (Tier 4)
print(" Current Value: " + str(config[selection1][selection2][selection3][selection4]))
config[selection1][selection2][selection3][selection4] = prompt(" New Value (" + str(type(config[selection1][selection2][selection3][selection4])) + "): ", optional=True, input_type=type(config[selection1][selection2][selection3][selection4]), default="")
elif (selection4 != ""):
display_message("Unknown configuration entry selected.", 3)
else: # If the current selection isn't a dictionary, assume that it's an configuration entry. (Tier 3)
print(" Current Value: " + str(config[selection1][selection2][selection3]))
config[selection1][selection2][selection3] = prompt(" New Value (" + str(type(config[selection1][selection2][selection3])) + "): ", optional=True, input_type=type(config[selection1][selection2][selection3]), default="")
Expand Down
2 changes: 1 addition & 1 deletion utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ def prompt(message, optional=True, input_type=str, default=""):

elif (input_type == list):
user_input = user_input.split(",") # Convert the user's input into a list.
user_input = [element.strip() for element in user_input]
user_input = [element.strip() for element in user_input] # Strip any leading or trailing white space on each element in the list.

return user_input

Expand Down

0 comments on commit 94758d6

Please sign in to comment.