def analyseBundle(bundleId): bundle = config.bundleTable.find_one({"bundleId": bundleId}) if bundle == None: logging.error("No matching bundle has been found") abort(make_response("No matching bundle has been found", 400)) if bundle["archivePath"] == None: logging.error("The bundle as no directory path") abort(make_response("The bundle as no directory path", 400)) headers = {'content-type': 'application/gzip'} analyseReturn = requests.post(config.uriAnalyser + "/bundle/" + str(bundleId), data=open(bundle["archivePath"], 'r').read(), headers=headers).json() # logging.error("analyzeBundle analyseReturn: " + str(analyseReturn)) pluginIdOffset = config.pluginTable.count() while 1: analyseReturn = requests.get(config.uriAnalyser + "/bundle/" + str(bundleId)).json() if analyseReturn['status'] == "done": bundleData = analyseReturn['datas'] break sleep(1) for index, plugin in enumerate(bundleData['plugins']): pluginId = pluginIdOffset + index currentPlugin = Plugin(pluginId, bundleId) currentPlugin.clips = plugin['clips'] currentPlugin.parameters = plugin['parameters'] currentPlugin.properties = plugin['properties'] currentPlugin.rawIdentifier = plugin['rawIdentifier'] currentPlugin.version = plugin['version'] # Gets Label/ShortLabel and ensures a non-empty value. currentPlugin.label = currentPlugin.getPropValueFromKeys( ('OfxPropLabel', 'OfxPropShortLabel', 'OfxPropLongLabel'), currentPlugin.rawIdentifier) currentPlugin.shortLabel = currentPlugin.getPropValueFromKeys( ('OfxPropShortLabel', 'OfxPropLongLabel'), currentPlugin.label) bundle['plugins'].append(pluginId) config.pluginTable.insert(currentPlugin.__dict__) return mongodoc_jsonify(bundle)
def analyseBundle(bundleId): bundle = config.bundleTable.find_one({"bundleId": bundleId}) if bundle == None: logging.error("No matching bundle has been found") abort(make_response("No matching bundle has been found", 400)) if bundle["archivePath"] == None: logging.error("The bundle as no directory path") abort(make_response("The bundle as no directory path", 400)) headers = {'content-type': 'application/gzip'} analyseReturn = requests.post( config.uriAnalyser+"/bundle/"+str(bundleId), data=open(bundle["archivePath"], 'r').read(), headers=headers).json() # logging.error("analyzeBundle analyseReturn: " + str(analyseReturn)) pluginIdOffset = config.pluginTable.count() while 1: analyseReturn = requests.get(config.uriAnalyser+"/bundle/"+str(bundleId)).json() if analyseReturn['status'] == "done": bundleData = analyseReturn['datas'] break sleep(1) for index, plugin in enumerate(bundleData['plugins']) : pluginId = pluginIdOffset + index currentPlugin = Plugin(pluginId, bundleId) currentPlugin.clips = plugin['clips'] currentPlugin.parameters = plugin['parameters'] currentPlugin.properties = plugin['properties'] currentPlugin.rawIdentifier = plugin['rawIdentifier'] currentPlugin.version = plugin['version'] # Gets Label/ShortLabel and ensures a non-empty value. currentPlugin.label = currentPlugin.getPropValueFromKeys( ('OfxPropLabel', 'OfxPropShortLabel', 'OfxPropLongLabel'), currentPlugin.rawIdentifier) currentPlugin.shortLabel = currentPlugin.getPropValueFromKeys( ('OfxPropShortLabel', 'OfxPropLongLabel'), currentPlugin.label) bundle['plugins'].append(pluginId) config.pluginTable.insert(currentPlugin.__dict__) return mongodoc_jsonify(bundle)