def compute_hotspot(): print request.content_type bodyArray = [] dvidServer = ns.getDefaultDvidServer() uuid = ns.getDefaultUuid() if request.content_type == 'application/x-www-form-urlencoded': bodyIdStr = request.forms.get('bodyId') bodyArray = [int(bodyId) for bodyId in bodyIdStr.split()] elif request.content_type == 'application/json': print request.json jsonObj = request.json try: jsonschema.validate(jsonObj, json.loads(ns.getSchema('hotspot', 'post'))) except jsonschema.exceptions.ValidationError as inst: print 'Invalid json input' print inst return '<p>Hotspot computation for ' + str( bodyArray) + ' failed.</p>' uuid = jsonObj['uuid'] if jsonObj.has_key('dvid-server'): dvidServer = jsonObj['dvid-server'] bodyArray = jsonObj['bodies'] output = {} config = {'dvid-server': dvidServer, 'uuid': uuid} print '********' print config global qualityAnalyzer for bodyId in bodyArray: # bodyLink = '/api/node/' + uuid + '/skeletons/' + str(bodyId) + '.swc' # print '************', bodyLink result = None try: result = qualityAnalyzer.computeHotSpot(bodyId) except Exception as e: result = {"error": str(e)} return result
def compute_hotspot(): print request.content_type bodyArray = []; dvidServer = ns.getDefaultDvidServer() uuid = ns.getDefaultUuid() if request.content_type == 'application/x-www-form-urlencoded': bodyIdStr = request.forms.get('bodyId') bodyArray = [int(bodyId) for bodyId in bodyIdStr.split()] elif request.content_type == 'application/json': print request.json jsonObj = request.json try: jsonschema.validate(jsonObj, json.loads(ns.getSchema('hotspot', 'post'))) except jsonschema.exceptions.ValidationError as inst: print 'Invalid json input' print inst return '<p>Hotspot computation for ' + str(bodyArray) + ' failed.</p>' uuid = jsonObj['uuid'] if jsonObj.has_key('dvid-server'): dvidServer = jsonObj['dvid-server'] bodyArray = jsonObj['bodies'] output = {} config = {'dvid-server': dvidServer, 'uuid': uuid} print '********' print config global qualityAnalyzer for bodyId in bodyArray: # bodyLink = '/api/node/' + uuid + '/skeletons/' + str(bodyId) + '.swc' # print '************', bodyLink result = None try: result = qualityAnalyzer.computeHotSpot(bodyId) except Exception as e: result = {"error": str(e)} return result
def do_skeletonize(): print request.content_type bodyArray = [] dvidServer = ns.getDefaultDvidServer() uuid = ns.getDefaultUuid() if request.content_type == 'application/x-www-form-urlencoded': bodyIdStr = request.forms.get('bodyId') bodyArray = [int(bodyId) for bodyId in bodyIdStr.split()] elif request.content_type == 'application/json': print request.json jsonObj = request.json try: jsonschema.validate( jsonObj, json.loads(ns.getSchema('skeletonize', 'post'))) except jsonschema.exceptions.ValidationError as inst: print 'Invalid json input' print inst return '<p>Skeletonization for ' + str(bodyArray) + ' failed.</p>' uuid = jsonObj['uuid'] if jsonObj.has_key('dvid-server'): dvidServer = jsonObj['dvid-server'] bodyArray = jsonObj['bodies'] output = {} config = {'dvid-server': dvidServer, 'uuid': uuid} print '********' print config output["swc-list"] = [] output['error'] = [] print dvidServer conn = httplib.HTTPConnection(dvidServer) conn.request("GET", '/api/node/' + uuid + '/skeletons/info') r1 = conn.getresponse() if not r1.status == 200: output['error'].append('Cannot connect to the DVID server.') else: for bodyId in bodyArray: bodyLink = '/api/node/' + uuid + '/skeletons/' + str( bodyId) + '.swc' print '************', bodyLink conn = httplib.HTTPConnection(dvidServer) conn.request("GET", bodyLink) r1 = conn.getresponse() swcAvailable = False if not r1.status == 200: try: skl.Skeletonize(bodyId, 'dvid', config) print 'skeletons retrieved.' except Exception as inst: print str(inst) output['error'].append(str(inst)) else: swcAvailable = True else: swcAvailable = True if swcAvailable: swc = {"id": bodyId, "url": dvidServer + bodyLink} output["swc-list"].append(swc) return json.dumps(output, sort_keys=False)
def do_skeletonize(): print request.content_type bodyArray = []; dvidServer = ns.getDefaultDvidServer() uuid = ns.getDefaultUuid() if request.content_type == 'application/x-www-form-urlencoded': bodyIdStr = request.forms.get('bodyId') bodyArray = [int(bodyId) for bodyId in bodyIdStr.split()] elif request.content_type == 'application/json': print request.json jsonObj = request.json try: jsonschema.validate(jsonObj, json.loads(ns.getSchema('skeletonize', 'post'))) except jsonschema.exceptions.ValidationError as inst: print 'Invalid json input' print inst return '<p>Skeletonization for ' + str(bodyArray) + ' failed.</p>' uuid = jsonObj['uuid'] if jsonObj.has_key('dvid-server'): dvidServer = jsonObj['dvid-server'] bodyArray = jsonObj['bodies'] output = {} config = {'dvid-server': dvidServer, 'uuid': uuid} print '********' print config output["swc-list"] = [] output['error'] = [] print dvidServer conn = httplib.HTTPConnection(dvidServer) conn.request("GET", '/api/node/' + uuid + '/skeletons/info') r1 = conn.getresponse() if not r1.status == 200: output['error'].append('Cannot connect to the DVID server.') else: for bodyId in bodyArray: bodyLink = '/api/node/' + uuid + '/skeletons/' + str(bodyId) + '.swc' print '************', bodyLink conn = httplib.HTTPConnection(dvidServer) conn.request("GET", bodyLink) r1 = conn.getresponse() swcAvailable = False if not r1.status == 200: try: skl.Skeletonize(bodyId, 'dvid', config) print 'skeletons retrieved.' except Exception as inst: print str(inst) output['error'].append(str(inst)) else: swcAvailable = True else: swcAvailable = True if swcAvailable: swc = {"id": bodyId, "url": dvidServer + bodyLink} output["swc-list"].append(swc) return json.dumps(output, sort_keys = False)