@@ -159,18 +159,6 @@ class PadDhcpServer:
159159 exp = 10
160160
161161
162- class PadUsbPort :
163- title = 30
164- name = 20
165- state = 10
166- oper = 10
167-
168- @classmethod
169- def table_width (cls ):
170- """Total width of USB port table"""
171- return cls .name + cls .state + cls .oper
172-
173-
174162class PadSensor :
175163 name = 30
176164 value = 20
@@ -685,12 +673,6 @@ def __init__(self, data):
685673 self .state = get_json_data ('' , self .data , 'state' , 'admin-state' )
686674 self .oper = get_json_data ('' , self .data , 'state' , 'oper-state' )
687675
688- def print (self ):
689- row = f"{ self .name :<{PadUsbPort .name }} "
690- row += f"{ self .state :<{PadUsbPort .state }} "
691- row += f"{ self .oper :<{PadUsbPort .oper }} "
692- print (row )
693-
694676
695677class Sensor :
696678 def __init__ (self , data ):
@@ -1928,8 +1910,7 @@ def show_hardware(json):
19281910 sensors = [c for c in components if c .get ("class" ) == "iana-hardware:sensor" ]
19291911 wifi_radios = [c for c in components if c .get ("class" ) == "infix-hardware:wifi" ]
19301912
1931- # Determine overall width (use the wider of the two sections)
1932- width = max (PadUsbPort .table_width (), PadSensor .table_width (), 100 )
1913+ width = max (PadSensor .table_width (), 100 )
19331914
19341915 # Display full-width inverted heading
19351916 print (Decore .invert (f"{ 'HARDWARE COMPONENTS' :<{width }} " ))
@@ -2001,16 +1982,18 @@ def show_hardware(json):
20011982
20021983 if usb_ports :
20031984 Decore .title ("USB Ports" , width )
2004- hdr = ( f" { 'NAME' :<{ PadUsbPort . name } } "
2005- f" { 'STATE' :<{ PadUsbPort . state } } "
2006- f" { 'OPER' :<{ PadUsbPort . oper } } " )
2007- # Pad header to full width
2008- hdr = f" { hdr :<{ width } } "
2009- print ( Decore . invert ( hdr ) )
1985+
1986+ usb_table = SimpleTable ([
1987+ Column ( 'NAME' ),
1988+ Column ( 'STATE' ),
1989+ Column ( 'OPER' )
1990+ ] )
20101991
20111992 for component in usb_ports :
20121993 port = USBport (component )
2013- port .print ()
1994+ usb_table .row (port .name , port .state , port .oper )
1995+
1996+ usb_table .print ()
20141997
20151998 if sensors :
20161999 Decore .title ("Sensors" , width )
0 commit comments