forked from iarv/contact
Compare commits
3 Commits
main
...
display-ip
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ba713366bc | ||
|
|
1c2384ea8d | ||
|
|
4cda264746 |
@@ -1,5 +1,6 @@
|
||||
import base64
|
||||
import curses
|
||||
import ipaddress
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
@@ -122,6 +123,18 @@ def display_menu() -> tuple[object, object]:
|
||||
full_key = ".".join(transformed_path + [option])
|
||||
display_name = field_mapping.get(full_key, option)
|
||||
|
||||
if full_key.startswith("config.network.ipv4_config.") and option in {"ip", "gateway", "subnet", "dns"}:
|
||||
if isinstance(current_value, int):
|
||||
try:
|
||||
current_value = str(ipaddress.IPv4Address(current_value))
|
||||
except ipaddress.AddressValueError:
|
||||
pass
|
||||
elif isinstance(current_value, str) and current_value.isdigit():
|
||||
try:
|
||||
current_value = str(ipaddress.IPv4Address(int(current_value)))
|
||||
except ipaddress.AddressValueError:
|
||||
pass
|
||||
|
||||
display_option = f"{display_name}"[: w // 2 - 2]
|
||||
display_value = f"{current_value}"[: w // 2 - 4]
|
||||
|
||||
|
||||
@@ -536,7 +536,7 @@ def get_fixed32_input(current_value: int) -> int:
|
||||
curses.napms(1500)
|
||||
user_input = ""
|
||||
|
||||
elif key in (curses.KEY_BACKSPACE, 127):
|
||||
elif key in (curses.KEY_BACKSPACE, curses.KEY_DC, 127, 8, "\b", "\x7f"):
|
||||
user_input = user_input[:-1]
|
||||
|
||||
else:
|
||||
|
||||
@@ -112,16 +112,23 @@ def save_changes(interface, modified_settings, menu_state):
|
||||
else:
|
||||
config_category = None
|
||||
|
||||
# Resolve the target config container, including nested sub-messages (e.g., network.ipv4_config)
|
||||
config_container = None
|
||||
if hasattr(node.localConfig, config_category):
|
||||
config_container = getattr(node.localConfig, config_category)
|
||||
elif hasattr(node.moduleConfig, config_category):
|
||||
config_container = getattr(node.moduleConfig, config_category)
|
||||
else:
|
||||
logging.warning(f"Config category '{config_category}' not found in config.")
|
||||
return
|
||||
|
||||
if len(menu_state.menu_path) >= 4:
|
||||
nested_key = menu_state.menu_path[3]
|
||||
if hasattr(config_container, nested_key):
|
||||
config_container = getattr(config_container, nested_key)
|
||||
|
||||
for config_item, new_value in modified_settings.items():
|
||||
# Check if the category exists in localConfig
|
||||
if hasattr(node.localConfig, config_category):
|
||||
config_subcategory = getattr(node.localConfig, config_category)
|
||||
# Check if the category exists in moduleConfig
|
||||
elif hasattr(node.moduleConfig, config_category):
|
||||
config_subcategory = getattr(node.moduleConfig, config_category)
|
||||
else:
|
||||
logging.warning(f"Config category '{config_category}' not found in config.")
|
||||
continue
|
||||
config_subcategory = config_container
|
||||
|
||||
# Check if the config_item exists in the subcategory
|
||||
if hasattr(config_subcategory, config_item):
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "contact"
|
||||
version = "1.4.13"
|
||||
version = "1.4.14"
|
||||
description = "This Python curses client for Meshtastic is a terminal-based client designed to manage device settings, enable mesh chat communication, and handle configuration backups and restores."
|
||||
authors = [
|
||||
{name = "Ben Lipsey",email = "ben@pdxlocations.com"}
|
||||
|
||||
Reference in New Issue
Block a user