sourcery.ai cleanup
This commit is contained in:
parent
a5a76979b9
commit
b66776a5fb
|
@ -53,6 +53,9 @@ import planktoscope.segmenter
|
||||||
# Import the planktonscope LED module
|
# Import the planktonscope LED module
|
||||||
import planktoscope.light
|
import planktoscope.light
|
||||||
|
|
||||||
|
# Import the planktonscope uuidName module
|
||||||
|
import planktoscope.uuidName
|
||||||
|
|
||||||
|
|
||||||
# global variable that keeps the wheels spinning
|
# global variable that keeps the wheels spinning
|
||||||
run = True
|
run = True
|
||||||
|
@ -75,8 +78,7 @@ if __name__ == "__main__":
|
||||||
# check if gpu_mem configuration is at least 256Meg, otherwise the camera will not run properly
|
# check if gpu_mem configuration is at least 256Meg, otherwise the camera will not run properly
|
||||||
with open("/boot/config.txt", "r") as config_file:
|
with open("/boot/config.txt", "r") as config_file:
|
||||||
for i, line in enumerate(config_file):
|
for i, line in enumerate(config_file):
|
||||||
if line.startswith("gpu_mem"):
|
if line.startswith("gpu_mem") and int(line.split("=")[1].strip()) < 256:
|
||||||
if int(line.split("=")[1].strip()) < 256:
|
|
||||||
logger.error(
|
logger.error(
|
||||||
"The GPU memory size is less than 256, this will prevent the camera from running properly"
|
"The GPU memory size is less than 256, this will prevent the camera from running properly"
|
||||||
)
|
)
|
||||||
|
@ -101,8 +103,7 @@ if __name__ == "__main__":
|
||||||
# create the path!
|
# create the path!
|
||||||
os.makedirs(export_path)
|
os.makedirs(export_path)
|
||||||
|
|
||||||
with open("/sys/firmware/devicetree/base/serial-number", "r") as config_file:
|
logger.info(f"This PlanktoScope unique ID is {planktoscope.uuidName.getSerial()}")
|
||||||
logger.info(f"This PlanktoScope unique ID is {config_file.readline()}")
|
|
||||||
|
|
||||||
# Prepare the event for a gracefull shutdown
|
# Prepare the event for a gracefull shutdown
|
||||||
shutdown_event = multiprocessing.Event()
|
shutdown_event = multiprocessing.Event()
|
||||||
|
|
|
@ -280,7 +280,6 @@ class ImagerProcess(multiprocessing.Process):
|
||||||
logger.error("We can't update the configuration while we are imaging.")
|
logger.error("We can't update the configuration while we are imaging.")
|
||||||
# Publish the status "Interrupted" to via MQTT to Node-RED
|
# Publish the status "Interrupted" to via MQTT to Node-RED
|
||||||
self.imager_client.client.publish("status/imager", '{"status":"Busy"}')
|
self.imager_client.client.publish("status/imager", '{"status":"Busy"}')
|
||||||
pass
|
|
||||||
|
|
||||||
elif action == "settings":
|
elif action == "settings":
|
||||||
if self.__imager.state.name is "stop":
|
if self.__imager.state.name is "stop":
|
||||||
|
@ -327,7 +326,6 @@ class ImagerProcess(multiprocessing.Process):
|
||||||
)
|
)
|
||||||
# Publish the status "Interrupted" to via MQTT to Node-RED
|
# Publish the status "Interrupted" to via MQTT to Node-RED
|
||||||
self.imager_client.client.publish("status/imager", '{"status":"Busy"}')
|
self.imager_client.client.publish("status/imager", '{"status":"Busy"}')
|
||||||
pass
|
|
||||||
|
|
||||||
elif action != "":
|
elif action != "":
|
||||||
logger.warning(
|
logger.warning(
|
||||||
|
@ -429,7 +427,6 @@ class ImagerProcess(multiprocessing.Process):
|
||||||
self.__imager.change(planktoscope.imager_state_machine.Stop)
|
self.__imager.change(planktoscope.imager_state_machine.Stop)
|
||||||
# Set the LEDs as Green
|
# Set the LEDs as Green
|
||||||
planktoscope.light.setRGB(0, 255, 255)
|
planktoscope.light.setRGB(0, 255, 255)
|
||||||
return
|
|
||||||
else:
|
else:
|
||||||
# We have not reached the final stage, let's keep imaging
|
# We have not reached the final stage, let's keep imaging
|
||||||
# Set the LEDs as Blue
|
# Set the LEDs as Blue
|
||||||
|
@ -461,10 +458,9 @@ class ImagerProcess(multiprocessing.Process):
|
||||||
self.__imager.change(planktoscope.imager_state_machine.Waiting)
|
self.__imager.change(planktoscope.imager_state_machine.Waiting)
|
||||||
return
|
return
|
||||||
|
|
||||||
elif self.__imager.state.name is "waiting":
|
elif (
|
||||||
return
|
self.__imager.state.name is "waiting" or self.__imager.state.name is "stop"
|
||||||
|
):
|
||||||
elif self.__imager.state.name is "stop":
|
|
||||||
return
|
return
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
|
@ -84,7 +84,7 @@ def light(state):
|
||||||
|
|
||||||
if state == "on":
|
if state == "on":
|
||||||
RPi.GPIO.output(21, RPi.GPIO.HIGH)
|
RPi.GPIO.output(21, RPi.GPIO.HIGH)
|
||||||
if state == "off":
|
elif state == "off":
|
||||||
RPi.GPIO.output(21, RPi.GPIO.LOW)
|
RPi.GPIO.output(21, RPi.GPIO.LOW)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -341,7 +341,6 @@ class SegmenterProcess(multiprocessing.Process):
|
||||||
self.segmenter_client.client.publish(
|
self.segmenter_client.client.publish(
|
||||||
"status/segmenter", '{"status":"Busy"}'
|
"status/segmenter", '{"status":"Busy"}'
|
||||||
)
|
)
|
||||||
pass
|
|
||||||
|
|
||||||
elif action != "":
|
elif action != "":
|
||||||
logger.warning(
|
logger.warning(
|
||||||
|
|
|
@ -188,7 +188,7 @@ class StepperProcess(multiprocessing.Process):
|
||||||
logger.info(
|
logger.info(
|
||||||
"The hardware configuration file doesn't exists, using defaults"
|
"The hardware configuration file doesn't exists, using defaults"
|
||||||
)
|
)
|
||||||
configuration = dict()
|
configuration = {}
|
||||||
|
|
||||||
reverse = False
|
reverse = False
|
||||||
|
|
||||||
|
@ -371,7 +371,7 @@ class StepperProcess(multiprocessing.Process):
|
||||||
)
|
)
|
||||||
|
|
||||||
# Validation of inputs
|
# Validation of inputs
|
||||||
if direction != "UP" and direction != "DOWN":
|
if direction not in ["UP", "DOWN"]:
|
||||||
logger.error("The direction command is not recognised")
|
logger.error("The direction command is not recognised")
|
||||||
logger.error("It should be either UP or DOWN")
|
logger.error("It should be either UP or DOWN")
|
||||||
return
|
return
|
||||||
|
@ -431,7 +431,7 @@ class StepperProcess(multiprocessing.Process):
|
||||||
logger.info(f"The pump will move {direction} for {volume}mL at {speed}mL/min")
|
logger.info(f"The pump will move {direction} for {volume}mL at {speed}mL/min")
|
||||||
|
|
||||||
# Validation of inputs
|
# Validation of inputs
|
||||||
if direction != "FORWARD" and direction != "BACKWARD":
|
if direction not in ["FORWARD", "BACKWARD"]:
|
||||||
logger.error("The direction command is not recognised")
|
logger.error("The direction command is not recognised")
|
||||||
logger.error("It should be either FORWARD or BACKWARD")
|
logger.error("It should be either FORWARD or BACKWARD")
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue