Style and linting
This commit is contained in:
parent
f12671fa3f
commit
de135abc95
2 changed files with 28 additions and 21 deletions
|
|
@ -1,17 +1,19 @@
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from .error_sources import ErrorSource, WarningSource
|
from .error_sources import ErrorSource
|
||||||
|
|
||||||
picamera_import_error = ErrorSource(
|
picamera_import_error = ErrorSource(
|
||||||
"Picamera module could not be imported. Check physical connections to the camera as it may be damaged."
|
("Picamera module could not be imported.",
|
||||||
|
"Check physical connections to the camera as it may be damaged or disconnected.")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
error_sources = []
|
error_sources = []
|
||||||
logging.info("Attempting to import picamera...")
|
logging.info("Attempting to import picamera...")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from picamerax import PiCamera
|
from picamerax import PiCamera as _
|
||||||
except Exception as e: # pylint: disable=W0703
|
except Exception as e: # pylint: disable=W0703
|
||||||
# TODO: Parse exception object for a few different issues, and append different error sources
|
# TODO: Parse exception object for a few different issues, and append different error sources
|
||||||
# E.g. pi with camera already in use, disconnected, unsupported OS, etc
|
# E.g. pi with camera already in use, disconnected, unsupported OS, etc
|
||||||
|
|
|
||||||
|
|
@ -8,37 +8,42 @@ def main():
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from sangaboard import Sangaboard
|
from sangaboard import Sangaboard
|
||||||
except Exception as e: # pylint: disable=W0703
|
except ImportError as e:
|
||||||
error_sources.append(ErrorSource(
|
error_sources.append(ErrorSource(str(e)))
|
||||||
"Sangaboard module could not be imported."
|
|
||||||
))
|
|
||||||
else:
|
else:
|
||||||
configuration = user_configuration.load()
|
configuration = user_configuration.load()
|
||||||
stage_type = configuration["stage"].get("type")
|
stage_type = configuration["stage"].get("type")
|
||||||
stage_port = configuration["stage"].get("port")
|
stage_port = configuration["stage"].get("port")
|
||||||
|
|
||||||
error_sources.append(WarningSource(
|
error_sources.append(
|
||||||
"Stage serial port is not specified in configuration. Application will scan ports for a Sangaboard."
|
WarningSource(
|
||||||
))
|
"Stage serial port is not specified in configuration. Application will scan ports for a Sangaboard."
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
# If any Sangaboard-based stage is configured for use
|
# If any Sangaboard-based stage is configured for use
|
||||||
if stage_type in ("SangaBoard", "SangaStage", "SangaDeltaStage"):
|
if stage_type in ("SangaBoard", "SangaStage", "SangaDeltaStage"):
|
||||||
# Try connecting on the specified port
|
# Try connecting on the specified port
|
||||||
try:
|
try:
|
||||||
_ = Sangaboard(stage_port)
|
_ = Sangaboard(stage_port)
|
||||||
except FileNotFoundError as e: # pylint: disable=W0703
|
except FileNotFoundError as e:
|
||||||
if stage_port:
|
if stage_port:
|
||||||
error_sources.append(ErrorSource(
|
error_sources.append(
|
||||||
f"No {stage_type} device was found on the configured port {stage_port}."
|
ErrorSource(
|
||||||
))
|
f"No {stage_type} device was found on the configured port {stage_port}."
|
||||||
|
)
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
error_sources.append(ErrorSource(
|
error_sources.append(
|
||||||
f"No {stage_type} device was found during port scanning."
|
ErrorSource(
|
||||||
))
|
f"No {stage_type} device was found during port scanning."
|
||||||
|
)
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
error_sources.append(ErrorSource(
|
error_sources.append(
|
||||||
f"Invalid stage type {stage_type} specified in configuration file."
|
ErrorSource(
|
||||||
))
|
f"Invalid stage type {stage_type} specified in configuration file."
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
return error_sources
|
return error_sources
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue