Esempio n. 1
0
def _run_environment(ctx, name, options, targets, upload_port):
    variables = ["PIOENV=" + name]
    if upload_port:
        variables.append("UPLOAD_PORT=%s" % upload_port)
    for k, v in options.items():
        k = k.upper()
        if k == "TARGETS" or (k == "UPLOAD_PORT" and upload_port):
            continue
        variables.append("%s=%s" % (k.upper(), v))

    envtargets = []
    if targets:
        envtargets = [t for t in targets]
    elif "targets" in options:
        envtargets = options['targets'].split()

    if "platform" not in options:
        raise exception.UndefinedEnvPlatform(name)
    platform = options['platform']

    telemetry.on_run_environment(options, envtargets)

    installed_platforms = PlatformFactory.get_platforms(installed=True).keys()
    if (platform not in installed_platforms and
        (not app.get_setting("enable_prompts")
         or click.confirm("The platform '%s' has not been installed yet. "
                          "Would you like to install it now?" % platform))):
        ctx.invoke(cmd_install, platforms=[platform])

    p = PlatformFactory.newPlatform(platform)
    return p.run(variables, envtargets)
Esempio n. 2
0
    def _run(self):
        if "platform" not in self.options:
            raise exception.UndefinedEnvPlatform(self.name)

        build_vars = self.get_build_variables()
        build_targets = self.get_build_targets()

        telemetry.on_run_environment(self.options, build_targets)

        # skip monitor target, we call it above
        if "monitor" in build_targets:
            build_targets.remove("monitor")
        if "nobuild" not in build_targets:
            # install dependent libraries
            if "lib_install" in self.options:
                _autoinstall_libdeps(self.cmd_ctx, [
                    int(d.strip())
                    for d in self.options['lib_install'].split(",")
                    if d.strip()
                ], self.verbose)
            if "lib_deps" in self.options:
                _autoinstall_libdeps(
                    self.cmd_ctx,
                    util.parse_conf_multi_values(self.options['lib_deps']),
                    self.verbose)

        try:
            p = PlatformFactory.newPlatform(self.options['platform'])
        except exception.UnknownPlatform:
            self.cmd_ctx.invoke(cmd_platform_install,
                                platforms=[self.options['platform']],
                                skip_default_package=True)
            p = PlatformFactory.newPlatform(self.options['platform'])

        return p.run(build_vars, build_targets, self.silent, self.verbose)
Esempio n. 3
0
    def process(self):
        if "platform" not in self.options:
            raise exception.UndefinedEnvPlatform(self.name)

        build_vars = self.get_build_variables()
        build_targets = list(self.get_build_targets())

        telemetry.on_run_environment(self.options, build_targets)

        # skip monitor target, we call it above
        if "monitor" in build_targets:
            build_targets.remove("monitor")

        try:
            p = PlatformFactory.newPlatform(self.options["platform"])
        except exception.UnknownPlatform:
            self.cmd_ctx.invoke(
                cmd_platform_install,
                platforms=[self.options["platform"]],
                skip_default_package=True,
            )
            p = PlatformFactory.newPlatform(self.options["platform"])

        result = p.run(build_vars, build_targets, self.silent, self.verbose,
                       self.jobs)
        return result["returncode"] == 0
Esempio n. 4
0
    def _run(self):
        if "platform" not in self.options:
            raise exception.UndefinedEnvPlatform(self.name)

        build_vars = self._get_build_variables()
        build_targets = self._get_build_targets()

        telemetry.on_run_environment(self.options, build_targets)

        if "nobuild" not in build_targets:
            # install dependent libraries
            if "lib_install" in self.options:
                _autoinstall_libdeps(
                    self.cmd_ctx,
                    [int(d.strip()) for d in self.options["lib_install"].split(",") if d.strip()],
                    self.verbose,
                )
            if "lib_deps" in self.options:
                _autoinstall_libdeps(
                    self.cmd_ctx, [d.strip() for d in self.options["lib_deps"].split(", ") if d.strip()], self.verbose
                )

        try:
            p = PlatformFactory.newPlatform(self.options["platform"])
        except exception.UnknownPlatform:
            self.cmd_ctx.invoke(cmd_platform_install, platforms=[self.options["platform"]], skip_default_package=True)
            p = PlatformFactory.newPlatform(self.options["platform"])

        return p.run(build_vars, build_targets, self.silent, self.verbose)
Esempio n. 5
0
    def _run(self):
        if "platform" not in self.options:
            raise exception.UndefinedEnvPlatform(self.name)

        build_vars = self._get_build_variables()
        build_targets = self._get_build_targets()

        telemetry.on_run_environment(self.options, build_targets)

        # install dependent libraries
        if "lib_install" in self.options:
            _autoinstall_libdeps(self.cmd_ctx, [
                int(d.strip())
                for d in self.options['lib_install'].split(",") if d.strip()
            ], self.verbose)
        if "lib_deps" in self.options:
            _autoinstall_libdeps(self.cmd_ctx, [
                d.strip() for d in self.options['lib_deps'].split(
                    "\n" if "\n" in self.options['lib_deps'] else ", ")
                if d.strip()
            ], self.verbose)

        try:
            p = PlatformFactory.newPlatform(self.options['platform'])
        except exception.UnknownPlatform:
            self.cmd_ctx.invoke(cmd_platform_install,
                                platforms=[self.options['platform']])
            p = PlatformFactory.newPlatform(self.options['platform'])

        return p.run(build_vars, build_targets, self.silent, self.verbose)
Esempio n. 6
0
def _run_environment(ctx, name, options, targets, upload_port):
    variables = ["PIOENV=" + name]
    if upload_port:
        variables.append("UPLOAD_PORT=%s" % upload_port)
    for k, v in options.items():
        k = k.upper()
        if k == "TARGETS" or (k == "UPLOAD_PORT" and upload_port):
            continue
        variables.append("%s=%s" % (k.upper(), v))

    envtargets = []
    if targets:
        envtargets = [t for t in targets]
    elif "targets" in options:
        envtargets = options['targets'].split()

    if "platform" not in options:
        raise exception.UndefinedEnvPlatform(name)
    platform = options['platform']

    telemetry.on_run_environment(options, envtargets)

    installed_platforms = PlatformFactory.get_platforms(
        installed=True).keys()
    if (platform not in installed_platforms and (
            not app.get_setting("enable_prompts") or
            click.confirm("The platform '%s' has not been installed yet. "
                          "Would you like to install it now?" % platform))):
        ctx.invoke(cmd_install, platforms=[platform])

    p = PlatformFactory.newPlatform(platform)
    return p.run(variables, envtargets)
Esempio n. 7
0
    def _run(self):
        if "platform" not in self.options:
            raise exception.UndefinedEnvPlatform(self.name)

        platform = self.options['platform']
        build_vars = self._get_build_variables()
        build_targets = self._get_build_targets()

        telemetry.on_run_environment(self.options, build_targets)

        # install dependent libraries
        if "lib_install" in self.options:
            _autoinstall_libs(self.cmd_ctx, self.options['lib_install'])

        p = PlatformFactory.newPlatform(platform)
        return p.run(build_vars, build_targets, self.verbose_level)
Esempio n. 8
0
    def _run(self):
        if "platform" not in self.options:
            raise exception.UndefinedEnvPlatform(self.name)

        platform = self.options['platform']
        build_vars = self._get_build_variables()
        build_targets = self._get_build_targets()

        telemetry.on_run_environment(self.options, build_targets)

        # install dependent libraries
        if "lib_install" in self.options:
            _autoinstall_libs(self.cmd_ctx, self.options['lib_install'])

        p = PlatformFactory.newPlatform(platform)
        return p.run(build_vars, build_targets, self.verbose_level)
Esempio n. 9
0
    def _run(self):
        if "platform" not in self.options:
            raise exception.UndefinedEnvPlatform(self.name)

        build_vars = self.get_build_variables()
        build_targets = self.get_build_targets()

        telemetry.on_run_environment(self.options, build_targets)

        # skip monitor target, we call it above
        if "monitor" in build_targets:
            build_targets.remove("monitor")
        if "nobuild" not in build_targets:
            # install dependent libraries
            if "lib_install" in self.options:
                _autoinstall_libdeps(self.cmd_ctx, [
                    int(d.strip())
                    for d in self.options['lib_install'].split(",")
                    if d.strip()
                ], self.verbose)
            if "lib_deps" in self.options:
                _autoinstall_libdeps(
                    self.cmd_ctx,
                    util.parse_conf_multi_values(self.options['lib_deps']),
                    self.verbose)

        try:
            p = PlatformFactory.newPlatform(self.options['platform'])
        except exception.UnknownPlatform:
            self.cmd_ctx.invoke(
                cmd_platform_install,
                platforms=[self.options['platform']],
                skip_default_package=True)
            p = PlatformFactory.newPlatform(self.options['platform'])

        return p.run(build_vars, build_targets, self.silent, self.verbose)