(self, data_frame, end_stream, retry_count=0)
return None
Upload data to Timesketch.

        Args:
            data_frame: a pandas DataFrame with the content to upload.
            end_stream: boolean indicating whether this is the last chunk of
                the stream.
            retry_count: optional int that is only set if this is a retry
                of the upload.

        Raises:
            RuntimeError: If the dataframe is not successfully uploaded.
Upload data to Timesketch.
Upload data to Timesketch .
def _upload_data_frame(self, data_frame, end_stream, retry_count=0):
        """Upload data to Timesketch.

        Args:
            data_frame: a pandas DataFrame with the content to upload.
            end_stream: boolean indicating whether this is the last chunk of
                the stream.
            retry_count: optional int that is only set if this is a retry
                of the upload.

        Raises:
            RuntimeError: If the dataframe is not successfully uploaded.
        """
        data = {
            'name': self._timeline_name,
            'sketch_id': self._sketch.id,
            'enable_stream': not end_stream,
            'data_label': self._data_label,
            'provider': self._provider,
            'events': data_frame.to_json(orient='records', lines=True),
        }
        if self._index:
            data['index_name'] = self._index

        if self._upload_context:
            data['context'] = self._upload_context

        response = self._sketch.api.session.post(self._resource_url, data=data)
        if response.status_code not in definitions.HTTP_STATUS_CODE_20X:
            if retry_count >= self.DEFAULT_RETRY_LIMIT:
                raise RuntimeError(
                    'Error uploading data: [{0:d}] {1!s} {2!s}, '
                    'index {3:s}'.format(
                        response.status_code, response.reason, response.text,
                        self._index))

            logger.warning(
                'Unable to upload dataframe, retrying (attempt '
                '{0:d}/{1:d})'.format(
                    retry_count + 1, self.DEFAULT_RETRY_LIMIT))

            return self._upload_data_frame(
                data_frame=data_frame, end_stream=end_stream,
                retry_count=retry_count + 1)

        self._chunk += 1
        response_dict = response.json()
        object_dict = response_dict.get('objects', [{}])[0]
        meta_dict = response_dict.get('meta', {})
        self._celery_task_id = meta_dict.get('task_id', '')

        self._timeline_id = object_dict.get('id')
        self._index = object_dict.get('searchindex', {}).get('index_name')
        self._last_response = response_dict
        return None
def _upload_data_frame ( self , data_frame , end_stream , retry_count = 0 ) : data = { 'name' : self . _timeline_name , 'sketch_id' : self . _sketch . id , 'enable_stream' : not end_stream , 'data_label' : self . _data_label , 'provider' : self . _provider , 'events' : data_frame . to_json ( orient = 'records' , lines = True ) , } if self . _index : data [ 'index_name' ] = self . _index if self . _upload_context : data [ 'context' ] = self . _upload_context response = self . _sketch . api . session . post ( self . _resource_url , data = data ) if response . status_code not in definitions . HTTP_STATUS_CODE_20X : if retry_count >= self . DEFAULT_RETRY_LIMIT : raise RuntimeError ( 'Error uploading data: [{0:d}] {1!s} {2!s}, ' 'index {3:s}' . format ( response . status_code , response . reason , response . text , self . _index ) ) logger . warning ( 'Unable to upload dataframe, retrying (attempt ' '{0:d}/{1:d})' . format ( retry_count + 1 , self . DEFAULT_RETRY_LIMIT ) ) return self . _upload_data_frame ( data_frame = data_frame , end_stream = end_stream , retry_count = retry_count + 1 ) self . _chunk += 1 response_dict = response . json ( ) object_dict = response_dict . get ( 'objects' , [ { } ] ) [ 0 ] meta_dict = response_dict . get ( 'meta' , { } ) self . _celery_task_id = meta_dict . get ( 'task_id' , '' ) self . _timeline_id = object_dict . get ( 'id' ) self . _index = object_dict . get ( 'searchindex' , { } ) . get ( 'index_name' ) self . _last_response = response_dict return None