def_validateProcessorsAndInputsIn(message):validProcessorIRIs=[processor[u'processorIRI']forprocessorinmessage[u'processors']]try:forinputsin(processor[u'inputs']forprocessorinmessage[u'processors']):forinputEnrichmentininputs:ifinputEnrichmentnotinvalidProcessorIRIs:returnFalseexceptExceptionase:log.warning(u'invalid or missing processor inputs list of IRIs; e = %s'%e)returnFalsereturnTruedefvalidateInput(message):""" Checks that message has the minimum initialized attributes to create a new job, and that none of the automatic definitions are pre-initialized (e.g. jobID). """validated=Falseifmessage:log.debug(u'validating input message = %s'%message)try:ifmessage[u'encoding']==u'UTF-8':ifmessage.get(u'completionDate',None):returnFalseifmessage[u'payload'].get(u'aggregatedResults',None):returnFalseiflen(message['processors']):ifmessage['payloadType']:validated=_validateProcessorsAndInputsIn(message)else:log.warning(u'message.payloadType missing or invalid')else:log.warning(u'message.processors empty or null')exceptExceptionase:log.warning(u'message format error; e = %s'%e)log.debug(u'%svalid input message'%(u'in'ifnotvalidatedelseu''))returnvalidated
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.