Code
stringlengths
103
85.9k
Summary
listlengths
0
94
Please provide a description of the function:def base64_encode_as_string(obj): # noqa # type: (any) -> str if on_python2(): return base64.b64encode(obj) else: return str(base64.b64encode(obj), 'ascii')
[ "Encode object to base64\n :param any obj: object to encode\n :rtype: str\n :return: base64 encoded string\n " ]
Please provide a description of the function:def page_align_content_length(length): # type: (int) -> int mod = length % _PAGEBLOB_BOUNDARY if mod != 0: return length + (_PAGEBLOB_BOUNDARY - mod) return length
[ "Compute page boundary alignment\n :param int length: content length\n :rtype: int\n :return: aligned byte boundary\n " ]
Please provide a description of the function:def normalize_azure_path(path): # type: (str) -> str if is_none_or_empty(path): raise ValueError('provided path is invalid') _path = path.strip('/').strip('\\') return '/'.join(re.split('/|\\\\', _path))
[ "Normalize remote path (strip slashes and use forward slashes)\n :param str path: path to normalize\n :rtype: str\n :return: normalized path\n " ]
Please provide a description of the function:def explode_azure_path(path): # type: (str) -> Tuple[str, str] rpath = normalize_azure_path(path).split('/') container = str(rpath[0]) if len(rpath) > 1: rpath = '/'.join(rpath[1:]) else: rpath = '' return container, rpath
[ "Explodes an azure path into a container or fileshare and the\n remaining virtual path\n :param str path: path to explode\n :rtype: tuple\n :return: container, vpath\n " ]
Please provide a description of the function:def blob_is_snapshot(url): # type: (str) -> bool if '?snapshot=' in url: try: dateutil.parser.parse(url.split('?snapshot=')[-1]) return True except (ValueError, OverflowError): pass return False
[ "Checks if the blob is a snapshot blob\n :param url str: blob url\n :rtype: bool\n :return: if blob is a snapshot blob\n " ]
Please provide a description of the function:def parse_blob_snapshot_parameter(url): # type: (str) -> str if blob_is_snapshot(url): tmp = url.split('?snapshot=') if len(tmp) == 2: return tmp[0], tmp[1] return None
[ "Retrieves the blob snapshot parameter from a url\n :param url str: blob url\n :rtype: str\n :return: snapshot parameter\n " ]
Please provide a description of the function:def parse_fileshare_or_file_snapshot_parameter(url): # type: (str) -> Tuple[str, str] if is_not_empty(url): if '?sharesnapshot=' in url: try: tmp = url.split('?sharesnapshot=') if len(tmp) == 2: ...
[ "Checks if the fileshare or file is a snapshot\n :param url str: file url\n :rtype: tuple\n :return: (url, snapshot)\n " ]
Please provide a description of the function:def explode_azure_storage_url(url): # type: (str) -> Tuple[str, str, str, str, str] tmp = url.split('/') host = tmp[2].split('.') sa = host[0] mode = host[1].lower() ep = '.'.join(host[2:]) tmp = '/'.join(tmp[3:]).split('?') rpath = tmp[0...
[ "Explode Azure Storage URL into parts\n :param url str: storage url\n :rtype: tuple\n :return: (sa, mode, ep, rpath, sas)\n " ]
Please provide a description of the function:def ensure_path_exists(self): # type: (LocalDestinationPath) -> None if self._is_dir is None: raise RuntimeError('is_dir not set') if self._is_dir: self._path.mkdir(mode=0o750, parents=True, exist_ok=True) else...
[ "Ensure path exists\n :param LocalDestinationPath self: this\n " ]
Please provide a description of the function:def _compute_total_chunks(self, chunk_size): # type: (Descriptor, int) -> int try: return int(math.ceil(self._ase.size / chunk_size)) except ZeroDivisionError: return 0
[ "Compute total number of chunks for entity\n :param Descriptor self: this\n :param int chunk_size: chunk size\n :rtype: int\n :return: num chunks\n " ]
Please provide a description of the function:def _initialize_integrity_checkers(self, options): # type: (Descriptor, blobxfer.models.options.Download) -> None if self._ase.is_encrypted: # ensure symmetric key exists if blobxfer.util.is_none_or_empty( ...
[ "Initialize file integrity checkers\n :param Descriptor self: this\n :param blobxfer.models.options.Download options: download options\n " ]
Please provide a description of the function:def compute_allocated_size(size, is_encrypted): # type: (int, bool) -> int # compute size if size > 0: if is_encrypted: # cipher_len_without_iv = (clear_len / aes_bs + 1) * aes_bs allocatesize = ( ...
[ "Compute allocated size on disk\n :param int size: size (content length)\n :param bool is_ecrypted: if entity is encrypted\n :rtype: int\n :return: required size on disk\n " ]
Please provide a description of the function:def generate_view(ase): # type: (blobxfer.models.azure.StorageEntity) -> # Tuple[LocalPathView, int] slicesize = blobxfer.models.download.Descriptor.compute_allocated_size( ase.size, ase.is_encrypted) if ase.vectored...
[ "Generate local path view and total size required\n :param blobxfer.models.azure.StorageEntity ase: Storage Entity\n :rtype: tuple\n :return: (local path view, allocation size)\n " ]
Please provide a description of the function:def convert_vectored_io_slice_to_final_path_name(local_path, ase): # type: (pathlib.Path, # blobxfer.models.azure.StorageEntity) -> pathlib.Path name = blobxfer.models.metadata.\ remove_vectored_io_slice_suffix_from_name( ...
[ "Convert vectored io slice to final path name\n :param pathlib.Path local_path: local path\n :param blobxfer.models.azure.StorageEntity ase: Storage Entity\n :rtype: pathlib.Path\n :return: converted final path\n " ]
Please provide a description of the function:def _set_final_path_view(self): # type: (Descriptor) -> int # set final path if vectored io stripe if self._ase.vectored_io is not None: self.final_path = blobxfer.models.download.Descriptor.\ convert_vectored_io_s...
[ "Set final path view and return required space on disk\n :param Descriptor self: this\n :rtype: int\n :return: required size on disk\n " ]
Please provide a description of the function:def _allocate_disk_space(self): # type: (Descriptor) -> None with self._meta_lock: if self._allocated or self._offset != 0: return # set local path view allocatesize = self._set_final_path_view() ...
[ "Perform file allocation (possibly sparse)\n :param Descriptor self: this\n " ]
Please provide a description of the function:def _resume(self): # type: (Descriptor) -> int if self._resume_mgr is None or self._offset > 0 or self._finalized: return None # check if path exists in resume db rr = self._resume_mgr.get_record(self._ase) if rr i...
[ "Resume a download, if possible\n :param Descriptor self: this\n :rtype: int or None\n :return: verified download offset\n " ]
Please provide a description of the function:def cleanup_all_temporary_files(self): # type: (Descriptor) -> None # delete local file try: self.final_path.unlink() except OSError: pass # iterate unchecked chunks and delete for key in self._...
[ "Cleanup all temporary files in case of an exception or interrupt.\n This function is not thread-safe.\n :param Descriptor self: this\n " ]
Please provide a description of the function:def next_offsets(self): # type: (Descriptor) -> Offsets resume_bytes = self._resume() if resume_bytes is None and not self._allocated: self._allocate_disk_space() with self._meta_lock: if self._offset >= self._...
[ "Retrieve the next offsets\n :param Descriptor self: this\n :rtype: Offsets\n :return: download offsets\n " ]
Please provide a description of the function:def write_unchecked_data(self, offsets, data): # type: (Descriptor, Offsets, bytes) -> None self.write_data(offsets, data) unchecked = UncheckedChunk( data_len=len(data), fd_start=self.view.fd_start + offsets.fd_start,...
[ "Write unchecked data to disk\n :param Descriptor self: this\n :param Offsets offsets: download offsets\n :param bytes data: data\n " ]
Please provide a description of the function:def write_unchecked_hmac_data(self, offsets, data): # type: (Descriptor, Offsets, bytes) -> None fname = None with tempfile.NamedTemporaryFile(mode='wb', delete=False) as fd: fname = fd.name fd.write(data) unch...
[ "Write unchecked encrypted data to disk\n :param Descriptor self: this\n :param Offsets offsets: download offsets\n :param bytes data: hmac/encrypted data\n " ]
Please provide a description of the function:def perform_chunked_integrity_check(self): # type: (Descriptor) -> None hasher = self.hmac or self.md5 # iterate from next chunk to be checked while True: ucc = None with self._meta_lock: chunk_...
[ "Hash data against stored hasher safely\n :param Descriptor self: this\n " ]
Please provide a description of the function:def _update_resume_for_completed(self): # type: (Descriptor) -> None if not self.is_resumable: return with self._meta_lock: self._resume_mgr.add_or_update_record( self.final_path, self._ase, self._chunk...
[ "Update resume for completion\n :param Descriptor self: this\n " ]
Please provide a description of the function:def write_data(self, offsets, data): # type: (Descriptor, Offsets, bytes) -> None if len(data) > 0: # offset from internal view pos = self.view.fd_start + offsets.fd_start with self.final_path.open('r+b') as fd: ...
[ "Write data to disk\n :param Descriptor self: this\n :param Offsets offsets: download offsets\n :param bytes data: data\n " ]
Please provide a description of the function:def finalize_integrity(self): # type: (Descriptor) -> None with self._meta_lock: if self._finalized: return # check final file integrity check = False msg = None if self.hmac is not None: ...
[ "Finalize integrity check for download\n :param Descriptor self: this\n " ]
Please provide a description of the function:def _restore_file_attributes(self): # type: (Descriptor) -> None if (not self._restore_file_properties.attributes or self._ase.file_attributes is None): return # set file uid/gid and mode if blobxfer.util.o...
[ "Restore file attributes for file\n :param Descriptor self: this\n " ]
Please provide a description of the function:def _restore_file_lmt(self): # type: (Descriptor) -> None if not self._restore_file_properties.lmt or self._ase.lmt is None: return # timestamp() func is not available in py27 ts = time.mktime(self._ase.lmt.timetuple()) ...
[ "Restore file lmt for file\n :param Descriptor self: this\n " ]
Please provide a description of the function:def finalize_file(self): # type: (Descriptor) -> None # delete bad file if integrity failed if self._integrity_failed: self.final_path.unlink() else: self._restore_file_attributes() self._restore_fi...
[ "Finalize file for download\n :param Descriptor self: this\n " ]
Please provide a description of the function:def termination_check(self): # type: (Uploader) -> bool with self._upload_lock: with self._transfer_lock: return (self._upload_terminate or len(self._exceptions) > 0 or (self...
[ "Check if terminated\n :param Uploader self: this\n :rtype: bool\n :return: if terminated\n " ]
Please provide a description of the function:def termination_check_md5(self): # type: (Uploader) -> bool with self._md5_meta_lock: with self._upload_lock: return (self._upload_terminate or (self._all_files_processed and ...
[ "Check if terminated from MD5 context\n :param Uploader self: this\n :rtype: bool\n :return: if terminated from MD5 context\n " ]
Please provide a description of the function:def create_unique_id(src, ase): # type: (blobxfer.models.upload.LocalPath, # blobxfer.models.azure.StorageEntity) -> str return ';'.join( (str(src.absolute_path), ase._client.primary_endpoint, ase.path) )
[ "Create a unique id given a LocalPath and StorageEntity\n :param blobxfer.models.upload.LocalPath src: local path\n :param blobxfer.models.azure.StorageEntity ase: azure storage entity\n :rtype: str\n :return: unique id for pair\n " ]
Please provide a description of the function:def create_unique_transfer_id(local_path, ase, offsets): # type: (blobxfer.models.upload.LocalPath, # blobxfer.models.azure.StorageEntity) -> str return ';'.join( (str(local_path.absolute_path), ase._client.primary_endpoint...
[ "Create a unique transfer id given a offsets\n :param blobxfer.models.upload.LocalPath local_path: local path\n :param blobxfer.models.azure.StorageEntity ase: azure storage entity\n :param blobxfer.models.upload.Offsets offsets: upload offsets\n :rtype: str\n :return: unique id f...
Please provide a description of the function:def create_destination_id(client, container, name): # type: (azure.storage.StorageClient, str, str) -> str path = str(pathlib.PurePath(name)) return ';'.join((client.primary_endpoint, container, path))
[ "Create a unique destination id\n :param azure.storage.StorageClient client: storage client\n :param str container: container name\n :param str name: entity name\n :rtype: str\n :return: unique id for the destination\n " ]
Please provide a description of the function:def _update_progress_bar(self, stdin=False): # type: (Uploader, bool) -> None if not self._all_files_processed: return blobxfer.operations.progress.update_progress_bar( self._general_options, 'upload', ...
[ "Update progress bar\n :param Uploader self: this\n :param bool stdin: stdin upload\n " ]
Please provide a description of the function:def _pre_md5_skip_on_check(self, src, rfile): # type: (Uploader, blobxfer.models.upload.LocalPath, # blobxfer.models.azure.StorageEntity) -> None md5 = blobxfer.models.metadata.get_md5_from_metadata(rfile) key = blobxfer.operat...
[ "Perform pre MD5 skip on check\n :param Uploader self: this\n :param blobxfer.models.upload.LocalPath src: local path\n :param blobxfer.models.azure.StorageEntity rfile: remote file\n " ]
Please provide a description of the function:def _post_md5_skip_on_check(self, key, md5_match): # type: (Uploader, str, bool) -> None with self._md5_meta_lock: src, rfile = self._md5_map.pop(key) uid = blobxfer.operations.upload.Uploader.create_unique_id(src, rfile) ...
[ "Perform post MD5 skip on check\n :param Uploader self: this\n :param str key: md5 map key\n :param bool md5_match: if MD5 matches\n " ]
Please provide a description of the function:def _check_for_uploads_from_md5(self): # type: (Uploader) -> None cv = self._md5_offload.done_cv while not self.termination_check_md5: result = None cv.acquire() while True: result = self._m...
[ "Check queue for a file to upload\n :param Uploader self: this\n " ]
Please provide a description of the function:def _add_to_upload_queue(self, src, rfile, uid): # type: (Uploader, blobxfer.models.upload.LocalPath, # blobxfer.models.azure.StorageEntity, str) -> None # prepare local file for upload ud = blobxfer.models.upload.Descriptor( ...
[ "Add remote file to download queue\n :param Uploader self: this\n :param blobxfer.models.upload.LocalPath src: local path\n :param blobxfer.models.azure.StorageEntity rfile: remote file\n :param str uid: unique id\n " ]
Please provide a description of the function:def _initialize_disk_threads(self): # type: (Uploader) -> None logger.debug('spawning {} disk threads'.format( self._general_options.concurrency.disk_threads)) for _ in range(self._general_options.concurrency.disk_threads): ...
[ "Initialize disk threads\n :param Uploader self: this\n " ]
Please provide a description of the function:def _wait_for_disk_threads(self, terminate): # type: (Uploader, bool) -> None if terminate: self._upload_terminate = terminate for thr in self._disk_threads: thr.join()
[ "Wait for disk threads\n :param Uploader self: this\n :param bool terminate: terminate threads\n " ]
Please provide a description of the function:def _wait_for_transfer_threads(self, terminate): # type: (Uploader, bool) -> None if terminate: self._upload_terminate = terminate for thr in self._transfer_threads: thr.join()
[ "Wait for transfer threads\n :param Uploader self: this\n :param bool terminate: terminate threads\n " ]
Please provide a description of the function:def _worker_thread_transfer(self): # type: (Uploader) -> None while not self.termination_check: try: ud, ase, offsets, data = self._transfer_queue.get( block=False, timeout=0.1) except queue...
[ "Worker thread transfer\n :param Uploader self: this\n " ]
Please provide a description of the function:def _process_transfer(self, ud, ase, offsets, data): # type: (Uploader, blobxfer.models.upload.Descriptor, # blobxfer.models.azure.StorageEntity, # blobxfer.models.upload.Offsets, bytes) -> None # issue put range ...
[ "Process transfer instructions\n :param Uploader self: this\n :param blobxfer.models.upload.Descriptor ud: upload descriptor\n :param blobxfer.models.azure.StorageEntity ase: Storage entity\n :param blobxfer.models.upload.Offsets offsets: offsets\n :param bytes data: data to uploa...
Please provide a description of the function:def _put_data(self, ud, ase, offsets, data): # type: (Uploader, blobxfer.models.upload.Descriptor, # blobxfer.models.azure.StorageEntity, # blobxfer.models.upload.Offsets, bytes) -> None if ase.mode == blobxfer.models.az...
[ "Put data in Azure\n :param Uploader self: this\n :param blobxfer.models.upload.Descriptor ud: upload descriptor\n :param blobxfer.models.azure.StorageEntity ase: Storage entity\n :param blobxfer.models.upload.Offsets offsets: offsets\n :param bytes data: data to upload\n "...
Please provide a description of the function:def _worker_thread_upload(self): # type: (Uploader) -> None max_set_len = self._general_options.concurrency.transfer_threads << 2 while not self.termination_check: try: if len(self._transfer_set) > max_set_len: ...
[ "Worker thread upload\n :param Uploader self: this\n " ]
Please provide a description of the function:def _prepare_upload(self, ase): # type: (Uploader, blobxfer.models.azure.StorageEntity) -> None if ase.mode == blobxfer.models.azure.StorageModes.Append: if ase.append_create: # create container if necessary ...
[ "Prepare upload\n :param Uploader self: this\n :param blobxfer.models.azure.StorageEntity ase: Storage entity\n " ]
Please provide a description of the function:def _process_upload_descriptor(self, ud): # type: (Uploader, blobxfer.models.upload.Descriptor) -> None # get upload offsets offsets, resume_bytes = ud.next_offsets() # add resume bytes to counter if resume_bytes is not None: ...
[ "Process upload descriptor\n :param Uploader self: this\n :param blobxfer.models.upload.Descriptor: upload descriptor\n " ]
Please provide a description of the function:def _finalize_block_blob(self, ud, metadata): # type: (Uploader, blobxfer.models.upload.Descriptor, dict) -> None if not ud.entity.is_encrypted and ud.must_compute_md5: digest = blobxfer.util.base64_encode_as_string(ud.md5.digest()) ...
[ "Finalize Block blob\n :param Uploader self: this\n :param blobxfer.models.upload.Descriptor ud: upload descriptor\n :param dict metadata: metadata dict\n " ]
Please provide a description of the function:def _set_blob_properties(self, ud): # type: (Uploader, blobxfer.models.upload.Descriptor) -> None if ud.requires_non_encrypted_md5_put: digest = blobxfer.util.base64_encode_as_string(ud.md5.digest()) else: digest = Non...
[ "Set blob properties (md5, cache control)\n :param Uploader self: this\n :param blobxfer.models.upload.Descriptor ud: upload descriptor\n " ]
Please provide a description of the function:def _set_blob_metadata(self, ud, metadata): # type: (Uploader, blobxfer.models.upload.Descriptor, dict) -> None blobxfer.operations.azure.blob.set_blob_metadata(ud.entity, metadata) if blobxfer.util.is_not_empty(ud.entity.replica_targets): ...
[ "Set blob metadata\n :param Uploader self: this\n :param blobxfer.models.upload.Descriptor ud: upload descriptor\n :param dict metadata: metadata dict\n " ]
Please provide a description of the function:def _resize_blob(self, ud, size): # type: (Uploader, blobxfer.models.upload.Descriptor, int) -> None blobxfer.operations.azure.blob.page.resize_blob(ud.entity, size) if blobxfer.util.is_not_empty(ud.entity.replica_targets): for as...
[ "Resize page blob\n :param Uploader self: this\n :param blobxfer.models.upload.Descriptor ud: upload descriptor\n :param int size: content length\n " ]
Please provide a description of the function:def _finalize_nonblock_blob(self, ud, metadata): # type: (Uploader, blobxfer.models.upload.Descriptor, dict) -> None # resize blobs to final size if required needs_resize, final_size = ud.requires_resize() if needs_resize: ...
[ "Finalize Non-Block blob\n :param Uploader self: this\n :param blobxfer.models.upload.Descriptor ud: upload descriptor\n :param dict metadata: metadata dict\n " ]
Please provide a description of the function:def _finalize_azure_file(self, ud, metadata): # type: (Uploader, blobxfer.models.upload.Descriptor, dict) -> None # set md5 file property if required if ud.requires_non_encrypted_md5_put: digest = blobxfer.util.base64_encode_as_st...
[ "Finalize Azure File\n :param Uploader self: this\n :param blobxfer.models.upload.Descriptor ud: upload descriptor\n :param dict metadata: metadata dict\n " ]
Please provide a description of the function:def _finalize_upload(self, ud): # type: (Uploader, blobxfer.models.upload.Descriptor) -> None metadata = ud.generate_metadata() if ud.requires_put_block_list: # put block list for non one-shot block blobs self._finaliz...
[ "Finalize file upload\n :param Uploader self: this\n :param blobxfer.models.upload.Descriptor ud: upload descriptor\n " ]
Please provide a description of the function:def _get_destination_paths(self): # type: (Uploader) -> # Tuple[blobxfer.operations.azure.StorageAccount, str, str, str] for dst in self._spec.destinations: for dpath in dst.paths: sdpath = str(dpath) ...
[ "Get destination paths\n :param Uploader self: this\n :rtype: tuple\n :return: (storage account, container, name, dpath)\n " ]
Please provide a description of the function:def _delete_extraneous_files(self): # type: (Uploader) -> None if not self._spec.options.delete_extraneous_destination: return # list blobs for all destinations checked = set() deleted = 0 for sa, container...
[ "Delete extraneous files on the remote\n :param Uploader self: this\n " ]
Please provide a description of the function:def _check_upload_conditions(self, local_path, rfile): # type: (Uploader, blobxfer.models.upload.LocalPath, # blobxfer.models.azure.StorageEntity) -> UploadAction lpath = local_path.absolute_path # check if local file still exi...
[ "Check for upload conditions\n :param Uploader self: this\n :param blobxfer.models.LocalPath local_path: local path\n :param blobxfer.models.azure.StorageEntity rfile: remote file\n :rtype: UploadAction\n :return: upload action\n " ]
Please provide a description of the function:def _check_for_existing_remote(self, sa, cont, name): # type: (Uploader, blobxfer.operations.azure.StorageAccount, # str, str) -> bobxfer.models.azure.StorageEntity if self._spec.options.mode == blobxfer.models.azure.StorageModes.File:...
[ "Check for an existing remote file\n :param Uploader self: this\n :param blobxfer.operations.azure.StorageAccount sa: storage account\n :param str cont: container\n :param str name: entity name\n :rtype: blobxfer.models.azure.StorageEntity\n :return: remote storage entity\n...
Please provide a description of the function:def _generate_destination_for_source(self, local_path): # type: (Uploader, blobxfer.models.upload.LocalSourcePath) -> # Tuple[blobxfer.operations.azure.StorageAccount, # blobxfer.models.azure.StorageEntity) # construct s...
[ "Generate entities for source path\n :param Uploader self: this\n :param blobxfer.models.upload.LocalSourcePath local_path: local path\n :rtype: tuple\n :return: storage account, storage entity\n " ]
Please provide a description of the function:def _vectorize_and_bind(self, local_path, dest): # type: (Uploader, blobxfer.models.upload.LocalPath, # List[blobxfer.models.azure.StorageEntity]) -> # Tuple[blobxfer.operations.upload.UploadAction, # blobxfer.models.uploa...
[ "Vectorize local path to destinations, if necessary, and bind\n :param Uploader self: this\n :param blobxfer.models.LocalPath local_path: local path\n :param list dest: list of destination tuples (sa, ase)\n :rtype: tuple\n :return: action, LocalPath, ase\n " ]
Please provide a description of the function:def _run(self): # type: (Uploader) -> None # mark start self._start_time = blobxfer.util.datetime_now() logger.info('blobxfer start time: {0}'.format(self._start_time)) # check renames if not self._spec.sources.can_ren...
[ "Execute Uploader\n :param Uploader self: this\n " ]
Please provide a description of the function:def start(self): # type: (Uploader) -> None try: blobxfer.operations.progress.output_parameters( self._general_options, self._spec) self._run() except (KeyboardInterrupt, Exception) as ex: i...
[ "Start the Uploader\n :param Uploader self: this\n " ]
Please provide a description of the function:def _should_retry(self, context): # type: (ExponentialRetryWithMaxWait, # azure.storage.common.models.RetryContext) -> bool # do not retry if max attempts equal or exceeded if context.count >= self.max_attempts: ret...
[ "Determine if retry should happen or not\n :param ExponentialRetryWithMaxWait self: this\n :param azure.storage.common.models.RetryContext context: retry context\n :rtype: bool\n :return: True if retry should happen, False otherwise\n " ]
Please provide a description of the function:def _backoff(self, context): # type: (ExponentialRetryWithMaxWait, # azure.storage.common.models.RetryContext) -> int self._backoff_count += 1 if self._backoff_count == 1: self._last_backoff = self.initial_backoff ...
[ "Backoff calculator\n :param ExponentialRetryWithMaxWait self: this\n :param azure.storage.common.models.RetryContext context: retry context\n :rtype: int\n :return: backoff amount\n " ]
Please provide a description of the function:def termination_check(self): # type: (SyncCopy) -> bool with self._transfer_lock: return (self._synccopy_terminate or len(self._exceptions) > 0 or (self._all_remote_files_processed and ...
[ "Check if terminated\n :param SyncCopy self: this\n :rtype: bool\n :return: if terminated\n " ]
Please provide a description of the function:def create_unique_transfer_operation_id(src_ase, dst_ase): # type: (blobxfer.models.azure.StorageEntity, # blobxfer.models.azure.StorageEntity) -> str return ';'.join( (src_ase._client.primary_endpoint, src_ase.path, ...
[ "Create a unique transfer operation id\n :param blobxfer.models.azure.StorageEntity src_ase: src storage entity\n :param blobxfer.models.azure.StorageEntity dst_ase: dst storage entity\n :rtype: str\n :return: unique transfer id\n " ]
Please provide a description of the function:def _update_progress_bar(self): # type: (SyncCopy) -> None blobxfer.operations.progress.update_progress_bar( self._general_options, 'synccopy', self._synccopy_start_time, self._synccopy_total, ...
[ "Update progress bar\n :param SyncCopy self: this\n " ]
Please provide a description of the function:def _global_dest_mode_is_file(self): # type: (SyncCopy) -> bool if (self._spec.options.dest_mode == blobxfer.models.azure.StorageModes.File or (self._spec.options.mode == blobxfer.models.azure.StorageM...
[ "Determine if destination mode is file\n :param SyncCopy self: this\n :rtype: bool\n :return: destination mode is file\n " ]
Please provide a description of the function:def _translate_src_mode_to_dst_mode(self, src_mode): # type: (SyncCopy, blobxfer.models.azure.StorageModes) -> bool if (self._spec.options.dest_mode == blobxfer.models.azure.StorageModes.Auto): return src_mode else...
[ "Translate the source mode into the destination mode\n :param SyncCopy self: this\n :param blobxfer.models.azure.StorageModes src_mode: source mode\n :rtype: blobxfer.models.azure.StorageModes\n :return: destination mode\n " ]
Please provide a description of the function:def _delete_extraneous_files(self): # type: (SyncCopy) -> None if not self._spec.options.delete_extraneous_destination: return # list blobs for all destinations checked = set() deleted = 0 for sa, container...
[ "Delete extraneous files on the remote\n :param SyncCopy self: this\n " ]
Please provide a description of the function:def _add_to_transfer_queue(self, src_ase, dst_ase): # type: (SyncCopy, blobxfer.models.azure.StorageEntity, # blobxfer.models.azure.StorageEntity) -> None # prepare remote file for download # if remote file is a block blob, nee...
[ "Add remote file to download queue\n :param SyncCopy self: this\n :param blobxfer.models.azure.StorageEntity src_ase: src ase\n :param blobxfer.models.azure.StorageEntity dst_ase: dst ase\n " ]
Please provide a description of the function:def _wait_for_transfer_threads(self, terminate): # type: (SyncCopy, bool) -> None if terminate: self._synccopy_terminate = terminate for thr in self._transfer_threads: blobxfer.util.join_thread(thr)
[ "Wait for download threads\n :param SyncCopy self: this\n :param bool terminate: terminate threads\n " ]
Please provide a description of the function:def _worker_thread_transfer(self): # type: (SyncCopy) -> None while not self.termination_check: try: sd = self._transfer_queue.get(block=False, timeout=0.1) except queue.Empty: continue ...
[ "Worker thread download\n :param SyncCopy self: this\n " ]
Please provide a description of the function:def _put_data(self, sd, ase, offsets, data): # type: (SyncCopy, blobxfer.models.synccopy.Descriptor, # blobxfer.models.azure.StorageEntity, # blobxfer.models.upload.Offsets, bytes) -> None if ase.mode == blobxfer.models....
[ "Put data in Azure\n :param SyncCopy self: this\n :param blobxfer.models.synccopy.Descriptor sd: synccopy descriptor\n :param blobxfer.models.azure.StorageEntity ase: Storage entity\n :param blobxfer.models.upload.Offsets offsets: offsets\n :param bytes data: data to upload\n ...
Please provide a description of the function:def _process_data(self, sd, ase, offsets, data): # type: (SyncCopy, blobxfer.models.synccopy.Descriptor, # blobxfer.models.azure.StorageEntity, # blobxfer.models.synccopy.Offsets, bytes) -> None # issue put data ...
[ "Process downloaded data for upload\n :param SyncCopy self: this\n :param blobxfer.models.synccopy.Descriptor sd: synccopy descriptor\n :param blobxfer.models.azure.StorageEntity ase: storage entity\n :param blobxfer.models.synccopy.Offsets offsets: offsets\n :param bytes data: da...
Please provide a description of the function:def _process_synccopy_descriptor(self, sd): # type: (SyncCopy, blobxfer.models.synccopy.Descriptor) -> None # update progress bar self._update_progress_bar() # get download offsets offsets, resume_bytes = sd.next_offsets() ...
[ "Process synccopy descriptor\n :param SyncCopy self: this\n :param blobxfer.models.synccopy.Descriptor sd: synccopy descriptor\n " ]
Please provide a description of the function:def _finalize_block_blob(self, sd, metadata, digest): # type: (SyncCopy, blobxfer.models.synccopy.Descriptor, dict, # str) -> None blobxfer.operations.azure.blob.block.put_block_list( sd.dst_entity, sd.last_block_num, diges...
[ "Finalize Block blob\n :param SyncCopy self: this\n :param blobxfer.models.synccopy.Descriptor sd: synccopy descriptor\n :param dict metadata: metadata dict\n :param str digest: md5 digest\n " ]
Please provide a description of the function:def _set_blob_properties(self, sd, digest): # type: (SyncCopy, blobxfer.models.synccopy.Descriptor, str) -> None blobxfer.operations.azure.blob.set_blob_properties( sd.dst_entity, digest) if blobxfer.util.is_not_empty(sd.dst_entit...
[ "Set blob properties (md5, cache control)\n :param SyncCopy self: this\n :param blobxfer.models.synccopy.Descriptor sd: synccopy descriptor\n :param str digest: md5 digest\n " ]
Please provide a description of the function:def _set_blob_metadata(self, sd, metadata): # type: (SyncCopy, blobxfer.models.synccopy.Descriptor, dict) -> None blobxfer.operations.azure.blob.set_blob_metadata( sd.dst_entity, metadata) if blobxfer.util.is_not_empty(sd.dst_enti...
[ "Set blob metadata\n :param SyncCopy self: this\n :param blobxfer.models.synccopy.Descriptor sd: synccopy descriptor\n :param dict metadata: metadata dict\n :param dict metadata: metadata dict\n " ]
Please provide a description of the function:def _finalize_nonblock_blob(self, sd, metadata, digest): # type: (SyncCopy, blobxfer.models.synccopy.Descriptor, dict, # str) -> None # set md5 page blob property if required if (blobxfer.util.is_not_empty(digest) or ...
[ "Finalize Non-Block blob\n :param SyncCopy self: this\n :param blobxfer.models.synccopy.Descriptor sd: synccopy descriptor\n :param dict metadata: metadata dict\n :param str digest: md5 digest\n " ]
Please provide a description of the function:def _finalize_azure_file(self, sd, metadata, digest): # type: (SyncCopy, blobxfer.models.synccopy.Descriptor, dict, # str) -> None # set file properties if required if (blobxfer.util.is_not_empty(digest) or sd.d...
[ "Finalize Azure File\n :param SyncCopy self: this\n :param blobxfer.models.synccopy.Descriptor sd: synccopy descriptor\n :param dict metadata: metadata dict\n :param str digest: md5 digest\n " ]
Please provide a description of the function:def _finalize_upload(self, sd): # type: (SyncCopy, blobxfer.models.synccopy.Descriptor) -> None metadata = sd.src_entity.raw_metadata if blobxfer.util.is_not_empty(sd.src_entity.md5): digest = sd.src_entity.md5 else: ...
[ "Finalize file upload\n :param SyncCopy self: this\n :param blobxfer.models.synccopy.Descriptor sd: synccopy descriptor\n " ]
Please provide a description of the function:def _check_copy_conditions(self, src, dst): # type: (SyncCopy, blobxfer.models.azure.StorageEntity, # blobxfer.models.azure.StorageEntity) -> UploadAction # if remote file doesn't exist, copy if dst is None or dst.from_local: ...
[ "Check for synccopy conditions\n :param SyncCopy self: this\n :param blobxfer.models.azure.StorageEntity src: src\n :param blobxfer.models.azure.StorageEntity dst: dst\n :rtype: SynccopyAction\n :return: synccopy action\n " ]
Please provide a description of the function:def _generate_destination_for_source(self, src_ase): # type: (SyncCopy, blobxfer.models.azure.StorageEntity) -> # blobxfer.models.azure.StorageEntity) # create a storage entity for each destination for sa, cont, name, dpath in ...
[ "Generate entities for source path\n :param SyncCopy self: this\n :param blobxfer.models.azure.StorageEntity src_ase: source ase\n :rtype: blobxfer.models.azure.StorageEntity\n :return: destination storage entity\n " ]
Please provide a description of the function:def _bind_sources_to_destination(self): # type: (SyncCopy) -> # Tuple[blobxfer.models.azure.StorageEntity, # blobxfer.models.azure.StorageEntity] seen = set() # iterate through source paths to download fo...
[ "Bind source storage entity to destination storage entities\n :param SyncCopy self: this\n :rtype: tuple\n :return: (source storage entity, destination storage entity)\n " ]
Please provide a description of the function:def _run(self): # type: (SyncCopy) -> None # mark start self._start_time = blobxfer.util.datetime_now() logger.info('blobxfer start time: {0}'.format(self._start_time)) # initialize resume db if specified if self._gene...
[ "Execute SyncCopy\n :param SyncCopy self: this\n " ]
Please provide a description of the function:def start(self): # type: (SyncCopy) -> None try: blobxfer.operations.progress.output_parameters( self._general_options, self._spec) self._run() except (KeyboardInterrupt, Exception) as ex: i...
[ "Start the SyncCopy\n :param SyncCopy self: this\n " ]
Please provide a description of the function:def delete(self): # type: (_BaseResumeManager) -> None self.close() if self._resume_file.exists(): # noqa try: self._resume_file.unlink() except OSError as e: logger.warning('could not ...
[ "Delete the resume file db\n :param _BaseResumeManager self: this\n " ]
Please provide a description of the function:def datalock(self, acquire=True): # type: (_BaseResumeManager) -> None if acquire: self._lock.acquire() try: yield finally: if acquire: self._lock.release()
[ "Delete the resume file db\n :param _BaseResumeManager self: this\n :param bool acquire: acquire lock\n " ]
Please provide a description of the function:def generate_record_key(ase): # type: (blobxfer.models.azure.StorageEntity) -> str key = '{}:{}'.format(ase._client.primary_endpoint, ase.path) if blobxfer.util.on_python2(): return key.encode('utf8') else: ret...
[ "Generate a record key\n :param blobxfer.models.azure.StorageEntity ase: Storage Entity\n :rtype: str\n :return: record key\n " ]
Please provide a description of the function:def get_record(self, ase, key=None, lock=True): # type: (_BaseResumeManager, str, bool) -> object if key is None: key = blobxfer.operations.resume._BaseResumeManager.\ generate_record_key(ase) with self.datalock(lo...
[ "Get a resume record\n :param _BaseResumeManager self: this\n :param blobxfer.models.azure.StorageEntity ase: Storage Entity\n :param str key: record key\n :param bool lock: acquire lock\n :rtype: object\n :return: resume record object\n " ]
Please provide a description of the function:def add_or_update_record( self, final_path, ase, chunk_size, next_integrity_chunk, completed, md5): # type: (DownloadResumeManager, pathlib.Path, # blobxfer.models.azure.StorageEntity, int, int, bool, # str) -> No...
[ "Add or update a resume record\n :param DownloadResumeManager self: this\n :param pathlib.Path final_path: final path\n :param blobxfer.models.azure.StorageEntity ase: Storage Entity\n :param int chunk_size: chunk size in bytes\n :param int next_integrity_chunk: next integrity chu...
Please provide a description of the function:def add_or_update_record( self, local_path, ase, chunk_size, total_chunks, completed_chunks, completed, md5): # type: (UploadResumeManager, pathlib.Path, # blobxfer.models.azure.StorageEntity, int, int, int, bool, # ...
[ "Add or update a resume record\n :param UploadResumeManager self: this\n :param pathlib.Path local_path: local path\n :param blobxfer.models.azure.StorageEntity ase: Storage Entity\n :param int chunk_size: chunk size in bytes\n :param int total_chunks: total chunks\n :param...
Please provide a description of the function:def add_or_update_record( self, dst_ase, src_block_list, offset, chunk_size, total_chunks, completed_chunks, completed): # type: (SyncCopyResumeManager, # blobxfer.models.azure.StorageEntity, list, int, int, int, # ...
[ "Add or update a resume record\n :param SyncCopyResumeManager self: this\n :param blobxfer.models.azure.StorageEntity dst_ase: Storage Entity\n :param list src_block_list: source block list\n :param int offset: offset\n :param int chunk_size: chunk size in bytes\n :param in...
Please provide a description of the function:def update_progress_bar( go, optext, start, total_files, files_sofar, total_bytes, bytes_sofar, stdin_upload=False): # type: (blobxfer.models.options.General, str, datetime.datetime, int, # int, int, int, bool) -> None if (go.quiet or ...
[ "Update the progress bar\n :param blobxfer.models.options.General go: general options\n :param str optext: operation prefix text\n :param datetime.datetime start: start time\n :param int total_files: total number of files\n :param int files_sofar: files transfered so far\n :param int total_bytes: ...
Please provide a description of the function:def output_parameters(general_options, spec): # type: (blobxfer.models.options.General, object) -> None if general_options.quiet: return sep = '============================================' log = [] log.append(sep) log.append(' Az...
[ "Output parameters\n :param blobxfer.models.options.General general_options: general options\n :param object spec: upload or download spec\n " ]
Please provide a description of the function:def compute_md5_for_file_asbase64( filename, pagealign=False, start=None, end=None, blocksize=65536): # type: (str, bool, int, int, int) -> str hasher = blobxfer.util.new_md5_hasher() with open(filename, 'rb') as filedesc: if start is not Non...
[ "Compute MD5 hash for file and encode as Base64\n :param str filename: file to compute MD5 for\n :param bool pagealign: page align data\n :param int start: file start offset\n :param int end: file end offset\n :param int blocksize: block size\n :rtype: str\n :return: MD5 for file encoded as Bas...
Please provide a description of the function:def compute_md5_for_data_asbase64(data): # type: (obj) -> str hasher = blobxfer.util.new_md5_hasher() hasher.update(data) return blobxfer.util.base64_encode_as_string(hasher.digest())
[ "Compute MD5 hash for bits and encode as Base64\n :param any data: data to compute MD5 for\n :rtype: str\n :return: MD5 for data\n " ]
Please provide a description of the function:def check_data_is_empty(data): # type: (bytes) -> bool contentmd5 = compute_md5_for_data_asbase64(data) datalen = len(data) if datalen == _MAX_PAGE_SIZE_BYTES: if contentmd5 == _EMPTY_MAX_PAGE_SIZE_MD5: return True else: d...
[ "Check if data is empty via MD5\n :param bytes data: data to check\n :rtype: bool\n :return: if data is empty\n " ]
Please provide a description of the function:def _worker_process(self): # type: (LocalFileMd5Offload) -> None while not self.terminated: try: key, lpath, fpath, remote_md5, pagealign, lpview = \ self._task_queue.get(True, 0.1) except q...
[ "Compute MD5 for local file\n :param LocalFileMd5Offload self: this\n " ]