How to use the tox.exception.InvocationError function in tox

To help you get started, we’ve selected a few tox 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 tox-dev / tox / src / tox / venv.py View on Github external
"""
        name = str(name)
        if os.path.isabs(name):
            return name
        if os.path.split(name)[0] == ".":
            path = cwd.join(name)
            if path.check():
                return str(path)

        if venv:
            path = self._venv_lookup_and_check_external_whitelist(name)
        else:
            path = self._normal_lookup(name)

        if path is None:
            raise tox.exception.InvocationError("could not find executable {!r}".format(name))

        return str(path)  # will not be rewritten for reporting
github tox-dev / tox / src / tox / session.py View on Github external
ret = popen.wait()
        finally:
            self._popenlist.remove(popen)
        if ret and not ignore_ret:
            invoked = " ".join(map(str, popen.args))
            if outpath:
                self.report.error(
                    "invocation failed (exit code {:d}), logfile: {}".format(ret, outpath)
                )
                out = outpath.read()
                self.report.error(out)
                if hasattr(self, "commandlog"):
                    self.commandlog.add_command(popen.args, out, ret)
                raise tox.exception.InvocationError("{} (see {})".format(invoked, outpath), ret)
            else:
                raise tox.exception.InvocationError("{!r}".format(invoked), ret)
        if not out and outpath:
            out = outpath.read()
        if hasattr(self, "commandlog"):
            self.commandlog.add_command(popen.args, out, ret)
        return out
github tox-dev / tox / src / tox / venv.py View on Github external
"""
        name = str(name)
        if os.path.isabs(name):
            return name
        if os.path.split(name)[0] == ".":
            path = cwd.join(name)
            if path.check():
                return str(path)

        if venv:
            path = self._venv_lookup_and_check_external_whitelist(name)
        else:
            path = self._normal_lookup(name)

        if path is None:
            raise tox.exception.InvocationError(
                "could not find executable {}".format(pipes.quote(name))
            )

        return str(path)  # will not be rewritten for reporting
github tox-dev / tox-pipenv / tox_pipenv / plugin.py View on Github external
del argv[0]
                else:
                    argv[0] = argv[0].lstrip("-")
            else:
                ignore_ret = False
            args = [sys.executable, "-m", "pipenv", "run"] + argv
            try:
                venv._pcall(
                    args,
                    venv=False,
                    cwd=cwd,
                    action=action,
                    redirect=redirect,
                    ignore_ret=ignore_ret
                )
            except tox.exception.InvocationError as err:
                if venv.envconfig.ignore_outcome:
                    reporter.warning(
                        "command failed but result from testenv is ignored\n"
                        "  cmd: %s" % (str(err),)
                    )
                    venv.status = "ignored failed command"
                    continue  # keep processing commands

                reporter.error(str(err))
                venv.status = "commands failed"
                if not venv.envconfig.ignore_errors:
                    break  # Don't process remaining commands
            except KeyboardInterrupt:
                venv.status = "keyboardinterrupt"
                reporter.error(venv.status)
                raise
github tox-dev / tox / src / tox / session / commands / run / parallel.py View on Github external
with tox_env.new_action("parallel {}".format(tox_env.name)) as action:

                    def collect_process(process):
                        processes[tox_env] = (action, process)

                    print_out = not live_out and tox_env.envconfig.parallel_show_output
                    output = action.popen(
                        args=args_sub,
                        env=os_env,
                        redirect=not live_out,
                        capture_err=print_out,
                        callback=collect_process,
                        returnout=print_out,
                    )

            except InvocationError as err:
                status = "parallel child exit code {}".format(err.exit_code)
            finally:
                semaphore.release()
                finished.set()
                tox_env.status = status
                done.add(env_name)
                outcome = spinner.succeed
                if config.option.notest:
                    outcome = spinner.skip
                elif status is not None:
                    outcome = spinner.fail
                outcome(env_name)
                if print_out and output is not None:
                    reporter.verbosity0(output)