def importPlateAction(*args, **kwargs): print "Welcome to importPlateAction. Live hot plate importing action. \nLadies and gentlemen here are your **kwargs:" if not kwargs: print "Problem! the dancing kwargs are missing" return False latest = kwargs['publishes'][-1] inputPath=None; outputPath=None; start=10; end=20 inputValues=None; sampleFile=None #use hard coded defaults as a fallback workingValues=PROJECT_DEFAULTS #search for project defaults project = conn.getProject( mavisEntity['project'] ) if project and project.has_key('fields'): if project['fields'].has_key('defaults'): print "found defaults" print project['fields']['defaults']['plates'] if project['fields']['defaults'] and project['fields']['defaults'].has_key('plates'): workingValues=project['fields']['defaults']['plates'] print "setWorkingValues" print kwargs['publishes'][-1]['path'] sampleFile='' try: outputPath = kwargs['publishes'][-1]['path'] start = kwargs['publishArgs']['sfrm'] end = kwargs['publishArgs']['efrm'] srcPath = kwargs['publishArgs']['source'] # inputValues = kwargs['fields']['originalMetadata'] fileList = sorted([x for x in os.listdir(srcPath) if os.path.isfile(os.path.join(srcPath, x))]) print fileList sampleFile = os.path.join(srcPath, fileList[ int(len(fileList)/2)-1 ] ) print "sampleFile %s " %sampleFile if not inputValues: #we have nothing for information on the incoming plate #'input': {u'colorspace': u'Cineon', u'inX': 1920, u'inY': 1080, u'inPixelAspect': 2.3999999999999999, u'inFilter': 0, u'inCDL': 0} #is the data['sfrm'] the same as the plate ? if not end or end == "null": end=int(start)+len(fileList) inputValues = imageHeaderInfo.imageHeader(sampleFile) updateDict = {} # <- kwargs['name'] #update the mavis plate entity with metadata values updateDict['originalMetadata']=inputValues #save this metadata out to mavis? #conn.put(kwargs['path'], {'data':updateDict}) except Exception, e: print "ERROR: mavis entity has no input and working keys" print e exc_type, exc_value, exc_traceback = sys.exc_info() traceback.print_tb(exc_traceback, file=sys.stdout)
def importPlateAction(*args, **kwargs): print "Welcome to importPlateAction. Live hot plate importing action. \nLadies and gentlemen here are your **kwargs:" if not kwargs: print "Problem! the dancing kwargs are missing" return False for kay,val in kwargs.iteritems(): if not kay in ['publishes','activity', 'entityType']: print kay, val latest = kwargs['publishes'][-1] print latest inputPath=None; outputPath=None; start=10; end=20 inputValues=None; sampleFile=None workingValues=PROJECT_DEFAULTS try: #inputPath = kwargs['source'] outputPath = kwargs['publishes'][-1]['path'] #use values from args rather than ones in database !!!*** investigate this ***** start = kwargs['publishArgs']['sfrm'] end = kwargs['publishArgs']['efrm'] srcPath =kwargs['publishArgs']['source'] inputValues = kwargs['data']['originalMetadata'] if not inputValues: #we have nothing for information on the incoming plate #'input': {u'colorspace': u'Cineon', u'inX': 1920, u'inY': 1080, u'inPixelAspect': 2.3999999999999999, u'inFilter': 0, u'inCDL': 0} #is the data['sfrm'] the same as the plate ? fileList =sorted([x for x in os.listdir(srcPath) if os.path.isfile(os.path.join(srcPath, x))]) if not end or end == "null": end=int(start)+len(fileList) sampleFile = os.path.join(srcPath, fileList[ int(len(fileList)/2)-1 ] ) print "sampleFile %s " %sampleFile inputValues = imageHeaderInfo.imageHeader(sampleFile) print "header values" print inputValues updateDict = kwargs['data'] #update the mavis plate entity with metadata values updateDict['originalMetadata']=inputValues #conn.put(kwargs['path'], {'data':updateDict}) #project defaults hard coded for now workingValues = PROJECT_DEFAULTS except Exception, e: print "ERROR: mavis entity has no input and working keys" print e exc_type, exc_value, exc_traceback = sys.exc_info() traceback.print_tb(exc_traceback, file=sys.stdout)