python: improve log messages
This commit is contained in:
parent
2c9a6df20f
commit
1a42f05941
|
@ -123,7 +123,7 @@ if __name__ == "__main__":
|
|||
segmenter_thread = planktoscope.segmenter.SegmenterProcess(shutdown_event)
|
||||
segmenter_thread.start()
|
||||
|
||||
logger.info("Looks like everything is set up and running, have fun!")
|
||||
logger.success("Looks like everything is set up and running, have fun!")
|
||||
|
||||
while run:
|
||||
# TODO look into ways of restarting the dead threads
|
||||
|
@ -141,6 +141,7 @@ if __name__ == "__main__":
|
|||
|
||||
logger.info("Shutting down the shop")
|
||||
shutdown_event.set()
|
||||
time.sleep(0.5)
|
||||
stepper_thread.join()
|
||||
imager_thread.join()
|
||||
segmenter_thread.join()
|
||||
|
|
|
@ -162,7 +162,7 @@ class ImagerProcess(multiprocessing.Process):
|
|||
# FIXME We should save the metadata to a file in the folder too
|
||||
# TODO create a directory structure per day/per imaging session
|
||||
|
||||
logger.info("planktoscope.imager is initialised and ready to go!")
|
||||
logger.success("planktoscope.imager is initialised and ready to go!")
|
||||
|
||||
@logger.catch
|
||||
def start_camera(self):
|
||||
|
@ -401,8 +401,9 @@ class ImagerProcess(multiprocessing.Process):
|
|||
# Define the filename of the image
|
||||
filename_path = os.path.join(self.__export_path, filename)
|
||||
|
||||
logger.info(f"Capturing an image to {filename_path}")
|
||||
# TODO Insert here a delay to stabilize the flow before we image
|
||||
logger.info(
|
||||
f"Capturing image {self.__img_done + 1}/{self.__img_goal} to {filename_path}"
|
||||
)
|
||||
|
||||
# Capture an image with the proper filename
|
||||
self.__camera.capture(filename_path)
|
||||
|
@ -413,7 +414,7 @@ class ImagerProcess(multiprocessing.Process):
|
|||
# Publish the name of the image to via MQTT to Node-RED
|
||||
self.imager_client.client.publish(
|
||||
"status/imager",
|
||||
f'{{"status":"{self.__img_done + 1}/{self.__img_goal} has been imaged to {filename}."}}',
|
||||
f'{{"status":"Image {self.__img_done + 1}/{self.__img_goal} has been imaged to {filename}"}}',
|
||||
)
|
||||
|
||||
# Increment the counter
|
||||
|
@ -483,6 +484,9 @@ class ImagerProcess(multiprocessing.Process):
|
|||
topic="imager/#", name="imager_client"
|
||||
)
|
||||
|
||||
self.imager_client.client.publish("status/imager", '{"status":"Starting up"}')
|
||||
|
||||
logger.info("Initialising the camera")
|
||||
# PiCamera settings
|
||||
self.__camera = picamera.PiCamera(resolution=self.__resolution)
|
||||
self.__camera.iso = self.__iso
|
||||
|
@ -502,7 +506,7 @@ class ImagerProcess(multiprocessing.Process):
|
|||
# Publish the status "Ready" to via MQTT to Node-RED
|
||||
self.imager_client.client.publish("status/imager", '{"status":"Ready"}')
|
||||
|
||||
logger.info("Let's rock and roll!")
|
||||
logger.success("Camera is READY!")
|
||||
|
||||
# This is the loop
|
||||
while not self.stop_event.is_set():
|
||||
|
@ -517,6 +521,8 @@ class ImagerProcess(multiprocessing.Process):
|
|||
self.__camera.close()
|
||||
logger.debug("Stopping the streaming thread")
|
||||
server.shutdown()
|
||||
logger.debug("Stopping MQTT")
|
||||
self.imager_client.shutdown()
|
||||
# self.streaming_thread.kill()
|
||||
logger.info("Imager process shut down! See you!")
|
||||
logger.success("Imager process shut down! See you!")
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ class SegmenterProcess(multiprocessing.Process):
|
|||
os.makedirs(self.__ecotaxa_path)
|
||||
# Morphocut's pipeline will be created at runtime otherwise shit ensues
|
||||
|
||||
logger.info("planktoscope.segmenter is initialised and ready to go!")
|
||||
logger.success("planktoscope.segmenter is initialised and ready to go!")
|
||||
|
||||
def __create_morphocut_pipeline(self):
|
||||
"""Creates the Morphocut Pipeline"""
|
||||
|
@ -349,7 +349,7 @@ class SegmenterProcess(multiprocessing.Process):
|
|||
# Publish the status "Ready" to via MQTT to Node-RED
|
||||
self.segmenter_client.client.publish("status/segmenter", '{"status":"Ready"}')
|
||||
|
||||
logger.info("Ready to roll!")
|
||||
logger.success("Segmenter is READY!")
|
||||
|
||||
# This is the loop
|
||||
while not self.stop_event.is_set():
|
||||
|
@ -359,4 +359,5 @@ class SegmenterProcess(multiprocessing.Process):
|
|||
logger.info("Shutting down the segmenter process")
|
||||
self.segmenter_client.client.publish("status/segmenter", '{"status":"Dead"}')
|
||||
self.segmenter_client.shutdown()
|
||||
logger.info("Segmenter process shut down! See you!")
|
||||
logger.success("Segmenter process shut down! See you!")
|
||||
|
||||
|
|
|
@ -175,6 +175,7 @@ class StepperProcess(multiprocessing.Process):
|
|||
|
||||
def __init__(self, event):
|
||||
super(StepperProcess, self).__init__()
|
||||
logger.info("Initialising the stepper process")
|
||||
|
||||
self.stop_event = event
|
||||
|
||||
|
@ -244,7 +245,7 @@ class StepperProcess(multiprocessing.Process):
|
|||
logger.error(f"{self.stepper_type} is what was supplied")
|
||||
return
|
||||
|
||||
logger.debug(f"Stepper initialisation is over")
|
||||
logger.info(f"Stepper initialisation is over")
|
||||
|
||||
def treat_command(self):
|
||||
command = ""
|
||||
|
@ -495,6 +496,8 @@ class StepperProcess(multiprocessing.Process):
|
|||
self.actuator_client.client.publish("status/pump", '{"status":"Ready"}')
|
||||
# Publish the status "Ready" to via MQTT to Node-RED
|
||||
self.actuator_client.client.publish("status/focus", '{"status":"Ready"}')
|
||||
|
||||
logger.success("Stepper is READY!")
|
||||
while not self.stop_event.is_set():
|
||||
# check if a new message has been received
|
||||
self.treat_command()
|
||||
|
@ -515,7 +518,7 @@ class StepperProcess(multiprocessing.Process):
|
|||
self.pump_stepper.shutdown()
|
||||
self.focus_stepper.shutdown()
|
||||
self.actuator_client.shutdown()
|
||||
logger.info("Stepper process shut down! See you!")
|
||||
logger.success("Stepper process shut down! See you!")
|
||||
|
||||
|
||||
# This is called if this script is launched directly
|
||||
|
|
Loading…
Reference in a new issue