本文整理汇总了Python中psychopy.iohub.printExceptionDetailsToStdErr函数的典型用法代码示例。如果您正苦于以下问题:Python printExceptionDetailsToStdErr函数的具体用法?Python printExceptionDetailsToStdErr怎么用?Python printExceptionDetailsToStdErr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了printExceptionDetailsToStdErr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: shutdown
def shutdown(self):
try:
self._running=False
if Computer.system=='linux2':
if self._hookManager:
self._hookManager.cancel()
while len(self.deviceMonitors) > 0:
m=self.deviceMonitors.pop(0)
m.running=False
if self.eventBuffer:
self.clearEventBuffer()
try:
self.closeDataStoreFile()
except:
pass
while len(self.devices) > 0:
d=self.devices.pop(0)
try:
if d is not None:
d._close()
except:
pass
gevent.sleep()
except:
print2err("Error in ioSever.shutdown():")
printExceptionDetailsToStdErr()
示例2: checkIfSessionCodeExists
def checkIfSessionCodeExists(self,sessionCode):
try:
if self.iohub.emrt_file:
return self.iohub.emrt_file.checkIfSessionCodeExists(sessionCode)
return False
except:
printExceptionDetailsToStdErr()
示例3: initConditionVariableTable
def initConditionVariableTable(
self, experiment_id, session_id, np_dtype):
expcv_table = None
expcv_node = self.emrtFile.root.data_collection.condition_variables
exp_session = [('EXPERIMENT_ID','i4'),('SESSION_ID','i4')]
exp_session.extend(np_dtype)
np_dtype = []
for npctype in exp_session:
if isinstance(npctype[0], str):
nv = [str(npctype[0]),]
nv.extend(npctype[1:])
np_dtype.append(tuple(nv))
else:
np_dtype.append(npctype)
self._EXP_COND_DTYPE = np.dtype(np_dtype)
try:
expCondTableName = "EXP_CV_%d"%(experiment_id)
experimentConditionVariableTable = getattr(self.emrtFile.root.data_collection.condition_variables, _f_get_child)(expCondTableName)
self.TABLES['EXP_CV'] = experimentConditionVariableTable
except NoSuchNodeError as nsne:
try:
experimentConditionVariableTable = getattr(self.emrtFile, create_table)(self.emrtFile.root.data_collection.condition_variables, expCondTableName, self._EXP_COND_DTYPE, title='Condition Variable Values for Experiment ID %d' % (experiment_id))
self.TABLES['EXP_CV'] = experimentConditionVariableTable
self.emrtFile.flush()
except Exception:
printExceptionDetailsToStdErr()
return False
except Exception:
print2err(
'Error getting expcv_table for experiment %d, table name: %s' %
(experiment_id, expCondTableName))
printExceptionDetailsToStdErr()
return False
self._activeRunTimeConditionVariableTable = expcv_table
return True
示例4: _processDeviceEventIteration
def _processDeviceEventIteration(self):
for device in self.devices:
try:
events = device._getNativeEventBuffer()
while len(events) > 0:
evt = events.popleft()
e = device._getIOHubEventObject(evt)
if e is not None:
for l in device._getEventListeners(e[DeviceEvent.EVENT_TYPE_ID_INDEX]):
l._handleEvent(e)
filtered_events = []
for filter in device._filters.values():
filtered_events.extend(filter._removeOutputEvents())
for i in range(len(filtered_events)):
e = filtered_events[i]
for l in device._getEventListeners(e[DeviceEvent.EVENT_TYPE_ID_INDEX]):
l._handleEvent(e)
except:
printExceptionDetailsToStdErr()
print2err("Error in processDeviceEvents: ", device, " : ", len(events), " : ", e)
print2err("Event type ID: ",e[DeviceEvent.EVENT_TYPE_ID_INDEX], " : " , EventConstants.getName(e[DeviceEvent.EVENT_TYPE_ID_INDEX]))
print2err("--------------------------------------")
示例5: _handleEvents
def _handleEvents(self, events):
try:
if self.checkForExperimentAndSessionIDs(len(events)) is False:
return False
event = events[0]
etype = event[DeviceEvent.EVENT_TYPE_ID_INDEX]
eventClass = EventConstants.getClass(etype)
etable = self.TABLES[eventClass.IOHUB_DATA_TABLE]
np_events = []
for event in events:
event[DeviceEvent.EVENT_EXPERIMENT_ID_INDEX] = self.active_experiment_id
event[DeviceEvent.EVENT_SESSION_ID_INDEX] = self.active_session_id
np_events.append(tuple(event))
np_array = np.array(np_events, dtype=eventClass.NUMPY_DTYPE)
#ioHub.print2err('np_array:',np_array)
etable.append(np_array)
self.bufferedFlush(len(np_events))
except ioHubError as e:
print2err(e)
except Exception:
printExceptionDetailsToStdErr()
示例6: run
def run(rootScriptPathDir,configFilePath):
import tempfile
tdir=tempfile.gettempdir()
cdir,cfile=os.path.split(configFilePath)
if tdir==cdir:
tf=open(configFilePath)
ioHubConfig=json.loads(tf.read())
tf.close()
os.remove(configFilePath)
else:
ioHubConfig=load(file(configFilePath,'r'), Loader=Loader)
hub_defaults_config=load(file(os.path.join(iohub.IO_HUB_DIRECTORY,'default_config.yaml'),'r'), Loader=Loader)
updateDict(ioHubConfig,hub_defaults_config)
try:
s = ioServer(rootScriptPathDir, ioHubConfig)
except Exception,e:
printExceptionDetailsToStdErr()
sys.stdout.flush()
try:
s.shutdown()
except:
pass
return -1
示例7: __init__
def __init__(self, rootScriptPathDir, config=None):
self._session_id=None
self._experiment_id=None
self.log("Server Time Offset: {0}".format(Computer.globalClock.getLastResetTime()))
self._hookManager=None
self.emrt_file=None
self.config=config
self.devices=[]
self.deviceMonitors=[]
self.sessionInfoDict=None
self.experimentInfoList=None
self.filterLookupByInput={}
self.filterLookupByOutput={}
self.filterLookupByName={}
self._hookDevice=None
ioServer.eventBuffer=deque(maxlen=config.get('global_event_buffer',2048))
self._running=True
# start UDP service
self.udpService=udpServer(self,':%d'%config.get('udp_port',9000))
try:
# initial dataStore setup
if 'data_store' in config and psychopy.iohub._DATA_STORE_AVAILABLE:
experiment_datastore_config=config.get('data_store')
default_datastore_config_path=os.path.join(IO_HUB_DIRECTORY,'datastore','default_datastore.yaml')
#print2err('default_datastore_config_path: ',default_datastore_config_path)
_dslabel,default_datastore_config=load(file(default_datastore_config_path,'r'), Loader=Loader).popitem()
for default_key,default_value in default_datastore_config.iteritems():
if default_key not in experiment_datastore_config:
experiment_datastore_config[default_key]=default_value
if experiment_datastore_config.get('enable', True):
#print2err("Creating ioDataStore....")
resultsFilePath=rootScriptPathDir
self.createDataStoreFile(experiment_datastore_config.get('filename','events')+'.hdf5',resultsFilePath,'a',experiment_datastore_config)
#print2err("Created ioDataStore.")
except:
print2err("Error during ioDataStore creation....")
printExceptionDetailsToStdErr()
#built device list and config from initial yaml config settings
try:
for iodevice in config.get('monitor_devices',()):
for device_class_name,deviceConfig in iodevice.iteritems():
#print2err("======================================================")
#print2err("Started load process for: {0}".format(device_class_name))
self.createNewMonitoredDevice(device_class_name,deviceConfig)
except:
print2err("Error during device creation ....")
printExceptionDetailsToStdErr()
raise ioHubError("Error during device creation ....")
示例8: flush
def flush(self):
try:
if self.emrtFile:
self.emrtFile.flush()
except ClosedFileError:
pass
except:
printExceptionDetailsToStdErr()
示例9: updateDataStoreStructure
def updateDataStoreStructure(self, device_instance, event_class_dict):
dfilter = tables.Filters(
complevel=0,
complib='zlib',
shuffle=False,
fletcher32=False)
for event_cls_name, event_cls in event_class_dict.items():
if event_cls.IOHUB_DATA_TABLE:
event_table_label = event_cls.IOHUB_DATA_TABLE
if event_table_label not in self.TABLES:
try:
self.TABLES[event_table_label] = self.emrtFile.createTable(
self.groupNodeForEvent(event_cls),
self.eventTableLabel2ClassName(event_table_label),
event_cls.NUMPY_DTYPE,
title='%s Data' %
(device_instance.__class__.__name__,
),
filters=dfilter.copy())
self.flush()
except tables.NodeError:
self.TABLES[event_table_label] = self.groupNodeForEvent(event_cls)._f_get_child(self.eventTableLabel2ClassName(event_table_label))
except Exception as e:
print2err('---------------ERROR------------------')
print2err(
'Exception %s in iohub.datastore.updateDataStoreStructure:' %
(e.__class__.__name__))
print2err('\tevent_cls: {0}'.format(event_cls))
print2err(
'\tevent_cls_name: {0}'.format(event_cls_name))
print2err(
'\tevent_table_label: {0}'.format(event_table_label))
print2err(
'\teventTableLabel2ClassName: {0}'.format(
self.eventTableLabel2ClassName(event_table_label)))
print2err(
'\tgroupNodeForEvent(event_cls): {0}'.format(
self.groupNodeForEvent(event_cls)))
print2err('\nException:')
printExceptionDetailsToStdErr()
print2err('--------------------------------------')
if event_table_label in self.TABLES:
self.addClassMapping(event_cls,
self.TABLES[event_table_label])
else:
print2err(
'---- IOHUB.DATASTORE CANNOT ADD CLASS MAPPING ----')
print2err(
'\t** TABLES missing key: {0}'.format(event_table_label))
print2err('\tevent_cls: {0}'.format(event_cls))
print2err('\tevent_cls_name: {0}'.format(event_cls_name))
print2err(
'\teventTableLabel2ClassName: {0}'.format(
self.eventTableLabel2ClassName(event_table_label)))
print2err('----------------------------------------------')
示例10: shutDown
def shutDown(self):
try:
self.disableHighPriority()
self.iohub.shutdown()
self._running=False
self.stop()
except:
print2err("Error in ioSever.shutdown():")
printExceptionDetailsToStdErr()
sys.exit(1)
示例11: log
def log(self,text,level=None):
try:
log_time=currentSec()
exp=self.deviceDict.get('Experiment',None)
if exp and self._session_id and self._experiment_id:
while len(self._logMessageBuffer):
lm=self._logMessageBuffer.popleft()
exp.log(*lm)
exp.log(text,level,log_time)
else:
self._logMessageBuffer.append((text,level,log_time))
except:
printExceptionDetailsToStdErr()
示例12: __init__
def __init__(self,remote_address,sync_state_target):
try:
Greenlet.__init__(self)
self._sync_socket=None
self.initial_sync_interval=0.2
self._remote_address=remote_address
while self._sync_socket is None:
self._sync_socket=ioHubTimeSyncConnection(remote_address)
sleep(1)
self.sync_state_target=proxy(sync_state_target)
except Exception as e:
print2err("** Exception during ioHubTimeGreenSyncManager.__init__: ",self._remote_address)
printExceptionDetailsToStdErr()
示例13: _initializeConditionVariableTable
def _initializeConditionVariableTable(self,experiment_id,np_dtype):
experimentConditionVariableTable=None
self._EXP_COND_DTYPE=N.dtype(np_dtype)
try:
expCondTableName="EXP_CV_%d"%(experiment_id)
experimentConditionVariableTable=self.emrtFile.root.data_collection.condition_variables._f_getChild(expCondTableName)
self.TABLES['EXP_CV']=experimentConditionVariableTable
except NoSuchNodeError, nsne:
try:
experimentConditionVariableTable=self.emrtFile.createTable(self.emrtFile.root.data_collection.condition_variables,expCondTableName,self._EXP_COND_DTYPE,title='Condition Variable Values for Experiment ID %d'%(experiment_id))
self.TABLES['EXP_CV']=experimentConditionVariableTable
self.emrtFile.flush()
except:
printExceptionDetailsToStdErr()
return False
示例14: _handleEvent
def _handleEvent(self, event):
try:
if self.checkForExperimentAndSessionIDs(event) is False:
return False
etype = event[DeviceEvent.EVENT_TYPE_ID_INDEX]
eventClass = EventConstants.getClass(etype)
etable = self.TABLES[eventClass.IOHUB_DATA_TABLE]
event[DeviceEvent.EVENT_EXPERIMENT_ID_INDEX] = self.active_experiment_id
event[DeviceEvent.EVENT_SESSION_ID_INDEX] = self.active_session_id
np_array = np.array([tuple(event), ], dtype=eventClass.NUMPY_DTYPE)
etable.append(np_array)
self.bufferedFlush()
except Exception:
print2err("Error saving event: ", event)
printExceptionDetailsToStdErr()
示例15: handleGetEvents
def handleGetEvents(self,replyTo):
try:
currentEvents=list(self.iohub.eventBuffer)
self.iohub.eventBuffer.clear()
if len(currentEvents)>0:
currentEvents=sorted(currentEvents, key=itemgetter(DeviceEvent.EVENT_HUB_TIME_INDEX))
self.sendResponse(('GET_EVENTS_RESULT',currentEvents),replyTo)
else:
self.sendResponse(('GET_EVENTS_RESULT', None),replyTo)
return True
except Exception, e:
print2err("IOHUB_GET_EVENTS_ERROR")
printExceptionDetailsToStdErr()
self.sendResponse('IOHUB_GET_EVENTS_ERROR', replyTo)
return False