diff --git a/octoprint_gcodesystemcommands/__init__.py b/octoprint_gcodesystemcommands/__init__.py index 07766fe..228b4e9 100644 --- a/octoprint_gcodesystemcommands/__init__.py +++ b/octoprint_gcodesystemcommands/__init__.py @@ -5,6 +5,8 @@ __license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html" __copyright__ = "Copyright (C) 2017 Shawn Bruce - Released under terms of the AGPLv3 License" +import six + import octoprint.plugin import time import os @@ -76,6 +78,9 @@ def hook_gcode_sending(self, comm_instance, phase, cmd, cmd_type, gcode, *args, self._logger.exception("Error executing command ID %s: %s" % (cmd_id, e)) return (None,) + # Make sure we don't throw when logging output if it contains non-ascii characters + output = six.ensure_text(output, "utf-8", "ignore") + self._logger.debug("Command ID %s returned: %s, output=%s" % (cmd_id, r, output)) self._logger.info("Command ID %s returned: %s" % (cmd_id, r)) @@ -106,7 +111,7 @@ def on_settings_load(self): data[r] = None return data - + def on_settings_save(self, data): octoprint.plugin.SettingsPlugin.on_settings_save(self, data) self.reload_command_definitions() @@ -119,7 +124,7 @@ def get_template_configs(self): def get_assets(self): return { "js": ["js/gcodesystemcommands.js"] - } + } def get_update_information(self): return dict( diff --git a/requirements.txt b/requirements.txt index 9267262..a3e266b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,3 @@ OctoPrint +# six is already required by OctoPrint, but still add it here just in case +six