From 296775bc2e47883ca4dd0e1e9f0ef76a1288f718 Mon Sep 17 00:00:00 2001 From: Marcus Brown Date: Sun, 20 Oct 2024 19:10:44 +1100 Subject: [PATCH] Fix improper indentation in process_snapshot function - Corrected inconsistent indentation to avoid runtime . - Ensured that all indentation levels match Python's expected format. --- dayglo_detector/dayglo_detector.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/dayglo_detector/dayglo_detector.py b/dayglo_detector/dayglo_detector.py index 793de00..761d04c 100644 --- a/dayglo_detector/dayglo_detector.py +++ b/dayglo_detector/dayglo_detector.py @@ -89,8 +89,8 @@ async def process_snapshot(client, payload): # Attempt to read the saved image with OpenCV image = cv2.imread(temp_image_path) - if image is not None: - rating = calculate_dayglo_rating(image) + if image is not None: + rating = calculate_dayglo_rating(image) print("Dayglo Rating calculated:", rating) await publish_rating(client, rating) else: @@ -118,21 +118,21 @@ async def main(): print("Starting Dayglo Detector...") # Handle command line argument for image file if len(sys.argv) > 1: - image_file = sys.argv[1] - if os.path.exists(image_file): - client = DaygloDetectorMQTTClient("dayglo_detector") - client.set_auth_credentials(MQTT_USERNAME, MQTT_PASSWORD) - await client.connect(MQTT_BROKER, MQTT_PORT, keepalive=60) - print(f"Processing image from file: {image_file}") + image_file = sys.argv[1] + if os.path.exists(image_file): + client = DaygloDetectorMQTTClient("dayglo_detector") + client.set_auth_credentials(MQTT_USERNAME, MQTT_PASSWORD) + await client.connect(MQTT_BROKER, MQTT_PORT, keepalive=60) + print(f"Processing image from file: {image_file}") image = cv2.imread(image_file) if image is not None: rating = calculate_dayglo_rating(image) print("Dayglo Rating calculated from file:", rating) - await publish_rating(client, rating) + await publish_rating(client, rating) + else: + print("Invalid image file provided.") else: - print("Invalid image file provided.") - else: - print(f"File not found: {image_file}") + print(f"File not found: {image_file}") # Set up MQTT client for normal operation client = DaygloDetectorMQTTClient("dayglo_detector")