Tracking: track software updates
This commit is contained in:
1 parent
6b54a15ed9
commit
7587f34c94
2 files changed
+26
No files matched your search
@@ -8,6 +8,7 @@ __copyright__ = "Copyright (C) 2014 The OctoPrint Project - Released under terms
|
||||
|
||||
import octoprint.plugin
|
||||
|
||||
import copy
|
||||
import flask
|
||||
import os
|
||||
import threading
|
||||
@@ -897,6 +898,20 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
||||
# determine the target version to update to
|
||||
target_version = information["remote"]["value"]
|
||||
target_error = False
|
||||
target_result = None
|
||||
|
||||
def trigger_event(success, **additional_payload):
|
||||
if success:
|
||||
event = "update_succeeded"
|
||||
else:
|
||||
event = "update_failed"
|
||||
|
||||
payload = copy.copy(additional_payload)
|
||||
payload.update(dict(target=target,
|
||||
from_version=information["local"]["value"],
|
||||
to_version=target_version))
|
||||
|
||||
self._event_bus.fire("plugin_softwareupdate_{}".format(event), payload=payload)
|
||||
|
||||
### The actual update procedure starts here...
|
||||
|
||||
@@ -911,6 +926,7 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
||||
update_result = updater.perform_update(target, populated_check, target_version, log_cb=self._log, online=online)
|
||||
target_result = ("success", update_result)
|
||||
self._logger.info("Update of %s to %s successful!" % (target, target_version))
|
||||
trigger_event(True)
|
||||
|
||||
except exceptions.UnknownUpdateType:
|
||||
self._logger.warn("Update of %s can not be performed, unknown update type" % target)
|
||||
@@ -923,6 +939,8 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
||||
|
||||
except Exception as e:
|
||||
self._logger.exception("Update of %s can not be performed, please also check plugin_softwareupdate_console.log for possible causes of this" % target)
|
||||
trigger_event(False)
|
||||
|
||||
if not "ignorable" in populated_check or not populated_check["ignorable"]:
|
||||
target_error = True
|
||||
|
||||
|
||||
@@ -83,6 +83,8 @@ class TrackingPlugin(octoprint.plugin.SettingsPlugin,
|
||||
def on_event(self, event, payload):
|
||||
if event.startswith("plugin_pluginmanager_"):
|
||||
self._track_plugin_event(event, payload)
|
||||
if event.startswith("plugin_softwareupdate_"):
|
||||
self._track_update_event(event, payload)
|
||||
elif event in (Events.PRINT_STARTED, Events.PRINT_DONE, Events.PRINT_FAILED, Events.PRINT_CANCELLED):
|
||||
self._track_printjob_event(event, payload)
|
||||
|
||||
@@ -149,6 +151,12 @@ class TrackingPlugin(octoprint.plugin.SettingsPlugin,
|
||||
elif event.endswith("_disableplugin"):
|
||||
self._track("disable_plugin", plugin=payload.get(b"id"), plugin_version=payload.get(b"version"))
|
||||
|
||||
def _track_update_event(self, event, payload):
|
||||
if event.endswith("_update_succeeded"):
|
||||
self._track("update_successful", target=payload.get("target"), from_version=payload.get("from_version"), to_version=payload.get("to_version"))
|
||||
elif event.endswith("_update_failed"):
|
||||
self._track("update_failed", target=payload.get("target"), from_version=payload.get("from_version"), to_version=payload.get("to_version"))
|
||||
|
||||
def _track_printjob_event(self, event, payload):
|
||||
sha = hashlib.sha1()
|
||||
sha.update(payload.get("name"))
|
||||
|
||||
Reference in new issue
Block a user