Close the camera if the stage cannot be opened
This commit is contained in:
parent
6b9a34437e
commit
a98158634c
1 changed files with 13 additions and 8 deletions
|
|
@ -7,6 +7,7 @@ from flask import (
|
||||||
Flask, render_template)
|
Flask, render_template)
|
||||||
|
|
||||||
from flask.logging import default_handler
|
from flask.logging import default_handler
|
||||||
|
from serial import SerialException
|
||||||
|
|
||||||
from flask_cors import CORS
|
from flask_cors import CORS
|
||||||
|
|
||||||
|
|
@ -71,8 +72,12 @@ def attach_microscope():
|
||||||
api_camera = StreamingCamera(config=api_microscope.rc.read())
|
api_camera = StreamingCamera(config=api_microscope.rc.read())
|
||||||
|
|
||||||
logging.debug("Creating stage object...")
|
logging.debug("Creating stage object...")
|
||||||
|
try:
|
||||||
api_stage = Stage("/dev/ttyUSB0")
|
api_stage = Stage("/dev/ttyUSB0")
|
||||||
|
except SerialException as e:
|
||||||
|
api_camera.close()
|
||||||
|
raise e
|
||||||
|
else:
|
||||||
logging.debug("Attaching devices to microscope...")
|
logging.debug("Attaching devices to microscope...")
|
||||||
api_microscope.attach(
|
api_microscope.attach(
|
||||||
api_camera,
|
api_camera,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue