Ignore update definitions that are lacking the type

Caused a KeyError so far, update definitions that are broken like that
will now just be ignored instead.

Closes #1057
This commit is contained in:
Gina Häußge 2015-09-11 08:14:35 +02:00
parent f0ab517857
commit 2efc5c4fdb

View file

@ -416,14 +416,13 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
if not target in check_targets: if not target in check_targets:
continue continue
populated_check = self._populated_check(target, check)
try: try:
populated_check = self._populated_check(target, check)
target_information, target_update_available, target_update_possible = self._get_current_version(target, populated_check, force=force) target_information, target_update_available, target_update_possible = self._get_current_version(target, populated_check, force=force)
if target_information is None: if target_information is None:
target_information = dict() target_information = dict()
except exceptions.UnknownCheckType: except exceptions.UnknownCheckType:
self._logger.warn("Unknown update check type for %s" % target) self._logger.warn("Unknown update check type for target {}".format(target))
continue continue
target_information = dict_merge(dict(local=dict(name="unknown", value="unknown"), remote=dict(name="unknown", value="unknown")), target_information) target_information = dict_merge(dict(local=dict(name="unknown", value="unknown"), remote=dict(name="unknown", value="unknown")), target_information)
@ -669,6 +668,9 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
raise exceptions.RestartFailed() raise exceptions.RestartFailed()
def _populated_check(self, target, check): def _populated_check(self, target, check):
if not "type" in check:
raise exceptions.UnknownCheckType()
result = dict(check) result = dict(check)
if target == "octoprint": if target == "octoprint":
@ -703,30 +705,6 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
def _send_client_message(self, message_type, data=None): def _send_client_message(self, message_type, data=None):
self._plugin_manager.send_plugin_message(self._identifier, dict(type=message_type, data=data)) self._plugin_manager.send_plugin_message(self._identifier, dict(type=message_type, data=data))
def _populated_check(self, target, check):
result = dict(check)
if target == "octoprint":
from flask.ext.babel import gettext
result["displayName"] = check.get("displayName", gettext("OctoPrint"))
result["displayVersion"] = check.get("displayVersion", "{octoprint_version}")
from octoprint._version import get_versions
versions = get_versions()
if check["type"] == "github_commit":
result["current"] = versions.get("full-revisionid", versions.get("full", "unknown"))
else:
result["current"] = versions["version"]
else:
result["displayName"] = check.get("displayName", target)
result["displayVersion"] = check.get("displayVersion", check.get("current", "unknown"))
if check["type"] in ("github_commit"):
result["current"] = check.get("current", None)
else:
result["current"] = check.get("current", check.get("displayVersion", None))
return result
def _get_version_checker(self, target, check): def _get_version_checker(self, target, check):
""" """
Retrieves the version checker to use for given target and check configuration. Will raise an UnknownCheckType Retrieves the version checker to use for given target and check configuration. Will raise an UnknownCheckType