How to use the psychopy.iohub.errors.print2err function in psychopy

To help you get started, we’ve selected a few psychopy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github psychopy / psychopy / psychopy / iohub / devices / eyetracker / hw / sr_research / eyelink / eyetracker.py View on Github external
track_eyes = 'LEFT'
            elif track_eyes in ['BOTH', EyeTrackerConstants.getName(EyeTrackerConstants.BINOCULAR)]:
                track_eyes = 'BOTH'
            else:
                print2err(
                    '** Warning: UNKNOWN EYE CONSTANT, SETTING EYE TO TRACK TO RIGHT. UNKNOWN EYE CONSTANT: ',
                    track_eyes)
                track_eyes = 'RIGHT'

            srate = self._getSamplingRate()

            self._eyelink.sendCommand('lock_active_eye = NO')
            if track_eyes == 'BOTH':
                if self._eyelink.getTrackerVersion() == 3:
                    if srate >= 1000:
                        print2err(
                            'ERROR: setEyesToTrack: EyeLink can not record binocularly over 500 hz.')
                        return EyeTrackerConstants.EYETRACKER_ERROR
                    else:
                        trackerVersion = self._eyelink.getTrackerVersionString().strip()
                        trackerVersion = trackerVersion.split(' ')
                        tv = float(trackerVersion[len(trackerVersion) - 1])
                        if tv <= 3:
                            if srate > 500:
                                print2err(
                                    'ERROR: setEyesToTrack: Selected sample rate is not supported in binocular mode')
                                return EyeTrackerConstants.EYETRACKER_ERROR
                            else:
                                self._eyelink.sendCommand(
                                    'binocular_enabled = YES')
                                return EyeTrackerConstants.EYETRACKER_OK
                        else:
github psychopy / psychopy / psychopy / iohub / devices / eyetracker / hw / sr_research / eyelink / eyetracker.py View on Github external
'ERROR: setEyesToTrack: Selected sample rate is not supported in binocular mode')
                                return EyeTrackerConstants.EYETRACKER_ERROR
                            else:
                                self._eyelink.sendCommand(
                                    'binocular_enabled = YES')
                                return EyeTrackerConstants.EYETRACKER_OK
                        else:
                            rts = []
                            modes = self._readResultFromTracker(
                                'read_mode_list')
                            if modes is None or modes.strip() == 'Unknown Variable Name':
                                print2err(
                                    'ERROR: setEyesToTrack: Failed to get supported modes. ')
                                return EyeTrackerConstants.EYETRACKER_ERROR
                            modes = modes.strip().split()
                            print2err('EL Modes: ', modes)
                            for x in modes:
                                if x[-1] == 'B':
                                    x = int(x.replace('B', ' ').strip())
                                    rts.append(x)
                            print2err('EL srate: ', srate)
                            print2err('EL rts: ', rts)
                            if srate in rts:
                                self._eyelink.sendCommand(
                                    'binocular_enabled = YES')
                                return True
                            else:
                                print2err(
                                    'ERROR: setEyesToTrack: Selected sample rate is not supported!')
                                return EyeTrackerConstants.EYETRACKER_ERROR
            else:
                self._eyelink.sendCommand('binocular_enabled = NO')
github psychopy / psychopy / psychopy / iohub / devices / eyetracker / hw / lc_technologies / eyegaze / eyetracker.py View on Github external
if enable is True and not self.isConnected():
                    self._eyegaze_control = pEyeGaze.initializeEyeGazeDevice(
                        self._display_device, self.getConfiguration())
                    if self._eyegaze_control is None:
                        print2err(
                            'Could not connect to EyeGaze. Exiting app..')
                        sys.exit(0)
                    if self._eyegaze_control:
                        return True
                    return False
                elif enable is False and self.isConnected():
                    result = pEyeGaze.EgExit(byref(self._eyegaze_control))
                    self._eyegaze_control = None
                    return False
            else:
                return print2err(
                    'INVALID_METHOD_ARGUMENT_VALUE. ',
                    'EyeTracker.setConnectionState: ',
                    enable)
        except Exception as e:
            # ("IOHUB_DEVICE_EXCEPTION",error_message="An unhandled exception occurred on the ioHub Server Process.",method="EyeTracker.setConnectionState",arguement='enable', value=enable, error=e)
            return printExceptionDetailsToStdErr()
github psychopy / psychopy / psychopy / iohub / devices / eyetracker / hw / sr_research / eyelink / eyetracker.py View on Github external
srate = self._getSamplingRate()

            self._eyelink.sendCommand('lock_active_eye = NO')
            if track_eyes == 'BOTH':
                if self._eyelink.getTrackerVersion() == 3:
                    if srate >= 1000:
                        print2err(
                            'ERROR: setEyesToTrack: EyeLink can not record binocularly over 500 hz.')
                        return EyeTrackerConstants.EYETRACKER_ERROR
                    else:
                        trackerVersion = self._eyelink.getTrackerVersionString().strip()
                        trackerVersion = trackerVersion.split(' ')
                        tv = float(trackerVersion[len(trackerVersion) - 1])
                        if tv <= 3:
                            if srate > 500:
                                print2err(
                                    'ERROR: setEyesToTrack: Selected sample rate is not supported in binocular mode')
                                return EyeTrackerConstants.EYETRACKER_ERROR
                            else:
                                self._eyelink.sendCommand(
                                    'binocular_enabled = YES')
                                return EyeTrackerConstants.EYETRACKER_OK
                        else:
                            rts = []
                            modes = self._readResultFromTracker(
                                'read_mode_list')
                            if modes is None or modes.strip() == 'Unknown Variable Name':
                                print2err(
                                    'ERROR: setEyesToTrack: Failed to get supported modes. ')
                                return EyeTrackerConstants.EYETRACKER_ERROR
                            modes = modes.strip().split()
                            print2err('EL Modes: ', modes)
github psychopy / psychopy / psychopy / iohub / devices / eyetracker / hw / lc_technologies / eyegaze / eyetracker.py View on Github external
r = pEyeGaze.EgGetConfig(
                        byref(
                            self._eyegaze_control),
                        byref(egConfig),
                        sizeof(egConfig))
                    rdict = None
                    if r == 0:
                        rdict = {
                            'iNVis': egConfig.iNVis,
                            'bEyefollower': egConfig.bEyefollower}

                    egConfig = None
                    return rdict
                else:
                    print2err(
                        'WARNING: EyeGaze command not handled: {0} = {1}.'.format())
        except Exception as e:
            return printExceptionDetailsToStdErr()  # ("IOHUB_DEVICE_EXCEPTION",
            #error_message="An unhandled exception occurred on the ioHub Server Process.",
github psychopy / psychopy / psychopy / iohub / devices / eyetracker / hw / sr_research / eyelink / eyetracker.py View on Github external
'file_sample_data = GAZE, GAZERES, HREF , PUPIL , AREA ,STATUS, BUTTON, INPUT')

            # set link data
            eyelink.sendCommand(
                'link_event_filter = LEFT, RIGHT, FIXATION, SACCADE , BLINK, BUTTON, MESSAGE, INPUT')
            eyelink.sendCommand(
                'link_event_data = GAZE, GAZERES, HREF , AREA, VELOCITY, STATUS')

            if eyelink_sw_ver >= 4:
                eyelink.sendCommand(
                    'link_sample_data = GAZE, GAZERES, HREF , PUPIL , AREA ,STATUS, BUTTON, INPUT , HTARGET')
            else:
                eyelink.sendCommand(
                    'link_sample_data = GAZE, GAZERES, HREF , PUPIL , AREA ,STATUS, BUTTON, INPUT')
        except Exception:
            print2err('EYELINK Error during _eyelinkSetLinkAndFileContents:')
            printExceptionDetailsToStdErr()
            return EyeTrackerConstants.EYETRACKER_ERROR
github psychopy / psychopy / psychopy / iohub / devices / eyetracker / hw / sr_research / eyelink / eyetracker.py View on Github external
elif enable is False and self._eyelink.isConnected():
                    self._eyelink.setOfflineMode()

                    if self._active_edf_file:
                        self._eyelink.closeDataFile()
                        # receive(scr,dest)
                        self._eyelink.receiveDataFile(
                            self._host_edf_name + '.EDF',
                            os.path.join(
                                self._local_edf_dir,
                                self._active_edf_file))
                    self._eyelink.close()
                    EyeTracker._active_edf_file = None
                    return EyeTrackerConstants.EYETRACKER_OK
            else:
                print2err('INVALID_METHOD_ARGUMENT_VALUE')
        except Exception as e:
            printExceptionDetailsToStdErr()
github psychopy / psychopy / psychopy / iohub / devices / eyetracker / hw / lc_technologies / eyegaze / eyetracker.py View on Github external
def _eyeTrackerToDisplayCoords(self, eyetracker_point):
    """"""
    try:
        cl, ct, cr, cb = self._display_device.getCoordBounds()
        cw, ch = cr - cl, ct - cb

        dl, dt, dr, db = self._display_device.getBounds()
        dw, dh = dr - dl, db - dt

        gxn, gyn = eyetracker_point[0] / dw, eyetracker_point[1] / dh
        return cl + cw * gxn, cb + ch * (1.0 - gyn)
    except Exception:
        print2err('ERROR occurred during _eyeTrackerToDisplayCoords:')
        printExceptionDetailsToStdErr()
github psychopy / psychopy / psychopy / iohub / devices / eyetracker / hw / sr_research / eyelink / eyeLinkCoreGraphicsIOHubPsychopy.py View on Github external
if mouseDevice:
            eventIDs = []
            for event_class_name in mouseDevice.__class__.EVENT_CLASS_NAMES:
                eventIDs.append(
                    getattr(
                        EventConstants,
                        convertCamelToSnake(
                            event_class_name[
                                :-5],
                            False)))

            self._ioMouse = mouseDevice
            self._ioMouse._addEventListener(self, eventIDs)
        else:
            print2err(
                'Warning: elCG could not connect to Mouse device for events.')
github psychopy / psychopy / psychopy / iohub / devices / eyetracker / hw / sr_research / eyelink / eyetracker.py View on Github external
if srate in rts:
                                self._eyelink.sendCommand(
                                    'binocular_enabled = YES')
                                return True
                            else:
                                print2err(
                                    'ERROR: setEyesToTrack: Selected sample rate is not supported!')
                                return EyeTrackerConstants.EYETRACKER_ERROR
            else:
                self._eyelink.sendCommand('binocular_enabled = NO')
                self._eyelink.sendCommand('current_camera = %s' % (track_eyes))
                self._eyelink.sendCommand('active_eye = %s' % (track_eyes))
                self._eyelink.sendCommand('lock_active_eye = YES')
                return EyeTrackerConstants.EYETRACKER_OK
        except Exception:
            print2err('EYELINK Error during _setEyesToTrack:')
            printExceptionDetailsToStdErr()
            return EyeTrackerConstants.EYETRACKER_ERROR