Replaced 202s with more suitable 201s

This commit is contained in:
jtc42 2019-11-15 16:53:50 +00:00
parent 76af0891e9
commit dac50f1f3a
7 changed files with 10 additions and 10 deletions

View file

@ -142,4 +142,4 @@ class TimelapseAPI(MicroscopeViewPlugin):
self.timelapse_task = taskify(self.plugin.timelapse)(n_images) self.timelapse_task = taskify(self.plugin.timelapse)(n_images)
# Return the state of the task (will show ID, start time, and status before the task has finished) # Return the state of the task (will show ID, start time, and status before the task has finished)
return jsonify(self.timelapse_task.state), 202 return jsonify(self.timelapse_task.state), 201

View file

@ -44,7 +44,7 @@ An example of a long running task may look like:
def post(self): def post(self):
# Attach the long-running method as a microscope task # Attach the long-running method as a microscope task
self.my_task = taskify(self.plugin.long_running_function)() self.my_task = taskify(self.plugin.long_running_function)()
return jsonify(self.my_task.state), 202 return jsonify(self.my_task.state), 201
After some time, once the task has completed, it could be retreived using: After some time, once the task has completed, it could be retreived using:
@ -132,7 +132,7 @@ For example, a timelapse plugin may look like:
self.timelapse_task = taskify(self.plugin.timelapse)(n_images) self.timelapse_task = taskify(self.plugin.timelapse)(n_images)
# Return the state of the task (will show ID, start time, and status before the task has finished) # Return the state of the task (will show ID, start time, and status before the task has finished)
return jsonify(self.timelapse_task.state), 202 return jsonify(self.timelapse_task.state), 201
Notice that even though we never use the stage here, we still acquire the lock. This means that during the timelapse, Notice that even though we never use the stage here, we still acquire the lock. This means that during the timelapse,

View file

@ -29,7 +29,7 @@ class AutofocusAPI(MicroscopeViewPlugin):
task = taskify(self.plugin.autofocus)(dz) task = taskify(self.plugin.autofocus)(dz)
# return a handle on the autofocus task # return a handle on the autofocus task
return jsonify(task.state), 202 return jsonify(task.state), 201
else: else:
abort(503, "No stage connected. Unable to autofocus.") abort(503, "No stage connected. Unable to autofocus.")
@ -50,7 +50,7 @@ class FastAutofocusAPI(MicroscopeViewPlugin):
task = taskify(self.plugin.fast_autofocus)(dz, backlash=backlash) task = taskify(self.plugin.fast_autofocus)(dz, backlash=backlash)
# return a handle on the autofocus task # return a handle on the autofocus task
return jsonify(task.state), 202 return jsonify(task.state), 201
else: else:
abort(503, "No stage connected. Unable to autofocus.") abort(503, "No stage connected. Unable to autofocus.")

View file

@ -18,7 +18,7 @@ class RecalibrateAPIView(MicroscopeViewPlugin):
task = taskify(self.plugin.recalibrate)() task = taskify(self.plugin.recalibrate)()
# Return a handle on the autofocus task # Return a handle on the autofocus task
return jsonify(task.state), 202 return jsonify(task.state), 201
class Plugin(MicroscopePlugin): class Plugin(MicroscopePlugin):

View file

@ -60,4 +60,4 @@ class TileScanAPI(MicroscopeViewPlugin):
) )
# return a handle on the scan task # return a handle on the scan task
return jsonify(task.state), 202 return jsonify(task.state), 201

View file

@ -73,7 +73,7 @@ class LongRunningAPI(MicroscopeViewPlugin):
# Attach the long-running method as a microscope task # Attach the long-running method as a microscope task
try: try:
task = self.microscope.task.start(self.plugin.long_running, time_to_run) task = self.microscope.task.start(self.plugin.long_running, time_to_run)
return jsonify(task.state), 202 return jsonify(task.state), 201
except TaskDeniedException: except TaskDeniedException:
return abort(409) return abort(409)
@ -94,7 +94,7 @@ class SomeExceptionAPI(MicroscopeViewPlugin):
# Attach the long-running method as a microscope task # Attach the long-running method as a microscope task
try: try:
task = self.microscope.task.start(self.plugin.some_exception) task = self.microscope.task.start(self.plugin.some_exception)
return jsonify(task.state), 202 return jsonify(task.state), 201
except TaskDeniedException: except TaskDeniedException:
return abort(409) return abort(409)

View file

@ -57,4 +57,4 @@ class TaskAPI(MicroscopeViewPlugin):
task = taskify(self.plugin.generate_random_numbers_for_a_while)(val_int) task = taskify(self.plugin.generate_random_numbers_for_a_while)(val_int)
# return a handle on the autofocus task # return a handle on the autofocus task
return jsonify(task.state), 202 return jsonify(task.state), 201