Merge pull request #3889 from kantlivelong/fix_3886

Handle http errors when downloading plugin files.
This commit is contained in:
Gina Häußge authored and GitHub committed 2021-01-11 09:24:52 +01:00
commit fd891e39ff
2 files changed
+36 -14

No files matched your search

+27 -14
View File
@@ -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()
@@ -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