Loading openflexure_microscope/api/v2/blueprints/actions/__init__.py +8 −8 Original line number Diff line number Diff line Loading @@ -8,38 +8,38 @@ _actions = { "rule": "/camera/capture/", "view_class": camera.CaptureAPI, "description": "Take a single still capture", "conditions": True "conditions": True, }, "preview_start": { "rule": "/camera/preview/start", "view_class": camera.GPUPreviewStartAPI, "description": "Start the on-board GPU preview", "conditions": True "conditions": True, }, "preview_stop": { "rule": "/camera/preview/stop", "view_class": camera.GPUPreviewStopAPI, "description": "Stop the on-board GPU preview", "conditions": True "conditions": True, }, "move": { "rule": "/stage/move/", "view_class": stage.MoveStageAPI, "description": "Move the microscope stage", "conditions": True "conditions": True, }, "shutdown": { "rule": "/system/shutdown/", "view_class": system.ShutdownAPI, "description": "Shutdown the device", "conditions": (platform == "linux") "conditions": (platform == "linux"), }, "reboot": { "rule": "/system/reboot/", "view_class": system.RebootAPI, "description": "Reboot the device", "conditions": (platform == "linux") } "conditions": (platform == "linux"), }, } Loading @@ -57,7 +57,7 @@ def actions_representation(): "links": {"self": url_for(f".{name}")}, "description": action["description"], "rule": action["rule"], "view_class": str(action["view_class"]) "view_class": str(action["view_class"]), } actions[name] = d Loading openflexure_microscope/api/v2/blueprints/actions/system.py +2 −2 Original line number Diff line number Diff line Loading @@ -11,7 +11,7 @@ class ShutdownAPI(MicroscopeView): .. :quickref: Actions; Shutdown """ subprocess.Popen(['shutdown', '-h', 'now']) subprocess.Popen(["shutdown", "-h", "now"]) return "{}", 201 Loading @@ -24,6 +24,6 @@ class RebootAPI(MicroscopeView): .. :quickref: Actions; Shutdown """ subprocess.Popen(['sudo', 'shutdown', '-r', 'now']) subprocess.Popen(["sudo", "shutdown", "-r", "now"]) return "{}", 201 openflexure_microscope/api/v2/blueprints/captures.py +15 −8 Original line number Diff line number Diff line Loading @@ -20,14 +20,22 @@ def captures_representation(capture_list: list, include_unavailable: bool = Fals if include_unavailable: captures = {image.id: image.state for image in capture_list} else: captures = {image.id: image.state for image in capture_list if image.state["available"]} captures = { image.id: image.state for image in capture_list if image.state["available"] } for capture_key, capture_repr in captures.items(): # Add API routes to returned representations extra_state = { "links": { "self": "{}".format(url_for(".capture", capture_id=capture_key)), "download": "{}".format(url_for(".capture_download", capture_id=capture_key, filename=capture_repr["filename"])), "download": "{}".format( url_for( ".capture_download", capture_id=capture_key, filename=capture_repr["filename"], ) ), "tags": "{}".format(url_for(".capture_tags", capture_id=capture_key)), } } Loading Loading @@ -131,7 +139,9 @@ class CaptureAPI(MicroscopeView): """ try: representation = captures_representation(self.microscope.camera.images)[capture_id] representation = captures_representation(self.microscope.camera.images)[ capture_id ] except KeyError: return abort(404) # 404 Not Found Loading Loading @@ -379,9 +389,7 @@ def construct_blueprint(microscope_obj): # Capture routes blueprint.add_url_rule( "/<capture_id>/download/<filename>", view_func=DownloadAPI.as_view( "capture_download", microscope=microscope_obj ), view_func=DownloadAPI.as_view("capture_download", microscope=microscope_obj), ) blueprint.add_url_rule( Loading @@ -397,7 +405,6 @@ def construct_blueprint(microscope_obj): ) blueprint.add_url_rule( "/", view_func=ListAPI.as_view("capture_list", microscope=microscope_obj), "/", view_func=ListAPI.as_view("capture_list", microscope=microscope_obj) ) return blueprint openflexure_microscope/api/v2/blueprints/plugins.py +2 −3 Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ def plugins_representation(plugin_loader_object: PluginLoader): "name": plugin["name"], "plugin": str(plugin["plugin"]), "routes": plugin["routes"], "form": plugin["form"] "form": plugin["form"], } plugins.append(d) Loading Loading @@ -55,8 +55,7 @@ def construct_blueprint(microscope_obj): # Create a base route to return plugin API forms, if any exist blueprint.add_url_rule( "/", view_func=PluginFormAPI.as_view("plugins", microscope=microscope_obj), "/", view_func=PluginFormAPI.as_view("plugins", microscope=microscope_obj) ) all_routes = [] Loading openflexure_microscope/api/v2/blueprints/tasks.py +1 −3 Original line number Diff line number Diff line Loading @@ -16,9 +16,7 @@ def tasks_representation(): for task_key, task_repr in tasks_dict.items(): # Add API routes to returned representations extra_state = { "links": { "self": "{}".format(url_for(".task", task_id=task_key)), } "links": {"self": "{}".format(url_for(".task", task_id=task_key))} } tasks_dict[task_key].update(extra_state) Loading Loading
openflexure_microscope/api/v2/blueprints/actions/__init__.py +8 −8 Original line number Diff line number Diff line Loading @@ -8,38 +8,38 @@ _actions = { "rule": "/camera/capture/", "view_class": camera.CaptureAPI, "description": "Take a single still capture", "conditions": True "conditions": True, }, "preview_start": { "rule": "/camera/preview/start", "view_class": camera.GPUPreviewStartAPI, "description": "Start the on-board GPU preview", "conditions": True "conditions": True, }, "preview_stop": { "rule": "/camera/preview/stop", "view_class": camera.GPUPreviewStopAPI, "description": "Stop the on-board GPU preview", "conditions": True "conditions": True, }, "move": { "rule": "/stage/move/", "view_class": stage.MoveStageAPI, "description": "Move the microscope stage", "conditions": True "conditions": True, }, "shutdown": { "rule": "/system/shutdown/", "view_class": system.ShutdownAPI, "description": "Shutdown the device", "conditions": (platform == "linux") "conditions": (platform == "linux"), }, "reboot": { "rule": "/system/reboot/", "view_class": system.RebootAPI, "description": "Reboot the device", "conditions": (platform == "linux") } "conditions": (platform == "linux"), }, } Loading @@ -57,7 +57,7 @@ def actions_representation(): "links": {"self": url_for(f".{name}")}, "description": action["description"], "rule": action["rule"], "view_class": str(action["view_class"]) "view_class": str(action["view_class"]), } actions[name] = d Loading
openflexure_microscope/api/v2/blueprints/actions/system.py +2 −2 Original line number Diff line number Diff line Loading @@ -11,7 +11,7 @@ class ShutdownAPI(MicroscopeView): .. :quickref: Actions; Shutdown """ subprocess.Popen(['shutdown', '-h', 'now']) subprocess.Popen(["shutdown", "-h", "now"]) return "{}", 201 Loading @@ -24,6 +24,6 @@ class RebootAPI(MicroscopeView): .. :quickref: Actions; Shutdown """ subprocess.Popen(['sudo', 'shutdown', '-r', 'now']) subprocess.Popen(["sudo", "shutdown", "-r", "now"]) return "{}", 201
openflexure_microscope/api/v2/blueprints/captures.py +15 −8 Original line number Diff line number Diff line Loading @@ -20,14 +20,22 @@ def captures_representation(capture_list: list, include_unavailable: bool = Fals if include_unavailable: captures = {image.id: image.state for image in capture_list} else: captures = {image.id: image.state for image in capture_list if image.state["available"]} captures = { image.id: image.state for image in capture_list if image.state["available"] } for capture_key, capture_repr in captures.items(): # Add API routes to returned representations extra_state = { "links": { "self": "{}".format(url_for(".capture", capture_id=capture_key)), "download": "{}".format(url_for(".capture_download", capture_id=capture_key, filename=capture_repr["filename"])), "download": "{}".format( url_for( ".capture_download", capture_id=capture_key, filename=capture_repr["filename"], ) ), "tags": "{}".format(url_for(".capture_tags", capture_id=capture_key)), } } Loading Loading @@ -131,7 +139,9 @@ class CaptureAPI(MicroscopeView): """ try: representation = captures_representation(self.microscope.camera.images)[capture_id] representation = captures_representation(self.microscope.camera.images)[ capture_id ] except KeyError: return abort(404) # 404 Not Found Loading Loading @@ -379,9 +389,7 @@ def construct_blueprint(microscope_obj): # Capture routes blueprint.add_url_rule( "/<capture_id>/download/<filename>", view_func=DownloadAPI.as_view( "capture_download", microscope=microscope_obj ), view_func=DownloadAPI.as_view("capture_download", microscope=microscope_obj), ) blueprint.add_url_rule( Loading @@ -397,7 +405,6 @@ def construct_blueprint(microscope_obj): ) blueprint.add_url_rule( "/", view_func=ListAPI.as_view("capture_list", microscope=microscope_obj), "/", view_func=ListAPI.as_view("capture_list", microscope=microscope_obj) ) return blueprint
openflexure_microscope/api/v2/blueprints/plugins.py +2 −3 Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ def plugins_representation(plugin_loader_object: PluginLoader): "name": plugin["name"], "plugin": str(plugin["plugin"]), "routes": plugin["routes"], "form": plugin["form"] "form": plugin["form"], } plugins.append(d) Loading Loading @@ -55,8 +55,7 @@ def construct_blueprint(microscope_obj): # Create a base route to return plugin API forms, if any exist blueprint.add_url_rule( "/", view_func=PluginFormAPI.as_view("plugins", microscope=microscope_obj), "/", view_func=PluginFormAPI.as_view("plugins", microscope=microscope_obj) ) all_routes = [] Loading
openflexure_microscope/api/v2/blueprints/tasks.py +1 −3 Original line number Diff line number Diff line Loading @@ -16,9 +16,7 @@ def tasks_representation(): for task_key, task_repr in tasks_dict.items(): # Add API routes to returned representations extra_state = { "links": { "self": "{}".format(url_for(".task", task_id=task_key)), } "links": {"self": "{}".format(url_for(".task", task_id=task_key))} } tasks_dict[task_key].update(extra_state) Loading