parameters: (self, source, delete_source=False)
return_statement: return not errored
docstring: Copy given recording building block entries.
  
          :param RedisUniqueComponent source: building block
          :param bool delete_source: whether to delete source building block
  
          :returns: whether successful or not
          :rtype: bool
docstring_summary: Copy given recording building block entries.
docstring_tokens: Copy given recording building block entries .
function: def copy_data_from_recording(self, source, delete_source=False):
          """Copy given recording building block entries.
  
          :param RedisUniqueComponent source: building block
          :param bool delete_source: whether to delete source building block
  
          :returns: whether successful or not
          :rtype: bool
          """
          if self == source:
              return False
  
          if not self.is_open():
              return False
  
          errored = False
  
          self._copy_prop(source, 'title')
          self._copy_prop(source, 'desc')
          self._copy_prop(source, 'rec_type')
          self._copy_prop(source, 'recorded_at')
          #self._copy_prop(source, 'patch_rec')
  
          collection = self.get_owner()
          user = collection.get_owner()
  
          target_dirname = user.get_user_temp_warc_path()
          target_warc_key = self.COLL_WARC_KEY.format(coll=collection.my_id)
  
          # Copy WARCs
          loader = BlockLoader()
  
          for n, url in source.iter_all_files(include_index=True):
              local_filename = n + '.' + timestamp20_now()
              target_file = os.path.join(target_dirname, local_filename)
  
              src = loader.load(url)
  
              try:
                  with open(target_file, 'wb') as dest:
                      logger.debug('Copying {0} -> {1}'.format(url, target_file))
                      shutil.copyfileobj(src, dest)
                      size = dest.tell()
  
                  if n != self.INDEX_FILE_KEY:
                      self.incr_size(size)
                      self.redis.hset(target_warc_key, n, add_local_store_prefix(target_file))
                  else:
                      self.set_prop(n, target_file)
  
              except:
                  traceback.print_exc()
                  errored = True
  
          # COPY cdxj, if exists
          source_key = self.CDXJ_KEY.format(rec=source.my_id)
          target_key = self.CDXJ_KEY.format(rec=self.my_id)
  
          self.redis.zunionstore(target_key, [source_key])
  
          # recreate pages, if any, in new recording
          source_coll = source.get_owner()
          source_pages = source_coll.list_rec_pages(source)
          collection.import_pages(source_pages, self)
  
          # COPY remote archives, if any
          self.redis.sunionstore(self.RA_KEY.format(rec=self.my_id),
                                 self.RA_KEY.format(rec=source.my_id))
  
          # COPY recording warc keys
          self.redis.sunionstore(self.REC_WARC_KEY.format(rec=self.my_id),
                                 self.REC_WARC_KEY.format(rec=source.my_id))
  
          # sync collection cdxj, if exists
          collection.sync_coll_index(exists=True, do_async=True)
  
          if not errored and delete_source:
              collection = source.get_owner()
              collection.remove_recording(source, delete=True)
  
          return not errored
function_tokens: def copy_data_from_recording ( self , source , delete_source = False ) : if self == source : return False if not self . is_open ( ) : return False errored = False self . _copy_prop ( source , 'title' ) self . _copy_prop ( source , 'desc' ) self . _copy_prop ( source , 'rec_type' ) self . _copy_prop ( source , 'recorded_at' ) #self._copy_prop(source, 'patch_rec') collection = self . get_owner ( ) user = collection . get_owner ( ) target_dirname = user . get_user_temp_warc_path ( ) target_warc_key = self . COLL_WARC_KEY . format ( coll = collection . my_id ) # Copy WARCs loader = BlockLoader ( ) for n , url in source . iter_all_files ( include_index = True ) : local_filename = n + '.' + timestamp20_now ( ) target_file = os . path . join ( target_dirname , local_filename ) src = loader . load ( url ) try : with open ( target_file , 'wb' ) as dest : logger . debug ( 'Copying {0} -> {1}' . format ( url , target_file ) ) shutil . copyfileobj ( src , dest ) size = dest . tell ( ) if n != self . INDEX_FILE_KEY : self . incr_size ( size ) self . redis . hset ( target_warc_key , n , add_local_store_prefix ( target_file ) ) else : self . set_prop ( n , target_file ) except : traceback . print_exc ( ) errored = True # COPY cdxj, if exists source_key = self . CDXJ_KEY . format ( rec = source . my_id ) target_key = self . CDXJ_KEY . format ( rec = self . my_id ) self . redis . zunionstore ( target_key , [ source_key ] ) # recreate pages, if any, in new recording source_coll = source . get_owner ( ) source_pages = source_coll . list_rec_pages ( source ) collection . import_pages ( source_pages , self ) # COPY remote archives, if any self . redis . sunionstore ( self . RA_KEY . format ( rec = self . my_id ) , self . RA_KEY . format ( rec = source . my_id ) ) # COPY recording warc keys self . redis . sunionstore ( self . REC_WARC_KEY . format ( rec = self . my_id ) , self . REC_WARC_KEY . format ( rec = source . my_id ) ) # sync collection cdxj, if exists collection . sync_coll_index ( exists = True , do_async = True ) if not errored and delete_source : collection = source . get_owner ( ) collection . remove_recording ( source , delete = True ) return not errored