PR feedback: throttle state and uuid

- add a way to get the raw value only from throttle state (glad I already plumbed it into the object!)
- add warning about not sending uuid, modify the log entry too
This commit is contained in:
tedder committed 2018-11-08 01:29:15 +00:00
1 parent c1482eaacd
commit 76f48b3b13
2 files changed
+11 -4

No files matched your search

+6 -2
View File
@@ -244,8 +244,12 @@ class PiSupportPlugin(octoprint.plugin.EnvironmentDetectionPlugin,
def _check_throttled_state_condition(self):
return self._throttle_functional
def get_throttle_state(self, run_now=False):
'''public method to pass around in plugin_helpers'''
def get_throttle_state(self, raw_value_only=False, run_now=False):
'''public method to pass around in plugin_helpers.'''
# Not using the `run_now` yet, but leaving it as a placeholder.
if raw_value_only: return self._throttle_state._raw_value
return self._throttle_state.as_dict()
def _check_throttled_state(self):
+5 -2
View File
@@ -169,7 +169,7 @@ class TrackingPlugin(octoprint.plugin.SettingsPlugin,
ram=self._environment[b"hardware"][b"ram"])
if self._helpers_get_throttle_state:
payload[b"throttle_state"] = self._helpers_get_throttle_state()
payload[b"throttle_state"] = self._helpers_get_throttle_state(raw_value_only=True)
if b"plugins" in self._environment and b"pi_support" in self._environment[b"plugins"]:
payload[b"pi_model"] = self._environment[b"plugins"][b"pi_support"][b"model"]
@@ -263,15 +263,18 @@ class TrackingPlugin(octoprint.plugin.SettingsPlugin,
server = self._settings.get([b"server"])
url = server.format(id=self._settings.get([b"unique_id"]), event=event)
# don't print the URL or uuid! That would expose the uuid in forums if pasted.
# (it's okay for the user to know their uuid, but it shouldn't be shared)
headers = {"User-Agent": "OctoPrint/{}".format(get_octoprint_version_string())}
try:
params = urlencode(kwargs, doseq=True).replace("+", "%20")
requests.get(url,
params=params,
timeout=3.1,
headers=headers)
self._logger.info("Sent tracking event to {}, params: {}".format(url, kwargs))
self._logger.info("Sent tracking event to /{}, params: {}".format(event, kwargs))
except:
if self._logger.isEnabledFor(logging.DEBUG):
self._logger.exception("Error while sending event to anonymous usage tracking".format(url))