Files
es24n-conf-windows/es24n_conf.py
scott 75873dd4e0 Port serial layer to pyserial; add Windows COM detection and PyInstaller spec
- serial_port.py: replace termios/fcntl/select with pyserial wrapper,
  same SerialPort interface preserved for all other modules
- workflow_serial.py: detect_serial_device() uses serial.tools.list_ports
  to enumerate COM ports; removes _fix_permissions() (not needed on Windows);
  multi-device table now shows port description
- es24n_conf.py: enable VT/ANSI colour mode on Windows 10+ via ctypes;
  update docstring for Windows edition
- requirements.txt: pyserial >= 3.5, pyinstaller >= 6.0
- es24n_conf.spec: PyInstaller single-file .exe spec

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-16 15:50:17 -04:00

78 lines
2.2 KiB
Python
Executable File

#!/usr/bin/env python3
"""
ES24N IOM Network Configuration Tool — Windows Edition
TrueNAS ES24N Expansion Shelf — Serial Configuration Utility
Based on ES24N Product Service Guide v.26011
Requires: pyserial (pip install pyserial)
Distributed as a standalone .exe via PyInstaller.
Usage:
python3 es24n_conf.py (or run the packaged .exe)
All files in the modules/ subdirectory must be present:
ui.py, serial_port.py, models.py, redfish.py,
workflow_serial.py, workflow_firmware.py, workflow_check.py
"""
import os
import sys
import time
# Enable ANSI/VT colour codes on Windows 10+
if sys.platform == "win32":
import ctypes
kernel32 = ctypes.windll.kernel32
kernel32.SetConsoleMode(kernel32.GetStdHandle(-11), 7)
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "modules"))
from ui import _c, C, banner, draw_box, ok, warn, prompt
from workflow_check import system_check_workflow
from workflow_firmware import firmware_update_workflow
from workflow_restart import restart_iom_workflow
from workflow_serial import configure_shelf
def main():
while True:
banner()
draw_box([
f" {_c(C.BOLD, '1')} Configure Network Settings",
f" {_c(C.BOLD, '2')} Update IOM / Fabric Card Firmware",
f" {_c(C.BOLD, '3')} Query Current Configuration",
f" {_c(C.BOLD, '4')} Restart IOM",
f" {_c(C.BOLD, '5')} Exit",
])
print()
choice = prompt("Select [1-5]")
if choice == "1":
another = True
while another:
another = configure_shelf()
elif choice == "2":
firmware_update_workflow()
elif choice == "3":
system_check_workflow()
elif choice == "4":
restart_iom_workflow()
elif choice == "5":
break
else:
warn("Please enter 1, 2, 3, 4, or 5.")
time.sleep(1)
print()
ok("Exiting ES24N IOM Configuration Tool. Goodbye.")
print()
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
print()
warn("Interrupted. Exiting.")
sys.exit(0)