diff --git a/docs/api/slicing.rst b/docs/api/slicing.rst index 7edabe8f..5204da15 100644 --- a/docs/api/slicing.rst +++ b/docs/api/slicing.rst @@ -110,7 +110,7 @@ List Slicing Profiles of a Specific Slicer :param slicer: The identifying key of the slicer for which to list the available profiles. :statuscode 200: No error - :statuscode 404: If the ``slicer`` was unknown to the system. + :statuscode 404: If the ``slicer`` was unknown to the system or not yet configured. .. _sec-api-slicing-listspecific: @@ -155,7 +155,7 @@ Retrieve Specific Profile :param slicer: The identifying key of the slicer for which to list the available profiles. :param name: The identifying key of the profile to retrieve :statuscode 200: No error - :statuscode 404: If the ``slicer`` or the profile was unknown to the system. + :statuscode 404: If the ``slicer`` or the profile ``key`` was unknown to the system. .. _sec-api-slicing-add: @@ -215,7 +215,8 @@ Delete Slicing Profile .. http:delete:: /api/slicing/(string:slicer)/profiles/(string:key) - Delete the slicing profile identified by ``key`` for the slicer ``slicer``. + Delete the slicing profile identified by ``key`` for the slicer ``slicer``. If the profile doesn't exist, the + request will succeed anyway. :param slicer: The identifying key of the slicer for which to delete the profile :param key: The identifying key of the profile to delete diff --git a/src/octoprint/server/api/slicing.py b/src/octoprint/server/api/slicing.py index 4ad45e06..a1237f40 100644 --- a/src/octoprint/server/api/slicing.py +++ b/src/octoprint/server/api/slicing.py @@ -89,11 +89,10 @@ def slicingAddSlicerProfile(slicer, name): description = json_data["description"] try: - profile = slicingManager.save_profile(slicer, name, data, display_name=display_name, description=description) + profile = slicingManager.save_profile(slicer, name, data, + allow_overwrite=True, display_name=display_name, description=description) except UnknownSlicer: return make_response("Unknown slicer {slicer}".format(**locals()), 404) - except ProfileAlreadyExists: - return make_response("A profile named {name} already exists for slicer {slicer}".format(**locals()), 409) result = _getSlicingProfileData(slicer, name, profile) r = make_response(jsonify(result), 201) @@ -137,10 +136,8 @@ def slicingPatchSlicerProfile(slicer, name): s().set(["slicing", "defaultProfiles"], default_profiles) s().save(force=True) - try: - saved_profile = slicingManager.save_profile(slicer, name, profile, overrides=data, display_name=display_name, description=description) - except ProfileAlreadyExists: - return make_response("Profile named {name} for slicer {slicer} does already exist".format(**locals()), 409) + saved_profile = slicingManager.save_profile(slicer, name, profile, + allow_overwrite=True, overrides=data, display_name=display_name, description=description) return jsonify(_getSlicingProfileData(slicer, name, saved_profile)) @api.route("/slicing//profiles/", methods=["DELETE"]) @@ -150,8 +147,6 @@ def slicingDelSlicerProfile(slicer, name): slicingManager.delete_profile(slicer, name) except UnknownSlicer: return make_response("Unknown slicer {slicer}".format(**locals()), 404) - except UnknownProfile: - return make_response("Unknown profile {name} for slicer {slicer}".format(**locals()), 404) return NO_CONTENT diff --git a/src/octoprint/slicing/__init__.py b/src/octoprint/slicing/__init__.py index 083e5611..ab86c421 100644 --- a/src/octoprint/slicing/__init__.py +++ b/src/octoprint/slicing/__init__.py @@ -434,7 +434,7 @@ class SlicingManager(object): raise ValueError("name must be set") try: - path = self.get_profile_path(slicer, name) + path = self.get_profile_path(slicer, name, must_exist=True) except UnknownProfile: return os.remove(path)