示例#1
0
文件: cli.py 项目: zeus911/OctoPrint
    def check_command(force, targets):
        """
		Check for updates.

		If any TARGETs are provided, only those components will be checked.

		\b
		Examples:
		- octoprint plugins softwareupdate:check
		    This will check all components for available updates,
		    utilizing cached version information.
		- octoprint plugins softwareupdate:check --force
		    This will check all components for available updates,
		    ignoring any cached version information even if it's
		    still valid.
		- octoprint plugins softwareupdate:check octoprint
		    This will only check OctoPrint itself for available
		    updates.
		"""
        params = dict(force=force)
        if targets:
            params["check"] = ",".join(targets)

        client.init_client(cli_group.settings)
        r = client.get("plugin/softwareupdate/check", params=params)
        try:
            r.raise_for_status()
        except requests.exceptions.HTTPError as e:
            click.echo(
                "Could not get update information from server, got {}".format(
                    e))
            sys.exit(1)

        data = r.json()
        status = data["status"]
        information = data["information"]

        lines = []
        octoprint_line = None
        for key, info in information.items():
            status_text = "Up to date"
            if info["updateAvailable"]:
                if info["updatePossible"]:
                    status_text = "Update available"
                else:
                    status_text = "Update available (manual)"
            line = "{}\n\tInstalled: {}\n\tAvailable: {}\n\t=> {}".format(
                info["displayName"], info["information"]["local"]["name"],
                info["information"]["remote"]["name"], status_text)
            if key == "octoprint":
                octoprint_line = line
            else:
                lines.append(line)

        lines.sort()
        if octoprint_line:
            lines = [octoprint_line] + lines

        for line in lines:
            click.echo(line)

        click.echo()
        if status == "current":
            click.echo("Everything is up to date")
        else:
            click.echo("There are updates available!")
示例#2
0
def get(path):
    """Performs a GET request against the specified server path."""
    r = octoprint_client.get(path)
    log_response(r)
示例#3
0
文件: cli.py 项目: BigRep/OctoPrint
	def check_command(force, targets):
		"""
		Check for updates.

		If any TARGETs are provided, only those components will be checked.

		\b
		Examples:
		- octoprint plugins softwareupdate:check
		    This will check all components for available updates,
		    utilizing cached version information.
		- octoprint plugins softwareupdate:check --force
		    This will check all components for available updates,
		    ignoring any cached version information even if it's
		    still valid.
		- octoprint plugins softwareupdate:check octoprint
		    This will only check OctoPrint itself for available
		    updates.
		"""
		params = dict(force=force)
		if targets:
			params["check"] = ",".join(targets)

		client.init_client(cli_group.settings)
		r = client.get("plugin/softwareupdate/check", params=params)
		try:
			r.raise_for_status()
		except requests.exceptions.HTTPError as e:
			click.echo("Could not get update information from server, got {}".format(e))
			sys.exit(1)

		data = r.json()
		status = data["status"]
		information = data["information"]

		lines = []
		octoprint_line = None
		for key, info in information.items():
			status_text = "Up to date"
			if info["updateAvailable"]:
				if info["updatePossible"]:
					status_text = "Update available"
				else:
					status_text = "Update available (manual)"
			line = "{}\n\tInstalled: {}\n\tAvailable: {}\n\t=> {}".format(info["displayName"],
			                                                              info["information"]["local"]["name"],
			                                                              info["information"]["remote"]["name"],
			                                                              status_text)
			if key == "octoprint":
				octoprint_line = line
			else:
				lines.append(line)

		lines.sort()
		if octoprint_line:
			lines = [octoprint_line] + lines

		for line in lines:
			click.echo(line)

		click.echo()
		if status == "current":
			click.echo("Everything is up to date")
		else:
			click.echo("There are updates available!")
示例#4
0
def get(path):
	"""Performs a GET request against the specified server path."""
	r = octoprint_client.get(path)
	log_response(r)