Loading openflexure_microscope/api/v1.py +8 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ from openflexure_microscope import Microscope from openflexure_microscope.camera.pi import StreamingCamera from openflexure_stage import OpenFlexureStage import atexit import logging, sys logging.basicConfig(stream=sys.stderr, level=logging.DEBUG) Loading Loading @@ -350,6 +351,7 @@ class CaptureListAPI(MicroscopeView): :status 200: capture created """ state = parse_payload(request) logging.info(state) # TODO: Roll all of these ugly if statements into a method for getting payload elements if 'filename' in state: Loading Loading @@ -569,6 +571,12 @@ app.add_url_rule( uri('/capture/<capture_id>/download/<filename>'), view_func=CaptureDownloadAPI.as_view('capture_download', microscope=api_microscope)) # Automatically clean up microscope at exit def cleanup(): global api_microscope api_microscope.close() atexit.register(cleanup) if __name__ == "__main__": app.run(host='0.0.0.0', port="5000", threaded=True, debug=True, use_reloader=False) openflexure_microscope/camera/capture.py +12 −6 Original line number Diff line number Diff line Loading @@ -24,7 +24,7 @@ class StreamObject(object): """Create a new StreamObject, to manage capture data.""" # Store a nice ID self.id = uuid.uuid4().hex logging.info("Created StreamObject {}".format(self.id)) logging.info("Created StreamObject {}. keep_on_disk: {}, write_to_file: {}".format(self.id, keep_on_disk, write_to_file)) # Store file format self.format = fmt Loading Loading @@ -81,11 +81,9 @@ class StreamObject(object): Defaults to datestamp. """ appendix = "" if not self.keep_on_disk: appendix += ".tmp" file_name = "{}.{}".format(filename, fmt) base_name = filename file_name = "{}.{}".format(base_name, fmt) # Create folder and file if folder: Loading @@ -96,9 +94,17 @@ class StreamObject(object): else: file_path = file_name self.basename = filename # Handle path appendix appendix = "" if not self.keep_on_disk: appendix += ".tmp" file_path = file_path + appendix #self.basename = filename self.file = file_path self.filename = file_name self.basename = base_name def lock(self): """Set locked flag to True.""" Loading openflexure_microscope/camera/pi.py +1 −0 Original line number Diff line number Diff line Loading @@ -357,6 +357,7 @@ class StreamingCamera(BaseCamera): fmt (str): Format of the capture. resize ((int, int)): Resize the captured image. """ # If no filename is specified, build a non-clashing one if not filename: filename = self.generate_basename(self.images) Loading Loading
openflexure_microscope/api/v1.py +8 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ from openflexure_microscope import Microscope from openflexure_microscope.camera.pi import StreamingCamera from openflexure_stage import OpenFlexureStage import atexit import logging, sys logging.basicConfig(stream=sys.stderr, level=logging.DEBUG) Loading Loading @@ -350,6 +351,7 @@ class CaptureListAPI(MicroscopeView): :status 200: capture created """ state = parse_payload(request) logging.info(state) # TODO: Roll all of these ugly if statements into a method for getting payload elements if 'filename' in state: Loading Loading @@ -569,6 +571,12 @@ app.add_url_rule( uri('/capture/<capture_id>/download/<filename>'), view_func=CaptureDownloadAPI.as_view('capture_download', microscope=api_microscope)) # Automatically clean up microscope at exit def cleanup(): global api_microscope api_microscope.close() atexit.register(cleanup) if __name__ == "__main__": app.run(host='0.0.0.0', port="5000", threaded=True, debug=True, use_reloader=False)
openflexure_microscope/camera/capture.py +12 −6 Original line number Diff line number Diff line Loading @@ -24,7 +24,7 @@ class StreamObject(object): """Create a new StreamObject, to manage capture data.""" # Store a nice ID self.id = uuid.uuid4().hex logging.info("Created StreamObject {}".format(self.id)) logging.info("Created StreamObject {}. keep_on_disk: {}, write_to_file: {}".format(self.id, keep_on_disk, write_to_file)) # Store file format self.format = fmt Loading Loading @@ -81,11 +81,9 @@ class StreamObject(object): Defaults to datestamp. """ appendix = "" if not self.keep_on_disk: appendix += ".tmp" file_name = "{}.{}".format(filename, fmt) base_name = filename file_name = "{}.{}".format(base_name, fmt) # Create folder and file if folder: Loading @@ -96,9 +94,17 @@ class StreamObject(object): else: file_path = file_name self.basename = filename # Handle path appendix appendix = "" if not self.keep_on_disk: appendix += ".tmp" file_path = file_path + appendix #self.basename = filename self.file = file_path self.filename = file_name self.basename = base_name def lock(self): """Set locked flag to True.""" Loading
openflexure_microscope/camera/pi.py +1 −0 Original line number Diff line number Diff line Loading @@ -357,6 +357,7 @@ class StreamingCamera(BaseCamera): fmt (str): Format of the capture. resize ((int, int)): Resize the captured image. """ # If no filename is specified, build a non-clashing one if not filename: filename = self.generate_basename(self.images) Loading