def _handleExecutionDone(self, execId, data): execution = self._executions.get(execId) # pylint: disable=too-many-nested-blocks try: error = data.get('error') if (error): execution.waiter.set(error) elif (execution.includeResult): response = data.get('response') result = response if (typeCheck.isDict(response) and response.get('storageInfo') and self._storage == 'v3'): result = self._dataAdapter.tryGetDataFromPeerOrStorage( response) if self._storage == 'v3' and typeCheck.isList(result): for node in result: if typeCheck.isDict(node) and getPath( node, 'info.isBigData') is True: nodeResult = self._dataAdapter.tryGetDataFromPeerOrStorage( {"storageInfo": node['info']}) node['result'] = nodeResult execution.waiter.set(result) else: execution.waiter.set(None) except Exception as e: execution.waiter.set(e) finally: self._executions.pop(execId)
def _getPath(self, data, dataPath): if (data and dataPath): newData = getPath(data, dataPath) if (newData == 'DEFAULT'): newData = None else: newData = data return newData
def createMetadata(self, options): nodeName = options.get('nodeName') data = options.get('data') savePaths = options.get('savePaths', []) metadata = dict() objData = dict() objData[nodeName] = data for path in savePaths: try: value = getPath(objData, path) if (value != 'DEFAULT'): meta = self._getMetadata(value) metadata[path] = meta except Exception: pass return metadata
def test_getPath_no_path(): obj = [1, 2, 3, 4, 5, 6, 7, 8, 9] path = 'green.no.such' result = getPath(obj, path) assert result == 'DEFAULT'
def test_getPath_bytes(): sizeBytes = 10 * 1000000 obj = {"prop": [{"bytesArr": bytearray(sizeBytes)}]} path = 'prop.0.bytesArr' result = getPath(obj, path) assert result != 'DEFAULT'
def test_getPath_nested_array_index(): obj = {"green": {"prop": [1, 2, 3, 4, 5, 6, 7, 8, 9]}} path = 'green.prop.5' result = getPath(obj, path) assert typeCheck.isInt(result)
def test_getPath_array(): obj = [1, 2, 3, 4, 5, 6, 7, 8, 9] path = '5' result = getPath(obj, path) assert typeCheck.isInt(result)