Ejemplo n.º 1
0
def main():
    try:
        configure()
        cli(None, None, None)
    except Exception as e:  # pylint: disable=broad-except
        if not isinstance(e, exception.ReturnErrorCode):
            maintenance.on_platformio_exception(e)
            error_str = "Error: "
            if isinstance(e, exception.PlatformioException):
                error_str += str(e)
            else:
                error_str += format_exc()
                error_str += """
============================================================

An unexpected error occurred. Further steps:

* Verify that you have the latest version of PlatformIO using
  `pip install -U platformio` command

* Try to find answer in FAQ Troubleshooting section
  http://docs.platformio.org/page/faq.html

* Report this problem to the developers
  https://github.com/platformio/platformio-core/issues

============================================================
"""
            click.secho(error_str, fg="red", err=True)
        return int(str(e)) if str(e).isdigit() else 1
    return 0
Ejemplo n.º 2
0
def main():
    try:
        if "cygwin" in system().lower():
            raise exception.CygwinEnvDetected()

        # https://urllib3.readthedocs.org
        # /en/latest/security.html#insecureplatformwarning
        try:
            requests.packages.urllib3.disable_warnings()
        except AttributeError:
            raise exception.PlatformioException(
                "Invalid installation of Python `requests` package`. See "
                "< https://github.com/platformio/platformio/issues/252 >")

        cli(None, None, None)
    except Exception as e:  # pylint: disable=W0703
        if not isinstance(e, exception.ReturnErrorCode):
            maintenance.on_platformio_exception(e)
            error_str = "Error: "
            if isinstance(e, exception.PlatformioException):
                error_str += str(e)
            else:
                error_str += format_exc()
            click.secho(error_str, fg="red", err=True)
        return 1
    return 0
Ejemplo n.º 3
0
def main():
    try:
        if "cygwin" in system().lower():
            raise exception.CygwinEnvDetected()

        # https://urllib3.readthedocs.org
        # /en/latest/security.html#insecureplatformwarning
        try:
            requests.packages.urllib3.disable_warnings()
        except AttributeError:
            raise exception.PlatformioException(
                "Invalid installation of Python `requests` package`. See "
                "< https://github.com/platformio/platformio/issues/252 >")

        cli(None, None, None)
    except Exception as e:  # pylint: disable=W0703
        if not isinstance(e, exception.ReturnErrorCode):
            maintenance.on_platformio_exception(e)
            error_str = "Error: "
            if isinstance(e, exception.PlatformioException):
                error_str += str(e)
            else:
                error_str += format_exc()
            click.secho(error_str, fg="red", err=True)
        return 1
    return 0
Ejemplo n.º 4
0
def main():
    try:
        cli(None)
    except Exception as e:  # pylint: disable=W0703
        maintenance.on_platformio_exception(e)
        if isinstance(e, PlatformioException):
            click.echo("Error: " + str(e))
            sys_exit(1)
        else:
            print format_exc()
Ejemplo n.º 5
0
def main():
    try:
        if "cygwin" in system().lower():
            raise exception.CygwinEnvDetected()

        # https://urllib3.readthedocs.org
        # /en/latest/security.html#insecureplatformwarning
        try:
            requests.packages.urllib3.disable_warnings()
        except AttributeError:
            raise exception.PlatformioException(
                "Invalid installation of Python `requests` package`. See "
                "< https://github.com/platformio/platformio/issues/252 >")

        # handle PLATFORMIO_FORCE_COLOR
        if str(getenv("PLATFORMIO_FORCE_COLOR", "")).lower() == "true":
            try:
                # pylint: disable=protected-access
                click._compat.isatty = lambda stream: True
            except:  # pylint: disable=bare-except
                pass

        cli(None, None, None)
    except Exception as e:  # pylint: disable=W0703
        if not isinstance(e, exception.ReturnErrorCode):
            maintenance.on_platformio_exception(e)
            error_str = "Error: "
            if isinstance(e, exception.PlatformioException):
                error_str += str(e)
            else:
                error_str += format_exc()
                error_str += """
============================================================

An unexpected error occurred. Further steps:

* Verify that you have the latest version of PlatformIO using
  `pip install -U platformio` command

* Try to find answer in FAQ Troubleshooting section
  http://docs.platformio.org/en/stable/faq.html

* Report this problem to the developers
  https://github.com/platformio/platformio/issues

============================================================
"""
            click.secho(error_str, fg="red", err=True)
        return 1
    return 0
Ejemplo n.º 6
0
def main():
    try:
        if "cygwin" in system().lower():
            raise exception.CygwinEnvDetected()

        # https://urllib3.readthedocs.org
        # /en/latest/security.html#insecureplatformwarning
        try:
            requests.packages.urllib3.disable_warnings()
        except AttributeError:
            raise exception.PlatformioException(
                "Invalid installation of Python `requests` package`. See "
                "< https://github.com/platformio/platformio/issues/252 >")

        # handle PLATFORMIO_FORCE_COLOR
        if str(getenv("PLATFORMIO_FORCE_COLOR", "")).lower() == "true":
            try:
                # pylint: disable=protected-access
                click._compat.isatty = lambda stream: True
            except:  # pylint: disable=bare-except
                pass

        cli(None, None, None)
    except Exception as e:  # pylint: disable=W0703
        if not isinstance(e, exception.ReturnErrorCode):
            maintenance.on_platformio_exception(e)
            error_str = "Error: "
            if isinstance(e, exception.PlatformioException):
                error_str += str(e)
            else:
                error_str += format_exc()
                error_str += """
============================================================

An unexpected error occurred. Further steps:

* Verify that you have the latest version of PlatformIO using
  `pip install -U platformio` command

* Try to find answer in FAQ Troubleshooting section
  http://docs.platformio.org/en/stable/faq.html

* Report this problem to the developers
  https://github.com/platformio/platformio/issues

============================================================
"""
            click.secho(error_str, fg="red", err=True)
        return 1
    return 0
Ejemplo n.º 7
0
    def cb_global_error(self, err):
        if err.check(pb.PBConnectionLost, defer.CancelledError):
            return

        msg = err.getErrorMessage()
        if err.check(pb.DeadReferenceError):
            msg = "Remote Client has been terminated"
        elif "PioAgentNotStartedError" in str(err.type):
            msg = ("Could not find active agents. Please start it before on "
                   "a remote machine using `pio remote agent start` command.\n"
                   "See http://docs.platformio.org/page/plus/pio-remote.html")
        else:
            maintenance.on_platformio_exception(Exception(err.type))
        click.secho(msg, fg="red", err=True)
        self.disconnect(exit_code=1)
Ejemplo n.º 8
0
def main():
    try:
        # https://urllib3.readthedocs.org
        # /en/latest/security.html#insecureplatformwarning
        requests.packages.urllib3.disable_warnings()

        cli(None)
    except Exception as e:  # pylint: disable=W0703
        if not isinstance(e, exception.ReturnErrorCode):
            maintenance.on_platformio_exception(e)
            error_str = "Error: "
            if isinstance(e, exception.PlatformioException):
                error_str += str(e)
            else:
                error_str += format_exc()
            click.secho(error_str, fg="red", err=True)
        sys_exit(1)
Ejemplo n.º 9
0
def main():
    try:
        # https://urllib3.readthedocs.org
        # /en/latest/security.html#insecureplatformwarning
        requests.packages.urllib3.disable_warnings()

        cli(None, None)
    except Exception as e:  # pylint: disable=W0703
        if not isinstance(e, exception.ReturnErrorCode):
            maintenance.on_platformio_exception(e)
            error_str = "Error: "
            if isinstance(e, exception.PlatformioException):
                error_str += str(e)
            else:
                error_str += format_exc()
            click.secho(error_str, fg="red", err=True)
        sys_exit(1)
Ejemplo n.º 10
0
def main(argv=None):
    exit_code = 0
    prev_sys_argv = sys.argv[:]
    if argv:
        assert isinstance(argv, list)
        sys.argv = argv
    try:
        configure()
        cli()  # pylint: disable=no-value-for-parameter
    except SystemExit as e:
        if e.code and str(e.code).isdigit():
            exit_code = int(e.code)
    except Exception as e:  # pylint: disable=broad-except
        if not isinstance(e, exception.ReturnErrorCode):
            maintenance.on_platformio_exception(e)
            error_str = "Error: "
            if isinstance(e, exception.PlatformioException):
                error_str += str(e)
            else:
                error_str += format_exc()
                error_str += """
============================================================

An unexpected error occurred. Further steps:

* Verify that you have the latest version of PlatformIO using
  `pip install -U platformio` command

* Try to find answer in FAQ Troubleshooting section
  https://docs.platformio.org/page/faq.html

* Report this problem to the developers
  https://github.com/platformio/platformio-core/issues

============================================================
"""
            click.secho(error_str, fg="red", err=True)
        exit_code = int(str(e)) if str(e).isdigit() else 1
    sys.argv = prev_sys_argv
    return exit_code
Ejemplo n.º 11
0
def main():
    try:
        if "cygwin" in system().lower():
            raise exception.CygwinEnvDetected()

        # https://urllib3.readthedocs.org
        # /en/latest/security.html#insecureplatformwarning
        try:
            requests.packages.urllib3.disable_warnings()
        except AttributeError:
            raise exception.PlatformioException(
                "Invalid installation of Python `requests` package`. See "
                "< https://github.com/platformio/platformio/issues/252 >"
            )

        cli(None, None, None)
    except Exception as e:  # pylint: disable=W0703
        if not isinstance(e, exception.ReturnErrorCode):
            maintenance.on_platformio_exception(e)
            error_str = "Error: "
            if isinstance(e, exception.PlatformioException):
                error_str += str(e)
            else:
                error_str += format_exc()
                error_str += """
============================================================

An unexpected error occurred. Further steps:

* Verify that you have the latest version of PlatformIO using
  `platformio upgrade` command
* Report this problem to the developers
  https://github.com/platformio/platformio/issues

============================================================
"""
            click.secho(error_str, fg="red", err=True)
        return 1
    return 0