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 check_platform(self, board_data):
if 'platform' not in board_data:
return
platform = board_data.get('platform')
current_platform = util.get_systype()
if platform != current_platform:
# Incorrect platform
if platform == 'linux_armv7l':
raise Exception(
'incorrect platform: RPI2 or RPI3 required')
else:
raise Exception(
'incorrect platform {0}'.format(platform))
def _get_platform(self):
return util.get_systype()
# -- This file is part of the Apio project
# -- (C) 2016-2018 FPGAwars
# -- Author Jesús Arroyo
# -- Licence GPLv2
import os
import click
import subprocess
from os.path import isfile
from apio import util
from apio.profile import Profile
from apio.resources import Resources
platform = util.get_systype()
FTDI_INSTALL_DRIVER_INSTRUCTIONS = """
FTDI driver installation:
Usage instructions
1. Connect the FTDI FPGA board
2. Select (Interface 0)
3. Replace driver by "libusbK"
4. Reconnect the board
5. Check `apio system --lsftdi`
"""
FTDI_UNINSTALL_DRIVER_INSTRUCTIONS = """
FTDI driver uninstallation:
Usage instructions
vid = board_data.get('usb').get('vid')
programmer = programmer.replace('${VID}', vid)
# Replace USB product id
if '${PID}' in programmer:
pid = board_data.get('usb').get('pid')
programmer = programmer.replace('${PID}', pid)
# Replace FTDI index
if '${FTDI_ID}' in programmer:
self.check_usb(board, board_data)
ftdi_id = self.get_ftdi_id(board, board_data, ext_ftdi_id)
programmer = programmer.replace('${FTDI_ID}', ftdi_id)
# TinyFPGA BX board is not detected in MacOS HighSierra
if 'tinyprog' in board_data and 'darwin' in util.get_systype():
# In this case the serial check is ignored
return 'tinyprog --libusb --program'
# Replace Serial port
if '${SERIAL_PORT}' in programmer:
self.check_usb(board, board_data)
device = self.get_serial_port(board, board_data, ext_serial)
programmer = programmer.replace('${SERIAL_PORT}', device)
return programmer