Пример #1
0
	def _populated_check(self, target, check):
		if not "type" in check:
			raise exceptions.UnknownCheckType()

		result = dict(check)

		if target == "octoprint":
			from flask_babel import gettext

			from octoprint.util.version import is_released_octoprint_version, is_stable_octoprint_version

			result["displayName"] = to_unicode(check.get("displayName"), errors="replace")
			if result["displayName"] is None:
				# displayName missing or set to None
				result["displayName"] = to_unicode(gettext("OctoPrint"), errors="replace")

			result["displayVersion"] = to_unicode(check.get("displayVersion"), errors="replace")
			if result["displayVersion"] is None:
				# displayVersion missing or set to None
				result["displayVersion"] = u"{octoprint_version}"

			stable_branch = "master"
			release_branches = []
			if "stable_branch" in check:
				release_branches.append(check["stable_branch"]["branch"])
				stable_branch = check["stable_branch"]["branch"]
			if "prerelease_branches" in check:
				release_branches += [x["branch"] for x in check["prerelease_branches"]]
			result["released_version"] = is_released_octoprint_version()

			if check["type"] in self.COMMIT_TRACKING_TYPES:
				result["current"] = REVISION if REVISION else "unknown"
			else:
				result["current"] = VERSION

				if check["type"] == "github_release" and (check.get("prerelease", None) or not is_stable_octoprint_version()):
					# we are tracking github releases and are either also tracking prerelease OR are currently running
					# a non stable version => we need to change some parameters

					# we compare versions fully, not just the base so that we see a difference
					# between RCs + stable for the same version release
					result["force_base"] = False

					if check.get("prerelease", None):
						# we are tracking prereleases => we want to be on the correct prerelease channel/branch
						channel = check.get("prerelease_channel", None)
						if channel:
							# if we have a release channel, we also set our update_branch here to our release channel
							# in case it's not already set
							result["update_branch"] = check.get("update_branch", channel)

					else:
						# we are not tracking prereleases, but aren't on the stable branch either => switch back
						# to stable branch on update
						result["update_branch"] = check.get("update_branch", stable_branch)

					if check.get("update_script", None):
						# we force an exact version & python unequality check, to be able to downgrade
						result["force_exact_version"] = True
						result["release_compare"] = "python_unequal"

					elif check.get("pip", None):
						# we force python unequality check for pip installs, to be able to downgrade
						result["release_compare"] = "python_unequal"

		else:
			result["displayName"] = to_unicode(check.get("displayName"), errors="replace")
			if result["displayName"] is None:
				# displayName missing or None
				result["displayName"] = to_unicode(target, errors="replace")

			result["displayVersion"] = to_unicode(check.get("displayVersion", check.get("current")), errors="replace")
			if result["displayVersion"] is None:
				# displayVersion AND current missing or None
				result["displayVersion"] = u"unknown"

			if check["type"] in self.COMMIT_TRACKING_TYPES:
				result["current"] = check.get("current", None)
			else:
				result["current"] = check.get("current", check.get("displayVersion", None))

		if "pip" in result:
			if not "pip_command" in check and self._settings.get(["pip_command"]) is not None:
				result["pip_command"] = self._settings.get(["pip_command"])

		return result
Пример #2
0
def _is_enabled(enabled, enabled_unreleased):
	return enabled and (enabled_unreleased or is_released_octoprint_version())
Пример #3
0
def _is_enabled(enabled, enabled_unreleased):
    return enabled and (enabled_unreleased or is_released_octoprint_version())
Пример #4
0
	def _populated_check(self, target, check):
		if not "type" in check:
			raise exceptions.UnknownCheckType()

		result = dict(check)

		if target == "octoprint":
			from flask.ext.babel import gettext

			from octoprint.util.version import is_released_octoprint_version, is_stable_octoprint_version

			result["displayName"] = to_unicode(check.get("displayName"), errors="replace")
			if result["displayName"] is None:
				# displayName missing or set to None
				result["displayName"] = to_unicode(gettext("OctoPrint"), errors="replace")

			result["displayVersion"] = to_unicode(check.get("displayVersion"), errors="replace")
			if result["displayVersion"] is None:
				# displayVersion missing or set to None
				result["displayVersion"] = u"{octoprint_version}"

			stable_branch = "master"
			release_branches = []
			if "stable_branch" in check:
				release_branches.append(check["stable_branch"]["branch"])
				stable_branch = check["stable_branch"]["branch"]
			if "prerelease_branches" in check:
				release_branches += [x["branch"] for x in check["prerelease_branches"]]
			result["released_version"] = is_released_octoprint_version()

			if check["type"] in self.COMMIT_TRACKING_TYPES:
				result["current"] = REVISION if REVISION else "unknown"
			else:
				result["current"] = VERSION

				if check["type"] == "github_release" and (check.get("prerelease", None) or not is_stable_octoprint_version()):
					# we are tracking github releases and are either also tracking prerelease OR are currently running
					# a non stable version => we need to change some parameters

					# we compare versions fully, not just the base so that we see a difference
					# between RCs + stable for the same version release
					result["force_base"] = False

					if check.get("prerelease", None):
						# we are tracking prereleases => we want to be on the correct prerelease channel/branch
						channel = check.get("prerelease_channel", None)
						if channel:
							# if we have a release channel, we also set our update_branch here to our release channel
							# in case it's not already set
							result["update_branch"] = check.get("update_branch", channel)

					else:
						# we are not tracking prereleases, but aren't on the stable branch either => switch back
						# to stable branch on update
						result["update_branch"] = check.get("update_branch", stable_branch)

					if check.get("update_script", None):
						# we force an exact version & python unequality check, to be able to downgrade
						result["force_exact_version"] = True
						result["release_compare"] = "python_unequal"

					elif check.get("pip", None):
						# we force python unequality check for pip installs, to be able to downgrade
						result["release_compare"] = "python_unequal"

		else:
			result["displayName"] = to_unicode(check.get("displayName"), errors="replace")
			if result["displayName"] is None:
				# displayName missing or None
				result["displayName"] = to_unicode(target, errors="replace")

			result["displayVersion"] = to_unicode(check.get("displayVersion", check.get("current")), errors="replace")
			if result["displayVersion"] is None:
				# displayVersion AND current missing or None
				result["displayVersion"] = u"unknown"

			if check["type"] in self.COMMIT_TRACKING_TYPES:
				result["current"] = check.get("current", None)
			else:
				result["current"] = check.get("current", check.get("displayVersion", None))

		if "pip" in result:
			if not "pip_command" in check and self._settings.get(["pip_command"]) is not None:
				result["pip_command"] = self._settings.get(["pip_command"])

		return result