Execute computation of blobs on input eopatch

        :param eopatch: Input eopatch
        :type eopatch: eolearn.core.EOPatch
        :return: EOPatch instance with new key holding the blob image.
        :rtype: eolearn.core.EOPatch
10728
def execute(self, eopatch):
        
        for feature_type, feature_name, new_feature_name in self.feature:
            eopatch[feature_type][new_feature_name] = self._compute_blob(
                eopatch[feature_type][feature_name].astype(np.float64)).astype(np.float32)

        return eopatch
520725
def do_execute(self):
        
        relname = self.resolve_option("name")
        if isinstance(self.input.payload, Instance):
            self.input.payload.dataset.relationname = relname
        else:
            self.input.payload.relationname = relname
        self._output.append(self.input)
        return None
398349
def get(self, bucket: str, key: str) -> bytes:
        
        try:
            response = self.s3_client.get_object(
                Bucket=bucket,
                Key=key
            )
            return response['Body'].read()
        except botocore.exceptions.ClientError as ex:
            if ex.response['Error']['Code'] == "NoSuchKey":
                raise BlobNotFoundError(f"Could not find s3://{bucket}/{key}") from ex
            raise BlobStoreUnknownError(ex)
932287
def execute( self, conn, daoinput, transaction = False ):
        
        binds = {} 
        bindlist=[]
        
        if isinstance(daoinput, dict) and "block_name" in daoinput.keys():
            binds = {"block_name": daoinput["block_name"]}
            r = self.dbi.processData(self.sql_sel, binds, conn, False)
            bfile = self.format(r)
            bfile_list = []
            for f in bfile:
                bfile_list.append(f[0])           
            if "child_parent_id_list" in daoinput.keys():
                files = []
                for i in daoinput["child_parent_id_list"]:
                    files.append(i[0])
                if set(files)-set(bfile_list):
                    dbsExceptionHandler('dbsException-invalid-input2', "Files required in the same block for FileParent/insert2 dao.", self.logger.exception) 
            else:
                dbsExceptionHandler('dbsException-invalid-input2', "child_parent_id_list required for FileParent/insert2 dao.", self.logger.exception) 
        else:
            dbsExceptionHandler('dbsException-invalid-input2', "Block_name required in the same block for FileParent/insert2 dao.", self.logger.exception)
        binds = {} 
        for pf in daoinput["child_parent_id_list"]:
            binds = {"this_file_id":pf[0], "parent_file_id": pf[1]}
            bindlist.append(binds) 
        self.dbi.processData(self.sql, bindlist, conn, transaction)
1078465
def fetch(bank, key):
    '''
    
    '''
    _init_client()
    etcd_key = '{0}/{1}/{2}'.format(path_prefix, bank, key)
    try:
        value = client.read(etcd_key).value
        return __context__['serial'].loads(base64.b64decode(value))
    except etcd.EtcdKeyNotFound:
        return {}
    except Exception as exc:
        raise SaltCacheError(
            'There was an error reading the key, {0}: {1}'.format(
                etcd_key, exc
            )
        )
1288704
async def blob(self, elem=None, elem_type=None, params=None):
        
        elem_type = elem_type if elem_type else elem.__class__
        if hasattr(elem_type, "serialize_archive"):
            elem = elem_type() if elem is None else elem
            return await elem.serialize_archive(
                self, elem=elem, elem_type=elem_type, params=params
            )

        if self.writing:
            return await dump_blob(
                self.iobj, elem=elem, elem_type=elem_type, params=params
            )
        else:
            return await load_blob(
                self.iobj, elem_type=elem_type, params=params, elem=elem
            )
999335
def do_execute(self):
        
        if isinstance(self.input.payload, Instances):
            inst = None
            data = self.input.payload
        elif isinstance(self.input.payload, Instance):
            inst = self.input.payload
            data = inst.dataset

        index = str(self.resolve_option("index"))
        unset = bool(self.resolve_option("unset"))
        if unset:
            data.no_class()
        else:
            if index == "first":
                data.class_is_first()
            elif index == "last":
                data.class_is_last()
            else:
                data.class_index = int(index) - 1

        if inst is None:
            self._output.append(Token(data))
        else:
            self._output.append(Token(inst))

        return None
945334
def bpopleft(self, timeout=0):
        
        ret = self.database.blpop(self.key, timeout)
        if ret is not None:
            return ret[1]
1332938
def _perform_update(self, method, resource, payload):
        '''
        
        '''

        # python2/3 compatibility wizardry
        try:
            file_type = file
        except NameError:
            file_type = IOBase

        if isinstance(payload, (dict, list)):
            response = self._perform_request(method, resource,
                                             data=json.dumps(payload))
        elif isinstance(payload, file_type):
            headers = {
                "content-type": "text/csv",
            }
            response = self._perform_request(method, resource, data=payload,
                                             headers=headers)
        else:
            raise Exception("Unrecognized payload {0}. Currently only list-, dictionary-,"
                            " and file-types are supported.".format(type(payload)))

        return response
1124573
def _BlobToChunks(blob_id, blob):
  """"""
  #  In case of empty blob (with empty range), use [0].
  chunk_begins = list(range(0, len(blob), BLOB_CHUNK_SIZE)) or [0]
  chunks = []
  for i, chunk_begin in enumerate(chunk_begins):
    chunks.append({
        "blob_id": blob_id,
        "chunk_index": i,
        "blob_chunk": blob[chunk_begin:chunk_begin + BLOB_CHUNK_SIZE]
    })
  return chunks
1221520
def _get_features(self, eopatch=None):
        
        for feature_type, feature_dict in self.feature_collection.items():
            if feature_type is None and self.default_feature_type is not None:
                feature_type = self.default_feature_type

            if feature_type is None:
                for feature_name, new_feature_name in feature_dict.items():
                    if eopatch is None:
                        yield self._return_feature(..., feature_name, new_feature_name)
                    else:
                        found_feature_type = self._find_feature_type(feature_name, eopatch)
                        if found_feature_type:
                            yield self._return_feature(found_feature_type, feature_name, new_feature_name)
                        else:
                            raise ValueError("Feature with name '{}' does not exist among features of allowed feature"
                                             " types in given EOPatch. Allowed feature types are "
                                             "{}".format(feature_name, self.allowed_feature_types))
            elif feature_dict is ...:
                if not feature_type.has_dict() or eopatch is None:
                    yield self._return_feature(feature_type, ...)
                else:
                    for feature_name in eopatch[feature_type]:
                        yield self._return_feature(feature_type, feature_name)
            else:
                for feature_name, new_feature_name in feature_dict.items():
                    if eopatch is not None and feature_name not in eopatch[feature_type]:
                        raise ValueError('Feature {} of type {} was not found in EOPatch'.format(feature_name,
                                                                                                 feature_type))
                    yield self._return_feature(feature_type, feature_name, new_feature_name)
1248849
def execute(self, input_data):
        '''  '''

        # Just a small check to make sure we haven't been called on the wrong file type
        if (input_data['meta']['type_tag'] != 'exe'):
            return {'error': self.__class__.__name__+': called on '+input_data['meta']['type_tag']}

        view = {}
        view['indicators'] = list(set([item['category'] for item in input_data['pe_indicators']['indicator_list']]))
        view['peid_matches'] = input_data['pe_peid']['match_list']
        view['yara_sigs'] = input_data['yara_sigs']['matches'].keys()
        view['classification'] = input_data['pe_classifier']['classification']
        view['disass'] = self.safe_get(input_data, ['pe_disass', 'decode'])[:15]
        view.update(input_data['meta'])

        return view
466425
def _get_data_to_display(self, eopatch):
        
        feature_type, feature_name = next(self.feature(eopatch))

        image_seq = eopatch[feature_type][feature_name]
        single_channel = False
        if image_seq.ndim == 3:
            # single channel
            single_channel = True
        elif image_seq.ndim == 4:
            # If multi-channel make sure indexing is correct
            n_channels = image_seq.shape[-1]
            if n_channels == 1:
                image_seq = np.squeeze(image_seq, axis=-1)
                single_channel = True
            elif n_channels == 3:
                pass
            else:
                if (self.indices is not None) and ((len(self.indices) == 1) or (len(self.indices) == 3)):
                    image_seq = image_seq[..., self.indices]
                    if len(self.indices) == 1:
                        image_seq = np.squeeze(image_seq, axis=-1)
                        single_channel = True
                else:
                    raise ValueError("Specify valid indices for multi-channel EOPatch")
        else:
            raise ValueError("Unsupported format for EOPatch")
        return image_seq, single_channel
1322668
async def dump_blob(elem, elem_type=None):
    
    elem_is_blob = isinstance(elem, x.BlobType)
    data = getattr(elem, x.BlobType.DATA_ATTR) if elem_is_blob else elem
    if data is None or len(data) == 0:
        return b''
    if isinstance(data, (bytes, bytearray, list)):
        return base64.b16encode(bytes(data))
    else:
        raise ValueError('Unknown blob type')
59891
def execute(self, input_data):
        '''  '''
        raw_bytes = input_data['sample']['raw_bytes']

        # Have the PE File module process the file
        try:
            pefile_handle = pefile.PE(data=raw_bytes, fast_load=False)
        except (AttributeError, pefile.PEFormatError), error:
            return {'error':  str(error), 'match_list': []}

        # Now get information from PEID module
        peid_match = self.peid_features(pefile_handle)
        return {'match_list': peid_match}
84813
def execute(self, eopatch):
        
        for feature_type, feature_name in self.feature_gen(eopatch):
            if feature_name is ...:
                eopatch.reset_feature_type(feature_type)
            else:
                del eopatch[feature_type][feature_name]

        return eopatch
390365
def execute(self, input_data):
        '''  '''

        # Copy info from input
        view = input_data['view_pcap']

        # Grab a couple of handles
        extracted_files = input_data['view_pcap']['extracted_files']

        # Dump a couple of fields
        del view['extracted_files']        

        # Grab additional info about the extracted files
        view['extracted_files'] = [self.workbench.work_request('meta_deep', md5, 
            ['md5', 'sha256', 'entropy', 'ssdeep', 'file_size', 'file_type']) for md5 in extracted_files]

        return view