fix for python2.7
This commit is contained in:
parent
6629dc0bd4
commit
51ca8dc259
|
@ -32,6 +32,9 @@ try:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
import ConfigParser as configparser
|
import ConfigParser as configparser
|
||||||
|
|
||||||
|
if sys.version_info[0] < 3:
|
||||||
|
import StringIO
|
||||||
|
|
||||||
class KlipperPlugin(
|
class KlipperPlugin(
|
||||||
octoprint.plugin.StartupPlugin,
|
octoprint.plugin.StartupPlugin,
|
||||||
octoprint.plugin.TemplatePlugin,
|
octoprint.plugin.TemplatePlugin,
|
||||||
|
@ -428,9 +431,12 @@ class KlipperPlugin(
|
||||||
configpath)
|
configpath)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
|
||||||
self._settings.set(["config"], data["config"])
|
self._settings.set(["config"], data["config"])
|
||||||
# self.send_message("reload", "config", "", data["config"])
|
# self.send_message("reload", "config", "", data["config"])
|
||||||
# send the configdata to frontend to update ace editor
|
# send the configdata to frontend to update ace editor
|
||||||
|
if sys.version_info[0] < 3:
|
||||||
|
data["config"] = data["config"].decode('utf-8')
|
||||||
return flask.jsonify(data=data["config"])
|
return flask.jsonify(data=data["config"])
|
||||||
elif command == "checkConfig":
|
elif command == "checkConfig":
|
||||||
if "config" in data:
|
if "config" in data:
|
||||||
|
@ -539,12 +545,23 @@ class KlipperPlugin(
|
||||||
|
|
||||||
try:
|
try:
|
||||||
dataToValidated = configparser.RawConfigParser()
|
dataToValidated = configparser.RawConfigParser()
|
||||||
|
#
|
||||||
|
if sys.version_info[0] < 3:
|
||||||
|
buf = StringIO.StringIO(dataToBeValidated)
|
||||||
|
dataToValidated.readfp(buf)
|
||||||
|
else:
|
||||||
dataToValidated.read_string(dataToBeValidated)
|
dataToValidated.read_string(dataToBeValidated)
|
||||||
except configparser.Error as error:
|
except configparser.Error as error:
|
||||||
|
if sys.version_info[0] < 3:
|
||||||
|
error.message = error.message.replace("\\n","")
|
||||||
|
error.message = error.message.replace("file: u","Klipper Configuration", 1)
|
||||||
|
error.message = error.message.replace("'","", 2)
|
||||||
|
error.message = error.message.replace("u'","'", 1)
|
||||||
|
|
||||||
|
else:
|
||||||
error.message = error.message.replace("\\n","")
|
error.message = error.message.replace("\\n","")
|
||||||
error.message = error.message.replace("file:","Klipper Configuration", 1)
|
error.message = error.message.replace("file:","Klipper Configuration", 1)
|
||||||
error.message = error.message.replace("'","", 2)
|
error.message = error.message.replace("'","", 2)
|
||||||
error.source = "Klipper config"
|
|
||||||
self.log_error(
|
self.log_error(
|
||||||
"Error: Invalid Klipper config file:\n" +
|
"Error: Invalid Klipper config file:\n" +
|
||||||
"{}".format(str(error))
|
"{}".format(str(error))
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -19,7 +19,7 @@ plugin_package = "octoprint_klipper"
|
||||||
|
|
||||||
plugin_name = "OctoKlipper"
|
plugin_name = "OctoKlipper"
|
||||||
|
|
||||||
plugin_version = "0.3.6"
|
plugin_version = "0.3.6a"
|
||||||
|
|
||||||
plugin_description = """A plugin for OctoPrint to configure,control and monitor the Klipper 3D printer software."""
|
plugin_description = """A plugin for OctoPrint to configure,control and monitor the Klipper 3D printer software."""
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue