psychopy / psychopy

For running psychology and neuroscience experiments
http://www.psychopy.org
GNU General Public License v3.0
1.67k stars 902 forks source link

Error in tracker.runSetupProcedure() with possible solution #1213

Closed farkau closed 7 years ago

farkau commented 8 years ago

Short version:

Problem: raise errorReply at https://github.com/psychopy/psychopy/blob/master/psychopy/iohub/client/init.py#L1181

Solution: raise Exception(errorReply)

Long version:

Due to an error TypeError: exceptions must be old-style classes or derived from BaseException, not str (see details below) my experiment crashes.

Since time at the eye tracker is rare, I couldn't reproduce it with bare code. Primary it appears after I exit the tracker setup procedure (runSetupProcedure) after the validation pressing "Esc". The calibration and validation I start from the Psychopy-menu and not from the Eyetracker-PC. I use an Eyelink 1000. The only thing I do directly at the Eyetracking-PC is activating the "auto trigger" from calibration and validation.

Regarding http://stackoverflow.com/questions/11497234/typeerrorexceptions-must-be-old-style-classes-or-derived-from-baseexception-no I changed the "problematic" code at https://github.com/psychopy/psychopy/blob/master/psychopy/iohub/client/init.py#L1181 to raise Exception(errorReply) and the error didn't appear anymore.

Since I can't do further testing I don't dare a pull request.

ERROR


timeout('timed out',)
['  File "/usr/lib/python2.7/dist-packages/psychopy/iohub/net.py", line 78, in receive\n    data, address = self.sock.recvfrom(self._rcvBufferLength)\n']
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/home/my/experiment.py in <module>()
    307 # ==================================================================== #
    308 ## do the eyetracker setup (initial calibration and validation) ##
--> 309 tracker.runSetupProcedure()
    310 
    311 # ==================================================================== #

/usr/lib/python2.7/dist-packages/psychopy/iohub/client/__init__.pyc in __call__(self, *args, **kwargs)
     56 
     57     def __call__(self, *args,**kwargs):
---> 58         r = self.sendToHub(('EXP_DEVICE','DEV_RPC',self.device_class,self.method_name,args,kwargs))
     59         r=r[1:]
     60         if len(r)==1:

/usr/lib/python2.7/dist-packages/psychopy/iohub/client/__init__.pyc in _sendToHubServer(self, ioHubMessage)
   1179         errorReply=self._isErrorReply(result)
   1180         if errorReply:
-> 1181             raise errorReply
   1182 
   1183         #Otherwise return the result

TypeError: exceptions must be old-style classes or derived from BaseException, not str

Code

import psychopy.iohub as iohub

iohub_tracker_class_path = 'eyetracker.hw.sr_research.eyelink.EyeTracker'
eyetracker_config = dict()
eyetracker_config['name'] = 'tracker'
eyetracker_config['model_name'] = 'EYELINK 1000 DESKTOP'
eyetracker_config['runtime_settings'] = dict(sampling_rate=1000,
                                             track_eyes='LEFT')

io = iohub.launchHubServer(**{iohub_tracker_class_path: eyetracker_config})
tracker  = io.devices.tracker
tracker.runSetupProcedure()
hoechenberger commented 7 years ago

Hi @farkau, this change looks pretty straightforward and safe to me. You're welcome to file a pull request any time!