@@ -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
@@ -841,12 +829,6 @@ def __init__(self, data):
841829 self .state = get_json_data ('' , self .data , 'state' , 'admin-state' )
842830 self .oper = get_json_data ('' , self .data , 'state' , 'oper-state' )
843831
844- def print (self ):
845- row = f"{ self .name :<{PadUsbPort .name }} "
846- row += f"{ self .state :<{PadUsbPort .state }} "
847- row += f"{ self .oper :<{PadUsbPort .oper }} "
848- print (row )
849-
850832
851833class Sensor :
852834 def __init__ (self , data ):
@@ -2084,8 +2066,7 @@ def show_hardware(json):
20842066 sensors = [c for c in components if c .get ("class" ) == "iana-hardware:sensor" ]
20852067 wifi_radios = [c for c in components if c .get ("class" ) == "infix-hardware:wifi" ]
20862068
2087- # Determine overall width (use the wider of the two sections)
2088- width = max (PadUsbPort .table_width (), PadSensor .table_width (), 100 )
2069+ width = max (PadSensor .table_width (), 100 )
20892070
20902071 # Display full-width inverted heading
20912072 print (Decore .invert (f"{ 'HARDWARE COMPONENTS' :<{width }} " ))
@@ -2157,16 +2138,18 @@ def show_hardware(json):
21572138
21582139 if usb_ports :
21592140 Decore .title ("USB Ports" , width )
2160- hdr = ( f" { 'NAME' :<{ PadUsbPort . name } } "
2161- f" { 'STATE' :<{ PadUsbPort . state } } "
2162- f" { 'OPER' :<{ PadUsbPort . oper } } " )
2163- # Pad header to full width
2164- hdr = f" { hdr :<{ width } } "
2165- print ( Decore . invert ( hdr ) )
2141+
2142+ usb_table = SimpleTable ([
2143+ Column ( 'NAME' ),
2144+ Column ( 'STATE' ),
2145+ Column ( 'OPER' )
2146+ ] )
21662147
21672148 for component in usb_ports :
21682149 port = USBport (component )
2169- port .print ()
2150+ usb_table .row (port .name , port .state , port .oper )
2151+
2152+ usb_table .print ()
21702153
21712154 if sensors :
21722155 Decore .title ("Sensors" , width )
0 commit comments