From 8a282db12bac930324d0697270b12c43438c2b58 Mon Sep 17 00:00:00 2001 From: Joel Collins Date: Thu, 9 Jan 2020 20:04:22 +0000 Subject: [PATCH] Moved to collision-robust device name --- openflexure_microscope/api/app.py | 2 +- .../api/default_extensions/autofocus.py | 6 +++--- .../api/default_extensions/scan.py | 2 +- .../api/default_extensions/zip_builder.py | 2 +- .../api/v2/views/actions/camera.py | 6 +++--- .../api/v2/views/actions/stage.py | 4 ++-- .../api/v2/views/captures.py | 18 +++++++++--------- openflexure_microscope/api/v2/views/state.py | 12 ++++++------ openflexure_microscope/api/v2/views/streams.py | 4 ++-- 9 files changed, 28 insertions(+), 28 deletions(-) diff --git a/openflexure_microscope/api/app.py b/openflexure_microscope/api/app.py index dad8d1c9..afbae740 100644 --- a/openflexure_microscope/api/app.py +++ b/openflexure_microscope/api/app.py @@ -69,7 +69,7 @@ app, labthing = create_app( app.json_encoder = JSONEncoder # Attach lab devices -labthing.register_device(api_microscope, "openflexure_microscope") +labthing.register_device(api_microscope, "org.openflexure.microscope") # Attach extensions if not os.path.isfile(USER_EXTENSIONS_PATH): diff --git a/openflexure_microscope/api/default_extensions/autofocus.py b/openflexure_microscope/api/default_extensions/autofocus.py index 7e656543..913ce367 100644 --- a/openflexure_microscope/api/default_extensions/autofocus.py +++ b/openflexure_microscope/api/default_extensions/autofocus.py @@ -290,7 +290,7 @@ def fast_up_down_up_autofocus( class MeasureSharpnessAPI(Resource): def post(self): - microscope = find_device("openflexure_microscope") + microscope = find_device("org.openflexure.microscope") if not microscope: abort(503, "No microscope connected. Unable to measure sharpness.") @@ -305,7 +305,7 @@ class AutofocusAPI(Resource): def post(self): payload = JsonResponse(request) - microscope = find_device("openflexure_microscope") + microscope = find_device("org.openflexure.microscope") if not microscope: abort(503, "No microscope connected. Unable to autofocus.") @@ -331,7 +331,7 @@ class FastAutofocusAPI(Resource): def post(self): payload = JsonResponse(request) - microscope = find_device("openflexure_microscope") + microscope = find_device("org.openflexure.microscope") if not microscope: abort(503, "No microscope connected. Unable to autofocus.") diff --git a/openflexure_microscope/api/default_extensions/scan.py b/openflexure_microscope/api/default_extensions/scan.py index dd9f4986..7cff8621 100644 --- a/openflexure_microscope/api/default_extensions/scan.py +++ b/openflexure_microscope/api/default_extensions/scan.py @@ -359,7 +359,7 @@ class TileScanAPI(Resource): ) @marshal_task def post(self, args): - microscope = find_device("openflexure_microscope") + microscope = find_device("org.openflexure.microscope") if not microscope: abort(503, "No microscope connected. Unable to autofocus.") diff --git a/openflexure_microscope/api/default_extensions/zip_builder.py b/openflexure_microscope/api/default_extensions/zip_builder.py index 45b119a2..286789fc 100644 --- a/openflexure_microscope/api/default_extensions/zip_builder.py +++ b/openflexure_microscope/api/default_extensions/zip_builder.py @@ -95,7 +95,7 @@ class ZipBuilderAPIView(Resource): def post(self): ids = list(JsonResponse(request).json) - microscope = find_device("openflexure_microscope") + microscope = find_device("org.openflexure.microscope") task = taskify(default_zip_manager.build_zip_from_capture_ids)(microscope, ids) diff --git a/openflexure_microscope/api/v2/views/actions/camera.py b/openflexure_microscope/api/v2/views/actions/camera.py index 4e8ef19e..16f3313d 100644 --- a/openflexure_microscope/api/v2/views/actions/camera.py +++ b/openflexure_microscope/api/v2/views/actions/camera.py @@ -49,7 +49,7 @@ class CaptureAPI(Resource): """ Create a new capture """ - microscope = find_device("openflexure_microscope") + microscope = find_device("org.openflexure.microscope") resize = args.get("resize", None) if resize: @@ -97,7 +97,7 @@ class GPUPreviewStartAPI(Resource): """ Start the onboard GPU preview. """ - microscope = find_device("openflexure_microscope") + microscope = find_device("org.openflexure.microscope") payload = JsonResponse(request) window = payload.param("window", default=[]) @@ -120,6 +120,6 @@ class GPUPreviewStopAPI(Resource): """ Stop the onboard GPU preview. """ - microscope = find_device("openflexure_microscope") + microscope = find_device("org.openflexure.microscope") microscope.camera.stop_preview() return jsonify(microscope.state) diff --git a/openflexure_microscope/api/v2/views/actions/stage.py b/openflexure_microscope/api/v2/views/actions/stage.py index 3680ecd6..5aa3e501 100644 --- a/openflexure_microscope/api/v2/views/actions/stage.py +++ b/openflexure_microscope/api/v2/views/actions/stage.py @@ -28,7 +28,7 @@ class MoveStageAPI(Resource): """ Move the microscope stage in x, y, z """ - microscope = find_device("openflexure_microscope") + microscope = find_device("org.openflexure.microscope") # Handle absolute positioning (calculate a relative move from current position and target) if (args.get("absolute")) and (microscope.stage): # Only if stage exists @@ -62,7 +62,7 @@ class ZeroStageAPI(Resource): Zero the stage coordinates. Does not move the stage, but rather makes the current position read as [0, 0, 0] """ - microscope = find_device("openflexure_microscope") + microscope = find_device("org.openflexure.microscope") microscope.stage.zero_position() return jsonify(microscope.status["stage"]) diff --git a/openflexure_microscope/api/v2/views/captures.py b/openflexure_microscope/api/v2/views/captures.py index bfb31e87..819b46e0 100644 --- a/openflexure_microscope/api/v2/views/captures.py +++ b/openflexure_microscope/api/v2/views/captures.py @@ -71,7 +71,7 @@ class CaptureList(Resource): @marshal_with(CaptureSchema(many=True)) def get(self): - microscope = find_device("openflexure_microscope") + microscope = find_device("org.openflexure.microscope") image_list = microscope.camera.images return image_list @@ -83,7 +83,7 @@ class CaptureResource(Resource): @marshal_with(CaptureSchema()) def get(self, id): - microscope = find_device("openflexure_microscope") + microscope = find_device("org.openflexure.microscope") capture_obj = microscope.camera.image_from_id(id) if not capture_obj: @@ -92,7 +92,7 @@ class CaptureResource(Resource): return capture_obj def delete(self, id): - microscope = find_device("openflexure_microscope") + microscope = find_device("org.openflexure.microscope") capture_obj = microscope.camera.image_from_id(id) if not capture_obj: @@ -110,7 +110,7 @@ class CaptureDownload(Resource): def get(self, id, filename): - microscope = find_device("openflexure_microscope") + microscope = find_device("org.openflexure.microscope") capture_obj = microscope.camera.image_from_id(id) if not capture_obj: @@ -146,7 +146,7 @@ class CaptureTags(Resource): def get(self, id): - microscope = find_device("openflexure_microscope") + microscope = find_device("org.openflexure.microscope") capture_obj = microscope.camera.image_from_id(id) if not capture_obj: @@ -156,7 +156,7 @@ class CaptureTags(Resource): def put(self, id): - microscope = find_device("openflexure_microscope") + microscope = find_device("org.openflexure.microscope") capture_obj = microscope.camera.image_from_id(id) if not capture_obj: @@ -173,7 +173,7 @@ class CaptureTags(Resource): def delete(self, capture_id): - microscope = find_device("openflexure_microscope") + microscope = find_device("org.openflexure.microscope") capture_obj = microscope.camera.image_from_id(id) if not capture_obj: @@ -196,7 +196,7 @@ class CaptureMetadata(Resource): """ def get(self, id): - microscope = find_device("openflexure_microscope") + microscope = find_device("org.openflexure.microscope") capture_obj = microscope.camera.image_from_id(id) if not capture_obj: @@ -205,7 +205,7 @@ class CaptureMetadata(Resource): return jsonify(capture_obj.metadata) def put(self, id): - microscope = find_device("openflexure_microscope") + microscope = find_device("org.openflexure.microscope") capture_obj = microscope.camera.image_from_id(id) if not capture_obj: diff --git a/openflexure_microscope/api/v2/views/state.py b/openflexure_microscope/api/v2/views/state.py index e1ae2745..09408c00 100644 --- a/openflexure_microscope/api/v2/views/state.py +++ b/openflexure_microscope/api/v2/views/state.py @@ -15,11 +15,11 @@ import logging class SettingsProperty(Resource): def get(self): - microscope = find_device("openflexure_microscope") + microscope = find_device("org.openflexure.microscope") return jsonify(microscope.read_settings()) def put(self): - microscope = find_device("openflexure_microscope") + microscope = find_device("org.openflexure.microscope") payload = JsonResponse(request) logging.debug("Updating settings from PUT request:") @@ -33,7 +33,7 @@ class SettingsProperty(Resource): class NestedSettingsProperty(Resource): def get(self, route): - microscope = find_device("openflexure_microscope") + microscope = find_device("org.openflexure.microscope") keys = route.split("/") try: @@ -44,7 +44,7 @@ class NestedSettingsProperty(Resource): return jsonify(value) def put(self, route): - microscope = find_device("openflexure_microscope") + microscope = find_device("org.openflexure.microscope") keys = route.split("/") payload = JsonResponse(request) @@ -59,13 +59,13 @@ class NestedSettingsProperty(Resource): class StatusProperty(Resource): def get(self): - microscope = find_device("openflexure_microscope") + microscope = find_device("org.openflexure.microscope") return jsonify(microscope.status) class NestedStatusProperty(Resource): def get(self, route): - microscope = find_device("openflexure_microscope") + microscope = find_device("org.openflexure.microscope") keys = route.split("/") try: diff --git a/openflexure_microscope/api/v2/views/streams.py b/openflexure_microscope/api/v2/views/streams.py index 70cb8d3a..3ba63cca 100644 --- a/openflexure_microscope/api/v2/views/streams.py +++ b/openflexure_microscope/api/v2/views/streams.py @@ -22,7 +22,7 @@ class MjpegStream(Resource): """ MJPEG stream from the microscope camera """ - microscope = find_device("openflexure_microscope") + microscope = find_device("org.openflexure.microscope") # Restart stream worker thread microscope.camera.start_worker() @@ -46,7 +46,7 @@ class SnapshotStream(Resource): :>header Content-Type: image/jpeg :status 200: stream active """ - microscope = find_device("openflexure_microscope") + microscope = find_device("org.openflexure.microscope") # Restart stream worker thread microscope.camera.start_worker()