diff --git a/src/octoprint/plugins/pluginmanager/__init__.py b/src/octoprint/plugins/pluginmanager/__init__.py index 0da508497..da2cb05b0 100644 --- a/src/octoprint/plugins/pluginmanager/__init__.py +++ b/src/octoprint/plugins/pluginmanager/__init__.py @@ -47,6 +47,8 @@ from octoprint.util.version import ( is_python_compatible, ) +from . import exceptions + try: from os import scandir except ImportError: @@ -649,21 +651,32 @@ class PluginManagerPlugin( ) else: - self._logger.error( - "{} is neither an archive nor a python file, can't install that.".format( - source - ) + raise exceptions.InvalidPackageFormat() + except requests.exceptions.HTTPError as e: + self._logger.error("Could not fetch plugin from server, got {}".format(e)) + result = { + "result": False, + "source": source, + "source_type": source_type, + "reason": "Could not fetch plugin from server, got {}".format(e), + } + self._send_result_notification("install", result) + return result + except exceptions.InvalidPackageFormat: + self._logger.error( + "{} is neither an archive nor a python file, can't install that.".format( + source ) - result = { - "result": False, - "source": source, - "source_type": source_type, - "reason": "Could not install plugin from {}, was neither " - "a plugin archive nor a single file plugin".format(source), - } - self._send_result_notification("install", result) - return result - + ) + result = { + "result": False, + "source": source, + "source_type": source_type, + "reason": "Could not install plugin from {}, was neither " + "a plugin archive nor a single file plugin".format(source), + } + self._send_result_notification("install", result) + return result finally: if folder is not None: folder.cleanup() diff --git a/src/octoprint/plugins/pluginmanager/exceptions.py b/src/octoprint/plugins/pluginmanager/exceptions.py new file mode 100644 index 000000000..0b4256018 --- /dev/null +++ b/src/octoprint/plugins/pluginmanager/exceptions.py @@ -0,0 +1,9 @@ +# -*- coding: utf-8 -*- +from __future__ import absolute_import, division, print_function, unicode_literals + +__license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html" +__copyright__ = "Copyright (C) 2020 The OctoPrint Project - Released under terms of the AGPLv3 License" + + +class InvalidPackageFormat(Exception): + pass