From 9baa3e1498bdd8fedd669b9346b03b6454fd9429 Mon Sep 17 00:00:00 2001 From: Dominik Wild Date: Sat, 4 Mar 2023 12:14:56 +0100 Subject: [PATCH] replaced pkg_resources with importlib.resources This fixes a strange bug in bleak: https://github.com/hbldh/bleak/issues/1132 --- pycycling/sterzo.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pycycling/sterzo.py b/pycycling/sterzo.py index d279083..9ffcdb9 100644 --- a/pycycling/sterzo.py +++ b/pycycling/sterzo.py @@ -1,6 +1,6 @@ import asyncio import struct -import pkg_resources +import importlib.resources sterzo_measurement_id = '347b0030-7635-408b-8918-8ff3949ce592' sterzo_control_point_id = '347b0031-7635-408b-8918-8ff3949ce592' @@ -22,7 +22,7 @@ async def enable_steering_measurement_notifications(self): await self._activate_steering_measurements() async def _activate_steering_measurements(self): - with pkg_resources.resource_stream(__name__, 'data/sterzo-challenge-codes.dat') as fp: + with importlib.resources.files(__package__).joinpath('data/sterzo-challenge-codes.dat').open('rb') as fp: fp.seek(self._latest_challenge * 2, 1) code_1 = int.from_bytes(fp.read(1), 'little') code_2 = int.from_bytes(fp.read(1), 'little')