mmone / OctoprintKlipperPlugin

A plugin for a better integration of Klipper into OctoPrint.
GNU General Public License v3.0
83 stars 62 forks source link

Support unicode characters in printer.cfg #23

Open pinggi opened 6 years ago

pinggi commented 6 years ago

OctoKlipper can't save printer.cfg containing unicode characters and effectively wipes out printer.cfg file after its saving.

environment:

2018-09-15 21:18:09,696 - octoprint.server.api.settings - ERROR - Could not save settings for plugin OctoKlipper (0.2.5) Traceback (most recent call last): File "/home/pi/OctoPrint/venv/local/lib/python2.7/site-packages/octoprint/server/api/settings.py", line 535, in _saveSettings plugin.on_settings_save(data["plugins"][plugin_id]) File "/home/pi/OctoPrint/venv/local/lib/python2.7/site-packages/octoprint_klipper/__init__.py", line 96, in on_settings_save f.write(data["config"]) UnicodeEncodeError: 'ascii' codec can't encode character u'\xb0' in position 410: ordinal not in range(128)

jameseleach commented 5 years ago

I've got a fix for this on my branch. Hopefully @mmone can see what I've done and integrate the changes!

Elocai commented 5 years ago

@jameseleach could you "release" your version pls?

jameseleach commented 5 years ago

@Elocai I can’t update the official KlipperPlugin as @mmone is the only one that can do that. You can, however, uninstall your currently installed version and install my branch. It’s pretty straight forward and instructions are here: https://github.com/jameseleach/OctoprintKlipperPlugin#fork-installation-information

Basically, it’s just a matter of using PluginManager’s “From URL” option and entering this URL: https://github.com/jameseleach/OctoprintKlipperPlugin/archive/JEL-0.1.zip

jass-on commented 5 years ago

@jameseleach My printer.cfg file still gets erased using your branch.

jameseleach commented 5 years ago

@jameseleach My printer.cfg file still gets erased using your branch.

Can you attach your printer.cfg? I'd like to see what encoding is used. If it's unicode it should be converting it to utf-8 but that might not be happening.