def handleStartSolveMissingLink(wfile, request, session): productionId=int(session["production_id"]) production = indexer.getProduction(productionId) fileId=int(request["file_id"]) elementId=int(request["element_id"]) #determine original file if from elementid elementDetails = indexer.getElement(elementId) elementType=elementDetails[indexer.INDEX_ELEMENT_TYPE] orFileId = elementDetails[indexer.INDEX_ELEMENT_FILE_ID] orFileDetails = indexer.getFile(orFileId) tasks = [] if elementType=='ID': newElementId=fileId newElementDetails=indexer.getElement(newElementId) cl = ChangeIDElement() cl.fileDetails = orFileDetails cl.fileId = orFileId cl.productionDetails = production cl.libraryDetails=indexer.getElement(elementDetails[indexer.INDEX_LIBRARY_ID]) cl.elementDetails=elementDetails cl.newElementName=newElementDetails[indexer.INDEX_ELEMENT_NAME] tasks.append(cl) else: newFileDetails = indexer.getFile(fileId) cl = ChangeLibrary() cl.fileDetails = orFileDetails cl.fileId = orFileId cl.newFileDetails = newFileDetails cl.productionDetails = production cl.libraryDetails = elementDetails tasks.append(cl) session["tasks"]=tasks wfile.write("""[]""".encode())
def handleGetMissingLinkSolutions(wfile, request, session): if "production_id" in request: productionId = int(request["production_id"]) else: productionId = int(session["production_id"]) elementId = int(request["element_id"]) elementDetails = indexer.getElement(elementId) result = [] if elementDetails[indexer.INDEX_ELEMENT_TYPE] == 'LI': solutions = indexer.queryMissingLinkSolutions(productionId, elementId) for solution in solutions: result.append(solutionToObject(solution)) elif elementDetails[indexer.INDEX_ELEMENT_TYPE] == 'ID': solutions = indexer.queryMissingLinkSolutionsID( productionId, elementId) for solution in solutions: result.append(solutionIDToObject(solution)) elif elementDetails[indexer.INDEX_ELEMENT_TYPE] == 'IM': files = indexer.getProductionFiles(productionId) sfn = os.path.basename( elementDetails[indexer.INDEX_ELEMENT_LI_NAME].replace("\\", "/")) extension = os.path.splitext(sfn) still = [] for f in files: fname = f[indexer.INDEX_FILE_NAME] if fname == sfn: result.append(solutionToObject(f, 1.0)) else: if not fname.endswith(".blend"): still.append(f) files = still still = [] for f in files: fname = f[indexer.INDEX_FILE_NAME] if fname.startswith(extension[0]): result.append(solutionToObject(f, 0.75)) else: still.append(f) files = still still = [] for f in files: fname = f[indexer.INDEX_FILE_NAME] if fname.endswith(extension[1]): result.append(solutionToObject(f, 0.5)) else: still.append(f) for f in still: result.append(solutionToObject(f, 0.25)) wfile.write(json.dumps(result).encode())
def handleGetMissingLinkSolutions(wfile, request, session): if "production_id" in request: productionId=int(request["production_id"]) else: productionId=int(session["production_id"]) elementId=int(request["element_id"]) elementDetails = indexer.getElement(elementId) result = [] if elementDetails[indexer.INDEX_ELEMENT_TYPE] == 'LI': solutions = indexer.queryMissingLinkSolutions(productionId, elementId) for solution in solutions: result.append(solutionToObject(solution)) elif elementDetails[indexer.INDEX_ELEMENT_TYPE] == 'ID': solutions = indexer.queryMissingLinkSolutionsID(productionId, elementId) for solution in solutions: result.append(solutionIDToObject(solution)) elif elementDetails[indexer.INDEX_ELEMENT_TYPE] == 'IM': files = indexer.getProductionFiles(productionId) sfn = os.path.basename(elementDetails[indexer.INDEX_ELEMENT_LI_NAME].replace("\\", "/")) extension = os.path.splitext(sfn) still = [] for f in files: fname = f[indexer.INDEX_FILE_NAME] if fname == sfn: result.append(solutionToObject(f, 1.0)) else: if not fname.endswith(".blend"): still.append(f) files = still still=[] for f in files: fname = f[indexer.INDEX_FILE_NAME] if fname.startswith(extension[0]): result.append(solutionToObject(f, 0.75)) else: still.append(f) files = still still=[] for f in files: fname = f[indexer.INDEX_FILE_NAME] if fname.endswith(extension[1]): result.append(solutionToObject(f, 0.5)) else: still.append(f) for f in still: result.append(solutionToObject(f, 0.25)) wfile.write(json.dumps(result).encode())
def handleStartSolveMissingLink(wfile, request, session): productionId = int(session["production_id"]) production = indexer.getProduction(productionId) fileId = int(request["file_id"]) elementId = int(request["element_id"]) #determine original file if from elementid elementDetails = indexer.getElement(elementId) elementType = elementDetails[indexer.INDEX_ELEMENT_TYPE] orFileId = elementDetails[indexer.INDEX_ELEMENT_FILE_ID] orFileDetails = indexer.getFile(orFileId) tasks = [] if elementType == 'ID': newElementId = fileId newElementDetails = indexer.getElement(newElementId) cl = ChangeIDElement() cl.fileDetails = orFileDetails cl.fileId = orFileId cl.productionDetails = production cl.libraryDetails = indexer.getElement( elementDetails[indexer.INDEX_LIBRARY_ID]) cl.elementDetails = elementDetails cl.newElementName = newElementDetails[indexer.INDEX_ELEMENT_NAME] tasks.append(cl) else: newFileDetails = indexer.getFile(fileId) cl = ChangeLibrary() cl.fileDetails = orFileDetails cl.fileId = orFileId cl.newFileDetails = newFileDetails cl.productionDetails = production cl.libraryDetails = elementDetails tasks.append(cl) session["tasks"] = tasks wfile.write("""[]""".encode())