How to use the apio.util.safe_join function in apio

To help you get started, we’ve selected a few apio examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github FPGAwars / apio / apio / managers / system.py View on Github external
def _run_command(self, command, silent=False):
        result = {}
        system_base_dir = util.get_package_dir('tools-system')
        system_bin_dir = util.safe_join(system_base_dir, 'bin')

        on_stdout = None if silent else self._on_stdout
        on_stderr = self._on_stderr

        if util.check_package(
            self.name,
            self.version,
            self.spec_version,
            system_bin_dir
        ):
            result = util.exec_command(
                util.safe_join(system_bin_dir, command + self.ext),
                stdout=util.AsyncPipe(on_stdout),
                stderr=util.AsyncPipe(on_stderr))

        return result
github FPGAwars / apio / apio / managers / installer.py View on Github external
def uninstall(self):
        if isdir(util.safe_join(self.packages_dir, self.package_name)):
            click.echo('Uninstalling %s package:' % click.style(
                self.package, fg='cyan'))
            shutil.rmtree(
                util.safe_join(self.packages_dir, self.package_name))
            click.secho(
                """Package \'{}\' has been """
                """successfully uninstalled!""".format(self.package),
                fg='green')
        else:
            util.show_package_path_error(self.package)
        self.profile.remove_package(self.package)
        self.profile.save()
github FPGAwars / apio / apio / managers / drivers.py View on Github external
def _ftdi_enable_windows(self):
        drivers_base_dir = util.get_package_dir('tools-drivers')
        drivers_bin_dir = util.safe_join(drivers_base_dir, 'bin')
        drivers_share_dir = util.safe_join(drivers_base_dir, 'share')
        zadig_ini_path = util.safe_join(drivers_share_dir, 'zadig.ini')
        zadig_ini = 'zadig.ini'

        try:
            if util.check_package(
                self.name,
                self.version,
                self.spec_version,
                drivers_bin_dir
            ):
                click.secho('Launch drivers configuration tool')
                click.secho(FTDI_INSTALL_DRIVER_INSTRUCTIONS, fg='yellow')
                # Copy zadig.ini
                with open(zadig_ini, 'w') as ini_file:
                    with open(zadig_ini_path, 'r') as local_ini_file:
github FPGAwars / apio / apio / managers / drivers.py View on Github external
def _serial_enable_windows(self):
        drivers_base_dir = util.get_package_dir('tools-drivers')
        drivers_bin_dir = util.safe_join(drivers_base_dir, 'bin')

        try:
            if util.check_package(
                self.name,
                self.version,
                self.spec_version,
                drivers_bin_dir
            ):
                click.secho('Launch drivers configuration tool')
                click.secho(SERIAL_INSTALL_DRIVER_INSTRUCTIONS, fg='yellow')
                result = util.exec_command(
                    util.safe_join(drivers_bin_dir, 'serial_install.exe'))
                click.secho('Serial drivers configuration finished',
                            fg='green')
            else:
                result = 1
github FPGAwars / apio / apio / managers / drivers.py View on Github external
def _ftdi_enable_windows(self):
        drivers_base_dir = util.get_package_dir('tools-drivers')
        drivers_bin_dir = util.safe_join(drivers_base_dir, 'bin')
        drivers_share_dir = util.safe_join(drivers_base_dir, 'share')
        zadig_ini_path = util.safe_join(drivers_share_dir, 'zadig.ini')
        zadig_ini = 'zadig.ini'

        try:
            if util.check_package(
                self.name,
                self.version,
                self.spec_version,
                drivers_bin_dir
            ):
                click.secho('Launch drivers configuration tool')
                click.secho(FTDI_INSTALL_DRIVER_INSTRUCTIONS, fg='yellow')
                # Copy zadig.ini
                with open(zadig_ini, 'w') as ini_file:
                    with open(zadig_ini_path, 'r') as local_ini_file:
                        ini_file.write(local_ini_file.read())
github FPGAwars / apio / apio / managers / examples.py View on Github external
def list_examples(self):
        if util.check_package(
            self.name,
            self.version,
            self.spec_version,
            self.examples_dir
        ):
            # examples = sorted(os.listdir(self.examples_dir))
            examples = [dirname(y).replace(self.examples_dir + sep, '')
                        for x in os.walk(self.examples_dir)
                        for y in glob.glob(util.safe_join(x[0], 'info'))]
            click.secho('')
            for example in examples:
                example_dir = util.safe_join(self.examples_dir, example)
                if isdir(example_dir):
                    info_path = util.safe_join(example_dir, 'info')
                    info = ''
                    if isfile(info_path):
                        with codecs.open(info_path, 'r', 'utf-8') as info_file:
                            info = info_file.read().replace('\n', '')
                    click.secho(' ' + example, fg='blue', bold=True)
                    click.secho('-' * click.get_terminal_size()[0])
                    click.secho(' ' + info)
                    click.secho('')
            click.secho(EXAMPLE_DIR_FILE, fg='green')
            click.secho(EXAMPLE_OF_USE_CAD, fg='green')
        else:
            return 1
        return 0
github FPGAwars / apio / apio / managers / drivers.py View on Github external
def _serial_enable_windows(self):
        drivers_base_dir = util.get_package_dir('tools-drivers')
        drivers_bin_dir = util.safe_join(drivers_base_dir, 'bin')

        try:
            if util.check_package(
                self.name,
                self.version,
                self.spec_version,
                drivers_bin_dir
            ):
                click.secho('Launch drivers configuration tool')
                click.secho(SERIAL_INSTALL_DRIVER_INSTRUCTIONS, fg='yellow')
                result = util.exec_command(
                    util.safe_join(drivers_bin_dir, 'serial_install.exe'))
                click.secho('Serial drivers configuration finished',
                            fg='green')
            else:
                result = 1
        except Exception as e:
            click.secho('Error: ' + str(e), fg='red')
            result = 1

        if not isinstance(result, int):
            result = result.get('returncode')
        return result