Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def cli(ctx, lsftdi, lsusb, lsserial, info):
"""System tools.\n
Install with `apio install system`"""
exit_code = 0
if lsftdi:
exit_code = System().lsftdi()
elif lsusb:
exit_code = System().lsusb()
elif lsserial:
exit_code = System().lsserial()
elif info:
click.secho('Platform: ', nl=False)
click.secho(get_systype(), fg='yellow')
else:
click.secho(ctx.get_help())
ctx.exit(exit_code)
def cli(ctx, lsftdi, lsusb, lsserial, info):
"""System tools.\n
Install with `apio install system`"""
exit_code = 0
if lsftdi:
exit_code = System().lsftdi()
elif lsusb:
exit_code = System().lsusb()
elif lsserial:
exit_code = System().lsserial()
elif info:
click.secho('Platform: ', nl=False)
click.secho(get_systype(), fg='yellow')
else:
click.secho(ctx.get_help())
ctx.exit(exit_code)
def cli(ctx, lsftdi, lsusb, lsserial, info):
"""System tools.\n
Install with `apio install system`"""
exit_code = 0
if lsftdi:
exit_code = System().lsftdi()
elif lsusb:
exit_code = System().lsusb()
elif lsserial:
exit_code = System().lsserial()
elif info:
click.secho('Platform: ', nl=False)
click.secho(get_systype(), fg='yellow')
else:
click.secho(ctx.get_help())
ctx.exit(exit_code)
def _check_ftdi(self, board, board_data, ext_ftdi_id):
if 'ftdi' not in board_data:
raise Exception('Missing board configuration: ftdi')
desc_pattern = '^' + board_data.get('ftdi').get('desc') + '$'
# Match the discovered FTDI chips
ftdi_devices = System().get_ftdi_devices()
if len(ftdi_devices) == 0:
# Board not available
raise Exception('board ' + board + ' not available')
for ftdi_device in ftdi_devices:
index = ftdi_device.get('index')
if ext_ftdi_id and ext_ftdi_id != index:
# If the --device options is set but it doesn't match
# with the detected index, skip the port.
continue
if re.match(desc_pattern, ftdi_device.get('description')):
# If matches the description pattern
# return the index for the FTDI device.
return index
def check_usb(self, board, board_data):
if 'usb' not in board_data:
raise Exception('Missing board configuration: usb')
usb_data = board_data.get('usb')
hwid = '{0}:{1}'.format(
usb_data.get('vid'),
usb_data.get('pid')
)
found = False
for usb_device in System().get_usb_devices():
if usb_device.get('hwid') == hwid:
found = True
break
if not found:
# Board not connected
if 'tinyprog' in board_data:
click.secho(
'Activate bootloader by pressing the reset button',
fg='yellow')
raise Exception('board ' + board + ' not connected')