Improved error resilience in plugin repository handling
This commit is contained in:
parent
a646fff5ff
commit
507ddde9dd
1 changed files with 18 additions and 14 deletions
|
|
@ -34,6 +34,10 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
|||
|
||||
ARCHIVE_EXTENSIONS = (".zip", ".tar.gz", ".tgz", ".tar")
|
||||
|
||||
OPERATING_SYSTEMS = dict(windows=["win32"],
|
||||
linux=["linux2"],
|
||||
macos=["darwin"])
|
||||
|
||||
pip_inapplicable_arguments = dict(uninstall=["--user"])
|
||||
|
||||
def __init__(self):
|
||||
|
|
@ -609,10 +613,10 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
|||
)
|
||||
|
||||
if "compatibility" in entry:
|
||||
if "octoprint" in entry["compatibility"] and entry["compatibility"]["octoprint"] is not None and len(entry["compatibility"]["octoprint"]):
|
||||
if "octoprint" in entry["compatibility"] and entry["compatibility"]["octoprint"] is not None and isinstance(entry["compatibility"]["octoprint"], (list, tuple)) and len(entry["compatibility"]["octoprint"]):
|
||||
result["is_compatible"]["octoprint"] = self._is_octoprint_compatible(octoprint_version, entry["compatibility"]["octoprint"])
|
||||
|
||||
if "os" in entry["compatibility"] and entry["compatibility"]["os"] is not None and len(entry["compatibility"]["os"]):
|
||||
if "os" in entry["compatibility"] and entry["compatibility"]["os"] is not None and isinstance(entry["compatibility"]["os"], (list, tuple)) and len(entry["compatibility"]["os"]):
|
||||
result["is_compatible"]["os"] = self._is_os_compatible(current_os, entry["compatibility"]["os"])
|
||||
|
||||
return result
|
||||
|
|
@ -626,12 +630,15 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
|||
"""
|
||||
|
||||
for octo_compat in compatibility_entries:
|
||||
if not any(octo_compat.startswith(c) for c in ("<", "<=", "!=", "==", ">=", ">", "~=", "===")):
|
||||
octo_compat = ">={}".format(octo_compat)
|
||||
try:
|
||||
if not any(octo_compat.startswith(c) for c in ("<", "<=", "!=", "==", ">=", ">", "~=", "===")):
|
||||
octo_compat = ">={}".format(octo_compat)
|
||||
|
||||
s = next(pkg_resources.parse_requirements("OctoPrint" + octo_compat))
|
||||
if octoprint_version in s:
|
||||
break
|
||||
s = next(pkg_resources.parse_requirements("OctoPrint" + octo_compat))
|
||||
if octoprint_version in s:
|
||||
break
|
||||
except:
|
||||
self._logger.exception("Something is wrong with this compatibility string for OctoPrint: {}".format(octo_compat))
|
||||
else:
|
||||
return False
|
||||
|
||||
|
|
@ -641,15 +648,12 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
|||
"""
|
||||
Tests if the ``current_os`` matches any of the provided ``compatibility_entries``.
|
||||
"""
|
||||
return current_os in compatibility_entries
|
||||
return current_os in filter(lambda x: x in self.__class__.OPERATING_SYSTEMS.keys(), compatibility_entries)
|
||||
|
||||
def _get_os(self):
|
||||
if sys.platform == "win32":
|
||||
return "windows"
|
||||
elif sys.platform == "linux2":
|
||||
return "linux"
|
||||
elif sys.platform == "darwin":
|
||||
return "macos"
|
||||
for identifier, platforms in self.__class__.OPERATING_SYSTEMS.items():
|
||||
if sys.platform in platforms:
|
||||
return identifier
|
||||
else:
|
||||
return "unknown"
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue