Esempio n. 1
0
    def check(self, on_defect_callback=None):
        self._on_defect_callback = on_defect_callback
        project_files = self.get_project_target_files(self.options["patterns"])

        languages = ("c", "c++")
        if not any([project_files[t] for t in languages]):
            click.echo("Error: Nothing to check.")
            return True
        for language in languages:
            if not project_files[language]:
                continue
            cmd = self.configure_command(language, project_files[language])
            if not cmd:
                self._bad_input = True
                continue
            if self.options.get("verbose"):
                click.echo(" ".join(cmd))

            proc.exec_command(
                cmd,
                stdout=proc.LineBufferedAsyncPipe(self.on_tool_output),
                stderr=proc.LineBufferedAsyncPipe(self.on_tool_output),
            )

        self.clean_up()

        return self._bad_input
Esempio n. 2
0
    def _run_scons(self, variables, targets, jobs):
        args = [
            proc.get_pythonexe_path(),
            join(get_core_package_dir("tool-scons"), "script", "scons"),
            "-Q",
            "--warn=no-no-parallel-support",
            "--jobs",
            str(jobs),
            "--sconstruct",
            join(fs.get_source_dir(), "builder", "main.py"),
        ]
        args.append("PIOVERBOSE=%d" % (1 if self.verbose else 0))
        # pylint: disable=protected-access
        args.append("ISATTY=%d" %
                    (1 if click._compat.isatty(sys.stdout) else 0))
        args += targets

        # encode and append variables
        for key, value in variables.items():
            args.append("%s=%s" % (key.upper(), self.encode_scons_arg(value)))

        proc.copy_pythonpath_to_osenv()

        if targets and "menuconfig" in targets:
            return proc.exec_command(args,
                                     stdout=sys.stdout,
                                     stderr=sys.stderr,
                                     stdin=sys.stdin)

        if click._compat.isatty(sys.stdout):

            def _write_and_flush(stream, data):
                try:
                    stream.write(data)
                    stream.flush()
                except IOError:
                    pass

            return proc.exec_command(
                args,
                stdout=proc.BuildAsyncPipe(
                    line_callback=self._on_stdout_line,
                    data_callback=lambda data: _write_and_flush(
                        sys.stdout, data),
                ),
                stderr=proc.BuildAsyncPipe(
                    line_callback=self._on_stderr_line,
                    data_callback=lambda data: _write_and_flush(
                        sys.stderr, data),
                ),
            )

        return proc.exec_command(
            args,
            stdout=proc.LineBufferedAsyncPipe(
                line_callback=self._on_stdout_line),
            stderr=proc.LineBufferedAsyncPipe(
                line_callback=self._on_stderr_line),
        )
Esempio n. 3
0
    def check(self, on_defect_callback=None):
        self._on_defect_callback = on_defect_callback
        cmd = self.configure_command()
        if self.options.get("verbose"):
            click.echo(" ".join(cmd))

        proc.exec_command(
            cmd,
            stdout=proc.LineBufferedAsyncPipe(self.on_tool_output),
            stderr=proc.LineBufferedAsyncPipe(self.on_tool_output),
        )

        self.clean_up()

        return self._bad_input
Esempio n. 4
0
    def execute_check_cmd(self, cmd):
        result = proc.exec_command(
            cmd,
            stdout=proc.LineBufferedAsyncPipe(self.on_tool_output),
            stderr=proc.LineBufferedAsyncPipe(self.on_tool_output),
        )

        if not self.is_check_successful(result):
            click.echo(
                "\nError: Failed to execute check command! Exited with code %d."
                % result["returncode"])
            if self.options.get("verbose"):
                click.echo(result["out"])
                click.echo(result["err"])
            self._bad_input = True

        return result