1 parent
8668e5d66b
commit
87102407c7
3 files changed
+20
-14
No files matched your search
@@ -710,12 +710,15 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
||||
@no_firstrun_access
|
||||
@Permissions.PLUGIN_SOFTWAREUPDATE_CHECK.require(403)
|
||||
def check_for_update(self):
|
||||
if "check" in flask.request.values:
|
||||
check_targets = list(map(lambda x: x.strip(), flask.request.values["check"].split(",")))
|
||||
request_data = flask.request.values
|
||||
|
||||
if "targets" in request_data or "check" in request_data:
|
||||
check_targets = list(map(lambda x: x.strip(),
|
||||
request_data.get("targets", request_data.get("check", "")).split(",")))
|
||||
else:
|
||||
check_targets = None
|
||||
|
||||
force = flask.request.values.get("force", "false") in octoprint.settings.valid_boolean_trues
|
||||
force = request_data.get("force", "false") in octoprint.settings.valid_boolean_trues
|
||||
|
||||
def view():
|
||||
self._environment_ready.wait(timeout=30.0)
|
||||
@@ -759,7 +762,7 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
||||
storage=dict(sufficient=self._storage_sufficient,
|
||||
free=storage)))
|
||||
except exceptions.ConfigurationInvalid as e:
|
||||
return flask.make_response("Update not properly configured, can't proceed: %s" % e.message, 500)
|
||||
return flask.make_response("Update not properly configured, can't proceed: {}".format(e), 500)
|
||||
|
||||
def etag():
|
||||
checks = self._get_configured_checks()
|
||||
@@ -830,15 +833,12 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
||||
if json_data is None:
|
||||
return flask.make_response("Invalid JSON", 400)
|
||||
|
||||
if "targets" in json_data:
|
||||
targets = list(map(lambda x: x.strip(), json_data["targets"]))
|
||||
if "targets" in json_data or "checks" in json_data:
|
||||
targets = list(map(lambda x: x.strip(), json_data.get("targets", json_data.get("check", []))))
|
||||
else:
|
||||
targets = None
|
||||
|
||||
if "force" in json_data and json_data["force"] in octoprint.settings.valid_boolean_trues:
|
||||
force = True
|
||||
else:
|
||||
force = False
|
||||
force = json_data.get("force", "false") in octoprint.settings.valid_boolean_trues
|
||||
|
||||
to_be_checked, checks = self.perform_updates(targets=targets, force=force)
|
||||
return flask.jsonify(dict(order=to_be_checked, checks=checks))
|
||||
|
||||
@@ -35,10 +35,13 @@ def commands(cli_group, pass_octoprint_ctx, *args, **kwargs):
|
||||
- octoprint plugins softwareupdate:check octoprint
|
||||
This will only check OctoPrint itself for available
|
||||
updates.
|
||||
|
||||
Note that the OctoPrint server needs to be running for this
|
||||
command to work as it utilizes the server API.
|
||||
"""
|
||||
params = dict(force=force)
|
||||
if targets:
|
||||
params["check"] = ",".join(targets)
|
||||
params["targets"] = ",".join(targets)
|
||||
|
||||
client = create_client(settings=cli_group.settings,
|
||||
apikey=apikey,
|
||||
@@ -119,11 +122,14 @@ def commands(cli_group, pass_octoprint_ctx, *args, **kwargs):
|
||||
- octoprint plugins softwareupdate:update octoprint
|
||||
This will only update OctoPrint and leave any further
|
||||
components with pending updates at their current versions.
|
||||
|
||||
Note that the OctoPrint server needs to be running for this
|
||||
command to work as it utilizes the server API.
|
||||
"""
|
||||
|
||||
data = dict(force=force)
|
||||
if targets:
|
||||
data["check"] = targets
|
||||
data["targets"] = targets
|
||||
|
||||
client = create_client(settings=cli_group.settings,
|
||||
apikey=apikey,
|
||||
@@ -176,7 +182,7 @@ def commands(cli_group, pass_octoprint_ctx, *args, **kwargs):
|
||||
flags["waiting_for_restart"] = True
|
||||
click.echo("Restarting to apply changes...")
|
||||
|
||||
elif plugin_message_type == "failure":
|
||||
elif plugin_message_type == "error":
|
||||
click.echo("Error")
|
||||
ws.close()
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
data.force = true;
|
||||
}
|
||||
if (entries && entries.length) {
|
||||
data.check = entries.join(",");
|
||||
data.targets = entries.join(",");
|
||||
}
|
||||
return this.base.getWithQuery(this.checkUrl, data, opts);
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user