From a0d9162e9a3a528ae470eb40d55defc6f3c99dc4 Mon Sep 17 00:00:00 2001 From: vshekar1 Date: Mon, 15 Jan 2024 14:43:34 -0500 Subject: [PATCH 1/2] Return empty image if eiger monitor is empty --- gui/albula/controller.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/gui/albula/controller.py b/gui/albula/controller.py index 04826611..5eade98d 100644 --- a/gui/albula/controller.py +++ b/gui/albula/controller.py @@ -156,14 +156,18 @@ def set_current_monitor_image(self): self.albulaSubFrame.loadImage(dimage) def get_eiger_monitor_image(self): # for EIGER1 - urlData = "http://{}/monitor/api/{}/images/monitor".format( - self.ip, self.api_version - ) - replyData = requests.get(urlData) - img_bytes = BytesIO(replyData.content) - img = Image.open(img_bytes) - array = numpy.array(img) - array[array == 65535] = 0 + try: + urlData = "http://{}/monitor/api/{}/images/monitor".format( + self.ip, self.api_version + ) + replyData = requests.get(urlData) + img_bytes = BytesIO(replyData.content) + img = Image.open(img_bytes) + array = numpy.array(img) + array[array == 65535] = 0 + except: + logger.error("Could not get image from EIGER") + array = numpy.zeros((3110, 3269)) return array From 41279bfff3eb5b22c1ca34e5167af304ec82dc0d Mon Sep 17 00:00:00 2001 From: Shekar V Date: Sat, 10 Feb 2024 16:18:39 -0500 Subject: [PATCH 2/2] Added specific exception to get_eiger_monitor_image --- gui/albula/controller.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gui/albula/controller.py b/gui/albula/controller.py index 5eade98d..ba67f800 100644 --- a/gui/albula/controller.py +++ b/gui/albula/controller.py @@ -11,7 +11,7 @@ from epics import PV from enum import Enum import platform -from PIL import Image +from PIL import Image, UnidentifiedImageError from io import BytesIO import os @@ -165,7 +165,7 @@ def get_eiger_monitor_image(self): # for EIGER1 img = Image.open(img_bytes) array = numpy.array(img) array[array == 65535] = 0 - except: + except UnidentifiedImageError: logger.error("Could not get image from EIGER") array = numpy.zeros((3110, 3269))