Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions calibrate_pro/core/lut_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -1089,8 +1089,8 @@ def create_native_gamut_lut(
t = max_vals[near_black_mask] / nb.threshold
lift = 1.0 - nb.gamma_lift * (1.0 - t)
rgb_corrected[near_black_mask] *= lift[:, np.newaxis]
except Exception:
pass # OLED compensation is non-critical
except Exception as e:
print(f"[lut_engine] OLED compensation skipped: {e}") # non-critical

# Step 4: Apply per-channel gamma correction
# Encode for panel: output^panel_gamma should produce the corrected linear
Expand Down
10 changes: 6 additions & 4 deletions calibrate_pro/core/vcgt.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,8 @@ def release_fn(h):
if release_fn:
release_fn(hdc)

except Exception:
except Exception as e:
print(f"[vcgt] apply_vcgt_windows failed: {e}")
return False


Expand Down Expand Up @@ -523,8 +524,8 @@ class _DISPLAY_DEVICE(ctypes.Structure):
active_count += 1
adapter_idx += 1

except Exception:
pass
except Exception as e:
print(f"[vcgt] _resolve_display_device_name failed for index {display_index}: {e}")
return ""


Expand Down Expand Up @@ -556,7 +557,8 @@ def get_current_vcgt_windows() -> VCGTTable | None:
finally:
user32.ReleaseDC(None, hdc)

except Exception:
except Exception as e:
print(f"[vcgt] get_current_vcgt_windows failed: {e}")
return None


Expand Down
24 changes: 12 additions & 12 deletions calibrate_pro/hardware/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,8 @@ def detect_all_devices():

native_devices = detect_colorimeters()
devices.extend(native_devices)
except Exception:
pass
except Exception as e:
print(f"[hardware] Native device detection failed: {e}")

# If no native devices, try ArgyllCMS
if not devices:
Expand All @@ -356,8 +356,8 @@ def detect_all_devices():
argyll = ArgyllBackend()
argyll_devices = argyll.detect_devices()
devices.extend(argyll_devices)
except Exception:
pass
except Exception as e:
print(f"[hardware] ArgyllCMS detection failed: {e}")

return devices

Expand All @@ -384,8 +384,8 @@ def auto_connect(prefer_native: bool = True):
driver = native_auto()
if driver:
return driver
except Exception:
pass
except Exception as e:
print(f"[hardware] Native auto-connect failed: {e}")

# Fall back to ArgyllCMS
try:
Expand All @@ -394,26 +394,26 @@ def auto_connect(prefer_native: bool = True):
driver = detect_spectrophotometer()
if driver:
return driver
except Exception:
pass
except Exception as e:
print(f"[hardware] Spectrophotometer detection failed: {e}")

try:
from calibrate_pro.hardware.i1display import detect_i1display

driver = detect_i1display()
if driver:
return driver
except Exception:
pass
except Exception as e:
print(f"[hardware] i1Display detection failed: {e}")

try:
from calibrate_pro.hardware.spyder import detect_spyder

driver = detect_spyder()
if driver:
return driver
except Exception:
pass
except Exception as e:
print(f"[hardware] Spyder detection failed: {e}")

return None

Expand Down
7 changes: 4 additions & 3 deletions calibrate_pro/hardware/argyll_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,8 @@ def disconnect(self) -> bool:
if self.temp_dir and self.temp_dir.exists():
try:
shutil.rmtree(self.temp_dir)
except Exception:
pass
except Exception as e:
print(f"[argyll] Failed to clean temp dir {self.temp_dir}: {e}")
self.temp_dir = None

return True
Expand Down Expand Up @@ -379,7 +379,8 @@ def measure_ambient(self) -> ColorMeasurement | None:
result = self._run_tool("spotread", args, timeout=30)
return self._parse_spotread_output(result.stdout + result.stderr)

except Exception:
except Exception as e:
print(f"[argyll] Ambient measurement failed: {e}")
return None

# =========================================================================
Expand Down
8 changes: 4 additions & 4 deletions calibrate_pro/hardware/hardware_calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,8 @@ def _read_current_state(self) -> CalibrationState:
state.green_black = settings.green_black_level
state.blue_black = settings.blue_black_level
state.color_preset = settings.color_preset
except Exception:
pass
except Exception as e:
print(f"[hardware_cal] Failed to read DDC/CI state: {e}")

return state

Expand Down Expand Up @@ -449,8 +449,8 @@ def _measure_patch(self, r: int, g: int, b: int) -> MeasurementResult | None:
result.L, result.a, result.b = xyz_to_lab(measurement.X, measurement.Y, measurement.Z)

return result
except Exception:
pass
except Exception as e:
print(f"[hardware_cal] White point measurement failed: {e}")

return None

Expand Down
14 changes: 8 additions & 6 deletions calibrate_pro/hardware/i1d3_native.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,8 @@ def open(self, path: bytes = None) -> bool:

return True

except Exception:
except Exception as e:
print(f"[i1d3] Connection failed: {e}")
self._device = None
return False

Expand All @@ -184,8 +185,8 @@ def close(self):
if self._device:
try:
self._device.close()
except Exception:
pass
except Exception as e:
print(f"[i1d3] Error closing device: {e}")
self._device = None

def get_info(self) -> I1D3Info | None:
Expand Down Expand Up @@ -218,7 +219,8 @@ def measure(self, integration_time: float = None) -> I1D3Measurement | None:
result = self._apply_calibration(raw)
return result

except Exception:
except Exception as e:
print(f"[i1d3] Measurement failed: {e}")
return None

# =========================================================================
Expand Down Expand Up @@ -281,8 +283,8 @@ def _get_device_info(self) -> I1D3Info:
serial = ""
try:
serial = self._device.get_serial_number_string() or ""
except Exception:
pass
except Exception as e:
print(f"[i1d3] Could not read serial number: {e}")

return I1D3Info(
product=product.split()[0] if parts else product,
Expand Down
4 changes: 2 additions & 2 deletions calibrate_pro/hardware/i1display.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ def measure_ambient(self) -> ColorMeasurement | None:

except subprocess.TimeoutExpired:
pass
except Exception:
pass
except Exception as e:
print(f"[i1display] Ambient measurement failed: {e}")

return None

Expand Down
25 changes: 14 additions & 11 deletions calibrate_pro/hardware/i1display_native.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ def _read_device_info(self):
if serial and self.device_info:
self.device_info.serial = serial

except Exception:
except Exception as e:
print(f"[i1display_native] Device info read failed, using USB fallback: {e}")
# Use USB info as fallback
if self._usb_info:
self.device_info = DeviceInfo(
Expand Down Expand Up @@ -264,7 +265,8 @@ def _read_calibration_data(self):
dark_offsets=np.zeros(3),
integration_scale=1.0,
)
except Exception:
except Exception as e:
print(f"[i1display_native] Calibration data read failed, using defaults: {e}")
# Use default calibration
self._cal_data = I1CalibrationData(
serial="",
Expand Down Expand Up @@ -315,8 +317,8 @@ def set_integration_time(self, seconds: float) -> bool:
try:
self._send_command(I1Command.SET_INTEGRATION, data)
return True
except Exception:
pass
except Exception as e:
print(f"[i1display_native] Set integration time failed: {e}")
return False

def set_refresh_mode(self, refresh_rate: float) -> bool:
Expand All @@ -334,7 +336,8 @@ def set_refresh_mode(self, refresh_rate: float) -> bool:
data = struct.pack("<H", int(refresh_rate))
self._send_command(I1Command.SET_REFRESH_MODE, data)
return True
except Exception:
except Exception as e:
print(f"[i1display_native] Set refresh mode failed: {e}")
return False

def measure_spot(self) -> ColorMeasurement | None:
Expand Down Expand Up @@ -439,8 +442,8 @@ def measure_ambient(self) -> ColorMeasurement | None:
measurement_mode="ambient",
)

except Exception:
pass
except Exception as e:
print(f"[i1display_native] Ambient measurement failed: {e}")

return None

Expand All @@ -455,8 +458,8 @@ def detect_refresh_rate(self) -> float | None:
# Parse refresh rate (Hz)
rate = struct.unpack("<H", resp[4:6])[0]
return float(rate)
except Exception:
pass
except Exception as e:
print(f"[i1display_native] Refresh rate detection failed: {e}")

return None

Expand All @@ -466,8 +469,8 @@ def set_led(self, color: str = "off"):
code = colors.get(color.lower(), 0)
try:
self._send_command(I1Command.SET_LED, bytes([code]))
except Exception:
pass
except Exception as e:
print(f"[i1display_native] LED control failed: {e}")


def detect_i1display_native() -> I1DisplayNative | None:
Expand Down
15 changes: 8 additions & 7 deletions calibrate_pro/hardware/measurement.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ def _create_display_window(self):
self._tk_canvas.pack(fill=tk.BOTH, expand=True)
self._tk_root.update()

except Exception:
except Exception as e:
print(f"[measurement] Display window creation failed: {e}")
self._tk_root = None
self._tk_canvas = None

Expand All @@ -170,8 +171,8 @@ def _get_display_geometry(self) -> tuple[int, int, int, int] | None:
if self.config.display_index < len(displays):
d = displays[self.config.display_index]
return (d.position_x, d.position_y, d.width, d.height)
except Exception:
pass
except Exception as e:
print(f"[measurement] Display geometry detection failed: {e}")
return None

def _measure_argyll(self) -> tuple[float, float, float]:
Expand Down Expand Up @@ -222,16 +223,16 @@ def close(self):
if self._tk_root is not None:
try:
self._tk_root.destroy()
except Exception:
pass
except Exception as e:
print(f"[measurement] Error destroying display window: {e}")
self._tk_root = None
self._tk_canvas = None

if self._argyll_backend is not None:
try:
self._argyll_backend.disconnect()
except Exception:
pass
except Exception as e:
print(f"[measurement] Error disconnecting argyll backend: {e}")

def __enter__(self):
self.initialize()
Expand Down
4 changes: 2 additions & 2 deletions calibrate_pro/hardware/spyder.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,8 @@ def measure_ambient(self) -> ColorMeasurement | None:
if result.returncode == 0:
return self._parse_ambient_output(result.stdout)

except Exception:
pass
except Exception as e:
print(f"[spyder] Ambient measurement failed: {e}")

return None

Expand Down
Loading
Loading