From 1e5d111905ae96caf3cd20f5d0eed8fee0b3aaf3 Mon Sep 17 00:00:00 2001 From: TEParsons Date: Wed, 16 Oct 2024 12:53:02 +0100 Subject: [PATCH] ENH: Remove deprecated calls and obsolete workarounds after fixes in new pyxid version --- psychopy_cedrus/base.py | 21 +-------------------- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/psychopy_cedrus/base.py b/psychopy_cedrus/base.py index 0004c15..695e68f 100644 --- a/psychopy_cedrus/base.py +++ b/psychopy_cedrus/base.py @@ -34,8 +34,6 @@ class BaseXidDevice(BaseDevice): ) # all Cedrus devices have a product ID - subclasses should specify what this is productId = None - # keep track of instances, as pyxid2 will not show active instances - instances = [] def __init__(self, index=0): # give error if no device connected @@ -43,9 +41,7 @@ def __init__(self, index=0): raise ConnectionError("No Cedrus device is connected.") # get xid device self.index = index - self.xid = pyxid2.get_xid_device(index) - # store xid instance - BaseXidDevice.instances.append(self) + self.xid = pyxid2.get_xid_devices()[index] # nodes self.nodes = [] # dict of responses by timestamp @@ -54,15 +50,6 @@ def __init__(self, index=0): self._lastTimerReset = None self.resetTimer() - def __del__(self): - # remove instance from record on deletion - i = None - for i, obj in enumerate(self.instances): - if obj is self: - break - if i is not None: - self.instances.pop(i) - @classmethod def resolve(cls, requested): """ @@ -146,12 +133,6 @@ def getAvailableDevices(cls): 'deviceName': profile.device_name, 'index': i, }) - # get_xid_devices only shows unconnected devices, so include connected ones here - for (i, inst) in enumerate(BaseXidDevice.instances): - devices.append({ - 'deviceName': inst.xid.device_name, - 'index': inst.index, - }) return devices diff --git a/pyproject.toml b/pyproject.toml index 7987da5..30ec51d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,7 +29,7 @@ urls.homepage = "https://psychopy.github.io/psychopy-cedrus" urls.changelog = "https://github.com/psychopy/psychopy-cedrus/blob/main/CHANGELOG.txt" dependencies = [ - "pyxid2" + "pyxid2>=1.0.7" ] [project.optional-dependencies]