Skip to content

Commit

Permalink
add devices.py --PORT <#> to disable others
Browse files Browse the repository at this point in the history
  • Loading branch information
maloel committed May 24, 2024
1 parent cc91bfb commit 4cfa904
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions unit-tests/py/rspy/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ def _get_usb_location( physical_port ):

try:
opts,args = getopt.getopt( sys.argv[1:], '',
longopts = [ 'help', 'recycle', 'all', 'none', 'list', 'port=', 'ports' ])
longopts = [ 'help', 'recycle', 'all', 'none', 'list', 'port=', 'PORT=', 'ports' ])
except getopt.GetoptError as err:
print( '-F-', err ) # something like "option -a not recognized"
usage()
Expand All @@ -718,15 +718,15 @@ def get_phys_port(dev):
for opt,arg in opts:
if opt in ('--list'):
action = 'list'
elif opt in ('--port'):
elif opt in ('--port','--PORT'):
if not hub:
log.f( 'No hub available' )
all_ports = hub.all_ports()
str_ports = arg.split(',')
ports = [int(port) for port in str_ports if port.isnumeric() and int(port) in all_ports]
if len(ports) != len(str_ports):
log.f( 'Invalid ports', str_ports )
hub.enable_ports( ports, disable_other_ports=False )
hub.enable_ports( ports, disable_other_ports=(opt == '--PORT') )
action = 'none'
elif opt in ('--ports'):
printer = get_phys_port
Expand Down

0 comments on commit 4cfa904

Please sign in to comment.