parent
ad2bdb1242
commit
aed9e905f2
2 changed files with 10 additions and 0 deletions
|
|
@ -65,6 +65,7 @@ class CuraPlugin(octoprint.plugin.SlicerPlugin,
|
|||
try:
|
||||
profile_dict = Profile.from_cura_ini(flask.request.values[input_upload_path])
|
||||
except Exception as e:
|
||||
self._logger.exception("Error while converting the imported profile")
|
||||
return flask.make_response("Something went wrong while converting imported profile: {message}".format(str(e)), 500)
|
||||
|
||||
elif input_name in flask.request.files:
|
||||
|
|
@ -75,6 +76,7 @@ class CuraPlugin(octoprint.plugin.SlicerPlugin,
|
|||
upload.save(temp_file.name)
|
||||
profile_dict = Profile.from_cura_ini(temp_file.name)
|
||||
except Exception as e:
|
||||
self._logger.exception("Error while converting the imported profile")
|
||||
return flask.make_response("Something went wrong while converting imported profile: {message}".format(str(e)), 500)
|
||||
finally:
|
||||
os.remove(temp_file)
|
||||
|
|
@ -82,9 +84,11 @@ class CuraPlugin(octoprint.plugin.SlicerPlugin,
|
|||
filename = upload.filename
|
||||
|
||||
else:
|
||||
self._logger.warn("No profile file included for importing, aborting")
|
||||
return flask.make_response("No file included", 400)
|
||||
|
||||
if profile_dict is None:
|
||||
self._logger.warn("Could not convert profile, aborting")
|
||||
return flask.make_response("Could not convert Cura profile", 400)
|
||||
|
||||
name, _ = os.path.splitext(filename)
|
||||
|
|
@ -114,6 +118,7 @@ class CuraPlugin(octoprint.plugin.SlicerPlugin,
|
|||
display_name=profile_display_name,
|
||||
description=profile_description)
|
||||
except octoprint.slicing.ProfileAlreadyExists:
|
||||
self._logger.warn("Profile {profile_name} already exists, aborting".format(**locals()))
|
||||
return flask.make_response("A profile named {profile_name} already exists for slicer cura".format(**locals()), 409)
|
||||
|
||||
result = dict(
|
||||
|
|
|
|||
|
|
@ -346,8 +346,12 @@ class Profile(object):
|
|||
|
||||
@classmethod
|
||||
def from_cura_ini(cls, path):
|
||||
import logging
|
||||
logger = logging.getLogger("octoprint.plugin.cura.profile")
|
||||
|
||||
import os
|
||||
if not os.path.exists(path) or not os.path.isfile(path):
|
||||
logger.warn("Path {path} does not exist or is not a file, cannot import".format(**locals()))
|
||||
return None
|
||||
|
||||
import ConfigParser
|
||||
|
|
@ -355,6 +359,7 @@ class Profile(object):
|
|||
try:
|
||||
config.read(path)
|
||||
except:
|
||||
logger.exception("Error while reading profile INI file from {path}".format(**locals()))
|
||||
return None
|
||||
|
||||
arrayified_options = ["print_temperature", "filament_diameter", "start.gcode", "end.gcode"]
|
||||
|
|
|
|||
Loading…
Reference in a new issue