Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _load_resource(self, name):
resource = None
filepath = util.safe_join(util.get_folder('resources'), name + '.json')
with open(filepath, 'r') as f:
# Load the JSON file
resource = json.loads(f.read())
return resource
# -*- coding: utf-8 -*-
# -- This file is part of the Apio project
# -- (C) 2016-2018 FPGAwars
# -- Author Jesús Arroyo
# -- Licence GPLv2
import click
from os import listdir
from os.path import isfile
from sys import exit as sys_exit
from apio import util
commands_folder = util.get_folder('commands')
class ApioCLI(click.MultiCommand):
def list_commands(self, ctx):
rv = []
for filename in listdir(commands_folder):
if filename.startswith('__init__'):
continue
if filename.endswith('.py'):
rv.append(filename[:-3])
rv.sort()
return rv
def get_command(self, ctx, name):
ns = {}
def create_sconstruct(self, project_dir='', sayyes=False):
"""Creates a default SConstruct file"""
project_dir = util.check_dir(project_dir)
sconstruct_name = 'SConstruct'
sconstruct_path = util.safe_join(project_dir, sconstruct_name)
local_sconstruct_path = util.safe_join(
util.get_folder('resources'), sconstruct_name)
if isfile(sconstruct_path):
# -- If sayyes, skip the question
if sayyes:
self._copy_sconstruct_file(sconstruct_name, sconstruct_path,
local_sconstruct_path)
else:
click.secho(
'Warning: {} file already exists'.format(sconstruct_name),
fg='yellow')
if click.confirm('Do you want to replace it?'):
self._copy_sconstruct_file(sconstruct_name,
sconstruct_path,
local_sconstruct_path)
else:
def run(self, command, variables=[], board=None, packages=[]):
"""Executes scons for building"""
# -- Check for the SConstruct file
if not isfile(util.safe_join(util.get_project_dir(), 'SConstruct')):
variables += ['-f']
variables += [util.safe_join(
util.get_folder('resources'), 'SConstruct')]
else:
click.secho('Info: use custom SConstruct file')
# -- Resolve packages
if self.profile.check_exe_default():
# Run on `default` config mode
if not util.resolve_packages(
packages,
self.profile.packages,
self.resources.distribution.get('packages')
):
# Exit if a package is not installed
raise Exception
else:
click.secho('Info: native config mode')
3. Select "Uninstall"
4. Accept the dialog
"""
class Drivers(object): # pragma: no cover
# FTDI rules files paths
ftdi_rules_local_path = util.safe_join(
util.get_folder('resources'), '80-fpga-ftdi.rules')
ftdi_rules_system_path = '/etc/udev/rules.d/80-fpga-ftdi.rules'
old_ftdi_rules_system_path = '/etc/udev/rules.d/80-icestick.rules'
# Serial rules files paths
serial_rules_local_path = util.safe_join(
util.get_folder('resources'), '80-fpga-serial.rules')
serial_rules_system_path = '/etc/udev/rules.d/80-fpga-serial.rules'
# Driver to restore: mac os
driverC = ''
def ftdi_enable(self):
if 'linux' in platform:
return self._ftdi_enable_linux()
elif 'darwin' in platform:
self._setup_darwin()
return self._ftdi_enable_darwin()
elif 'windows' in platform:
self._setup_windows()
return self._ftdi_enable_windows()
def ftdi_disable(self):