From 6294580e25f851e49f2ba5988ca26c2c2c8283d3 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 12 Oct 2018 22:30:28 +0300 Subject: [PATCH] Show a valid error when Internet is off-line while initializing a new project // Resolve #1784 --- HISTORY.rst | 2 ++ platformio/exception.py | 2 +- platformio/managers/package.py | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/HISTORY.rst b/HISTORY.rst index 488f786c..37e9edd5 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -19,6 +19,8 @@ PlatformIO 3.0 from a project * Report about outdated `99-platformio-udev.rules `__ (`issue #1823 `_) +* Show a valid error when Internet is off-line while initializing a new project + (`issue #1784 `_) * Fixed an issue when dynamic build flags were not handled correctly (`issue #1799 `_) * Fixed an issue when ``pio run -t monitor`` always uses first ``monitor_port`` diff --git a/platformio/exception.py b/platformio/exception.py index 7ec116fa..48f831c9 100644 --- a/platformio/exception.py +++ b/platformio/exception.py @@ -178,7 +178,7 @@ class InternetIsOffline(PlatformioException): MESSAGE = ( "You are not connected to the Internet.\n" "If you build a project first time, we need Internet connection " - "to install all dependencies and toolchain.") + "to install all dependencies and toolchains.") class LibNotFound(PlatformioException): diff --git a/platformio/managers/package.py b/platformio/managers/package.py index a5cf0647..b8db1f77 100644 --- a/platformio/managers/package.py +++ b/platformio/managers/package.py @@ -414,6 +414,7 @@ class PkgInstallerMixin(object): click.secho("Looking for another mirror...", fg="yellow") if versions is None: + util.internet_on(raise_exception=True) raise exception.UnknownPackage(name) elif not pkgdata: raise exception.UndefinedPackageVersion(requirements or "latest",