diff --git a/src/octoprint/plugins/cura/__init__.py b/src/octoprint/plugins/cura/__init__.py index 8b74a032..78a23501 100644 --- a/src/octoprint/plugins/cura/__init__.py +++ b/src/octoprint/plugins/cura/__init__.py @@ -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( diff --git a/src/octoprint/plugins/cura/profile.py b/src/octoprint/plugins/cura/profile.py index a63ff9cb..59a0ee15 100644 --- a/src/octoprint/plugins/cura/profile.py +++ b/src/octoprint/plugins/cura/profile.py @@ -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"]