Code stringlengths 103 85.9k | Summary listlengths 0 94 |
|---|---|
Please provide a description of the function:def add_localfile_for_md5_check(
self, key, lpath, fpath, remote_md5, mode, lpview):
# type: (LocalFileMd5Offload, str, str, str, str,
# blobxfer.models.azure.StorageModes, object) -> None
if blobxfer.util.is_none_or_empty(... | [
"Add a local file to MD5 check queue\n :param LocalFileMd5Offload self: this\n :param str key: md5 map key\n :param str lpath: \"local\" path for descriptor\n :param str fpath: \"final\" path for/where file\n :param str remote_md5: remote MD5 to compare against\n :param blo... |
Please provide a description of the function:def populate_from_blob(self, sa, blob, vio=None, store_raw_metadata=False):
# type: (StorageEntity, blobxfer.operations.azure.StorageAccount,
# azure.storage.blob.models.Blob) -> None
if store_raw_metadata:
self._raw_metada... | [
"Populate properties from Blob\n :param StorageEntity self: this\n :param blobxfer.operations.azure.StorageAccount sa: storage account\n :param azure.storage.blob.models.Blob blob: blob to populate from\n :param blobxfer.models.metadata.VectoredStripe vio: Vectored stripe\n :param... |
Please provide a description of the function:def populate_from_file(
self, sa, file, path, vio=None, store_raw_metadata=False,
snapshot=None):
# type: (StorageEntity, blobxfer.operations.azure.StorageAccount,
# azure.storage.file.models.File, str,
# blobxfer... | [
"Populate properties from File\n :param StorageEntity self: this\n :param blobxfer.operations.azure.StorageAccount sa: storage account\n :param azure.storage.file.models.File file: file to populate from\n :param str path: full path to file\n :param blobxfer.models.metadata.Vectore... |
Please provide a description of the function:def populate_from_local(self, sa, container, path, mode, cache_control):
# type: (StorageEntity, blobxfer.operations.azure.StorageAccount
# str, str, blobxfer.models.azure.StorageModes, str) -> None
self._can_create_containers = sa.can... | [
"Populate properties from local\n :param StorageEntity self: this\n :param blobxfer.operations.azure.StorageAccount sa: storage account\n :param str container: container\n :param str path: full path to file\n :param blobxfer.models.azure.StorageModes mode: storage mode\n :p... |
Please provide a description of the function:def add_includes(self, includes):
# type: (_BaseSourcePaths, list) -> None
if not isinstance(includes, list):
if isinstance(includes, tuple):
includes = list(includes)
else:
includes = [includes... | [
"Add a list of includes\n :param _BaseSourcePaths self: this\n :param list includes: list of includes\n "
] |
Please provide a description of the function:def add_excludes(self, excludes):
# type: (_BaseSourcePaths, list) -> None
if not isinstance(excludes, list):
if isinstance(excludes, tuple):
excludes = list(excludes)
else:
excludes = [excludes... | [
"Add a list of excludes\n :param _BaseSourcePaths self: this\n :param list excludes: list of excludes\n "
] |
Please provide a description of the function:def add_path(self, path):
# type: (_BaseSourcePaths, str) -> None
if isinstance(path, pathlib.Path):
self._paths.append(path)
else:
self._paths.append(pathlib.Path(path)) | [
"Add a local path\n :param _BaseSourcePaths self: this\n :param str path: path to add\n "
] |
Please provide a description of the function:def _inclusion_check(self, path):
# type: (_BaseSourcePaths, pathlib.Path) -> bool
_spath = str(path)
inc = True
if self._include is not None:
inc = any([fnmatch.fnmatch(_spath, x) for x in self._include])
if inc a... | [
"Check file for inclusion against filters\n :param _BaseSourcePaths self: this\n :param pathlib.Path path: path to check\n :rtype: bool\n :return: if file should be included\n "
] |
Please provide a description of the function:def add_storage_account(self, name, key, endpoint):
# type: (StorageCredentials, str, str, str) -> None
if name in self._storage_accounts:
raise ValueError(
'{} already exists in storage accounts'.format(name))
sel... | [
"Add a storage account\n :param StorageCredentials self: this\n :param str name: name of storage account to store\n :param str key: storage key or sas\n :param str endpoint: endpoint\n "
] |
Please provide a description of the function:def endpoint(self, value):
# type: (StorageAccount, str) -> None
tmp = value.split('.')
if (len(tmp) <= 1 or not tmp[0].isalnum()):
raise ValueError('endpoint is invalid: {}'.format(value))
self._endpoint = value | [
"Set endpoint\n :param StorageAccount self: this\n :param str value: endpoint\n "
] |
Please provide a description of the function:def _key_is_sas(key):
# type: (str) -> bool
# keys starting with ? are sas keys as ? is not in the base-64
# character range
if key.startswith('?'):
return True
else:
# & is not in the base-64 character... | [
"Determine if key is a sas\n :param str key: key to parse\n :rtype: bool\n :return: if key is a sas\n "
] |
Please provide a description of the function:def _container_manipulation_allowed(self):
# type: (StorageAccount) -> bool
if self.is_sas:
# search for account sas "c" resource
sasparts = self.key.split('&')
for part in sasparts:
tmp = part.spli... | [
"Check if container manipulation is allowed\n :param StorageAccount self: this\n :rtype: bool\n :return: if container manipulation is allowed\n "
] |
Please provide a description of the function:def _ensure_object_manipulation_allowed(self):
# type: (StorageAccount) -> bool
if self.is_sas:
# search for account sas "o" resource
sasparts = self.key.split('&')
for part in sasparts:
tmp = part.... | [
"Check if object manipulation is allowed\n :param StorageAccount self: this\n :rtype: bool\n :return: if object manipulation is allowed\n "
] |
Please provide a description of the function:def _credential_allows_container_list(self):
# type: (StorageAccount) -> bool
if self.is_sas:
sasparts = self.key.split('&')
caccess = self.can_create_containers
# search for container signed resource for service l... | [
"Check if container list is allowed\n :param StorageAccount self: this\n :rtype: bool\n :return: if container list is allowed\n "
] |
Please provide a description of the function:def _create_clients(self, timeout, proxy):
# type: (StorageAccount, blobxfer.models.options.Timeout,
# blobxfer.models.options.HttpProxy) -> None
self._append_blob_client = \
blobxfer.operations.azure.blob.append.create_cli... | [
"Create Azure Storage clients\n :param StorageAccount self: this\n :param blobxfer.models.options.Timeout timeout: timeout\n :param blobxfer.models.options.HttpProxy proxy: proxy\n "
] |
Please provide a description of the function:def add_path_with_storage_account(self, remote_path, storage_account):
# type: (SourcePath, str, str) -> None
if len(self._path_map) >= 1:
raise RuntimeError(
'cannot add multiple remote paths to SourcePath objects')
... | [
"Add a path with an associated storage account\n :param SourcePath self: this\n :param str remote_path: remote path\n :param str storage_account: storage account to associate with path\n "
] |
Please provide a description of the function:def files(self, creds, options, dry_run):
# type: (SourcePath, StorageCredentials,
# blobxfer.models.options.Download, bool) -> StorageEntity
if options.mode == blobxfer.models.azure.StorageModes.File:
for file in self._pop... | [
"Generator of Azure remote files or blobs\n :param SourcePath self: this\n :param StorageCredentials creds: storage creds\n :param blobxfer.models.options.Download options: download options\n :param bool dry_run: dry run\n :rtype: StorageEntity\n :return: Azure storage enti... |
Please provide a description of the function:def _convert_to_storage_entity_with_encryption_metadata(
self, options, store_raw_metadata, sa, entity, vio, is_file,
container, dir, file_snapshot):
# type: (SourcePath, StorageCredentials, any, bool, StorageAccount,
# any, blo... | [
"Convert entity into StorageEntity with encryption metadata if avail\n :param SourcePath self: this\n :param StorageCredentials creds: storage creds\n :param object options: download or synccopy options\n :param bool store_raw_metadata: store raw metadata\n :param StorageAccount s... |
Please provide a description of the function:def _handle_vectored_io_stripe(
self, creds, options, store_raw_metadata, sa, entity, is_file,
container, dir=None, file_snapshot=None):
# type: (SourcePath, StorageCredentials, any, bool, StorageAccount,
# any, bool, str, str) ... | [
"Handle Vectored IO stripe entries\n :param SourcePath self: this\n :param StorageCredentials creds: storage creds\n :param object options: download or synccopy options\n :param bool store_raw_metadata: store raw metadata\n :param StorageAccount sa: storage account\n :param... |
Please provide a description of the function:def _populate_from_list_files(self, creds, options, dry_run):
# type: (SourcePath, StorageCredentials, Any, bool) -> StorageEntity
store_raw_metadata = isinstance(
options, blobxfer.models.options.SyncCopy)
for _path in self._path... | [
"Internal generator for Azure remote files\n :param SourcePath self: this\n :param StorageCredentials creds: storage creds\n :param object options: download or synccopy options\n :param bool dry_run: dry run\n :rtype: StorageEntity\n :return: Azure storage entity object\n ... |
Please provide a description of the function:def _populate_from_list_blobs(self, creds, options, dry_run):
# type: (SourcePath, StorageCredentials, Any, bool) -> StorageEntity
is_synccopy = isinstance(options, blobxfer.models.options.SyncCopy)
for _path in self._paths:
rpath... | [
"Internal generator for Azure remote blobs\n :param SourcePath self: this\n :param StorageCredentials creds: storage creds\n :param object options: download or synccopy options\n :param bool dry_run: dry run\n :rtype: StorageEntity\n :return: Azure storage entity object\n ... |
Please provide a description of the function:def create_client(storage_account, timeout, proxy):
# type: (blobxfer.operations.azure.StorageAccount,
# blobxfer.models.options.Timeout,
# blobxfer.models.options.HttpProxy) -> FileService
if storage_account.is_sas:
client = azure.... | [
"Create file client\n :param blobxfer.operations.azure.StorageAccount storage_account:\n storage account\n :param blobxfer.models.options.Timeout timeout: timeout\n :param blobxfer.models.options.HttpProxy proxy: proxy\n :rtype: FileService\n :return: file service client\n "
] |
Please provide a description of the function:def parse_file_path(filepath):
# type: (pathlib.Path) -> Tuple[str, str, str]
if not isinstance(filepath, pathlib.Path):
filepath = pathlib.Path(filepath)
dirname = '/'.join(filepath.parts[:len(filepath.parts) - 1])
if len(dirname) == 0:
... | [
"Parse file path from file path\n :param str filepath: file path\n :rtype: tuple\n :return: (dirname, rest of path, snapshot)\n "
] |
Please provide a description of the function:def get_file_properties(
client, fileshare, prefix, timeout=None, snapshot=None):
# type: (azure.storage.file.FileService, str, str, int, str) ->
# azure.storage.file.models.File
dirname, fname, ss = parse_file_path(prefix)
if ss is not No... | [
"Get file properties\n :param FileService client: blob client\n :param str fileshare: file share name\n :param str prefix: path prefix\n :param int timeout: timeout\n :param str snapshot: snapshot\n :rtype: azure.storage.file.models.File\n :return: file properties\n "
] |
Please provide a description of the function:def check_if_single_file(client, fileshare, prefix, timeout=None):
# type: (azure.storage.file.FileService, str, str, int) ->
# Tuple[bool, azure.storage.file.models.File]
if blobxfer.util.is_none_or_empty(prefix):
return (False, None)
fil... | [
"Check if prefix is a single file or multiple files\n :param FileService client: blob client\n :param str fileshare: file share name\n :param str prefix: path prefix\n :param int timeout: timeout\n :rtype: tuple\n :return: (if prefix in fileshare is a single file, file)\n "
] |
Please provide a description of the function:def list_files(
client, fileshare, prefix, recursive, timeout=None, snapshot=None):
# type: (azure.storage.file.FileService, str, str, bool, int, str) ->
# azure.storage.file.models.File
# if single file, then yield file and return
_check ... | [
"List files in path\n :param azure.storage.file.FileService client: file client\n :param str fileshare: file share\n :param str prefix: path prefix\n :param bool recursive: recursive\n :param int timeout: timeout\n :param str snapshot: snapshot\n :rtype: azure.storage.file.models.File\n :ret... |
Please provide a description of the function:def list_all_files(client, fileshare, timeout=None):
# type: (azure.storage.file.FileService, str, int) -> str
dirs = [None]
while len(dirs) > 0:
dir = dirs.pop()
files = client.list_directories_and_files(
share_name=fileshare,
... | [
"List all files in share\n :param azure.storage.file.FileService client: file client\n :param str fileshare: file share\n :param int timeout: timeout\n :rtype: str\n :return: file name\n "
] |
Please provide a description of the function:def delete_file(client, fileshare, name, timeout=None):
# type: (azure.storage.file.FileService, str, str, int) -> None
dir, fpath, snapshot = parse_file_path(name)
if blobxfer.util.is_not_empty(snapshot):
raise RuntimeError(
'attempting ... | [
"Delete file from share\n :param azure.storage.file.FileService client: file client\n :param str fileshare: file share\n :param str name: file name\n :param int timeout: timeout\n "
] |
Please provide a description of the function:def get_file_range(ase, offsets, timeout=None):
# type: (blobxfer.models.azure.StorageEntity,
# blobxfer.models.download.Offsets, int) -> bytes
dir, fpath, _ = parse_file_path(ase.name)
return ase.client._get_file(
share_name=ase.container... | [
"Retrieve file range\n :param blobxfer.models.azure.StorageEntity ase: Azure StorageEntity\n :param blobxfer.models.download.Offsets offsets: download offsets\n :param int timeout: timeout\n :rtype: bytes\n :return: content for file range\n "
] |
Please provide a description of the function:def create_share(ase, containers_created, timeout=None):
# type: (blobxfer.models.azure.StorageEntity, dict, int) -> None
# check if auth allows create container
if not ase.can_create_containers:
return
key = ase.client.account_name + ':file=' + ... | [
"Create file share\n :param blobxfer.models.azure.StorageEntity ase: Azure StorageEntity\n :param dict containers_created: containers already created map\n :param int timeout: timeout\n "
] |
Please provide a description of the function:def create_all_parent_directories(ase, dirs_created, timeout=None):
# type: (blobxfer.models.azure.StorageEntity, dict, int) -> None
dirs = pathlib.Path(ase.name).parts
if len(dirs) <= 1:
return
# remove last part (which is the file)
dirs = d... | [
"Create all parent directories for a file\n :param blobxfer.models.azure.StorageEntity ase: Azure StorageEntity\n :param dict dirs_created: directories already created map\n :param int timeout: timeout\n "
] |
Please provide a description of the function:def create_file(ase, timeout=None):
# type: (blobxfer.models.azure.StorageEntity, int) -> None
dir, fpath, _ = parse_file_path(ase.name)
ase.client.create_file(
share_name=ase.container,
directory_name=dir,
file_name=fpath,
co... | [
"Create file remotely\n :param blobxfer.models.azure.StorageEntity ase: Azure StorageEntity\n :param int timeout: timeout\n "
] |
Please provide a description of the function:def put_file_range(ase, offsets, data, timeout=None):
# type: (blobxfer.models.azure.StorageEntity,
# blobxfer.models.upload.Offsets, bytes, int) -> None
dir, fpath, _ = parse_file_path(ase.name)
ase.client.update_range(
share_name=ase.con... | [
"Puts a range of bytes into the remote file\n :param blobxfer.models.azure.StorageEntity ase: Azure StorageEntity\n :param blobxfer.models.upload.Offsets offsets: upload offsets\n :param bytes data: data\n :param int timeout: timeout\n "
] |
Please provide a description of the function:def set_file_properties(ase, md5, timeout=None):
# type: (blobxfer.models.azure.StorageEntity, str, int) -> None
dir, fpath, _ = parse_file_path(ase.name)
ase.client.set_file_properties(
share_name=ase.container,
directory_name=dir,
f... | [
"Set file properties\n :param blobxfer.models.azure.StorageEntity ase: Azure StorageEntity\n :param str md5: md5 as base64\n :param int timeout: timeout\n "
] |
Please provide a description of the function:def set_file_metadata(ase, metadata, timeout=None):
# type: (blobxfer.models.azure.StorageEntity, dict, int) -> None
dir, fpath, _ = parse_file_path(ase.name)
ase.client.set_file_metadata(
share_name=ase.container,
directory_name=dir,
... | [
"Set file metadata\n :param blobxfer.models.azure.StorageEntity ase: Azure StorageEntity\n :param dict metadata: metadata kv pairs\n :param int timeout: timeout\n "
] |
Please provide a description of the function:def get_md5_from_metadata(ase):
# type: (blobxfer.models.azure.StorageEntity) -> str
# if encryption metadata is present, check for pre-encryption
# md5 in blobxfer extensions
md5 = None
if ase.is_encrypted:
try:
md5 = ase.encrypt... | [
"Get MD5 from properties or metadata\n :param blobxfer.models.azure.StorageEntity ase: Azure Storage Entity\n :rtype: str or None\n :return: md5\n "
] |
Please provide a description of the function:def generate_fileattr_metadata(local_path, metadata):
# type: (blobxfer.models.upload.LocalPath, dict) -> dict
if blobxfer.util.on_windows():
global _FILEATTR_WARNED_ON_WINDOWS
if not _FILEATTR_WARNED_ON_WINDOWS:
_FILEATTR_WARNED_ON_W... | [
"Generate file attribute metadata dict\n :param blobxfer.models.upload.LocalPath local_path: local path\n :param dict metadata: existing metadata dict\n :rtype: dict\n :return: merged metadata dictionary\n "
] |
Please provide a description of the function:def fileattr_from_metadata(md):
# type: (dict) -> collections.namedtuple
try:
mdattr = json.loads(
md[JSON_KEY_BLOBXFER_METADATA])[_JSON_KEY_FILE_ATTRIBUTES]
except (KeyError, TypeError):
return None
else:
if blobxfer.... | [
"Convert fileattr metadata in json metadata\n :param dict md: metadata dictionary\n :rtype: PosixFileAttr or WindowsFileAttr or None\n :return: fileattr metadata\n "
] |
Please provide a description of the function:def create_vectored_io_next_entry(ase):
# type: (blobxfer.models.azure.StorageEntity) -> str
return ';'.join(
(ase.client.primary_endpoint, ase.container, ase.name)
) | [
"Create Vectored IO next entry id\n :param blobxfer.models.azure.StorageEntity ase: Azure Storage Entity\n :rtype: str\n :return: vectored io next entry\n "
] |
Please provide a description of the function:def explode_vectored_io_next_entry(entry):
# type: (str, int) -> str
tmp = entry.split(';')
_sa = tmp[0].split('.')
return VectoredNextEntry(
storage_account_name=_sa[0],
endpoint='.'.join(_sa[2:]),
container=tmp[1],
name=... | [
"Explode next vectored io entry\n :param str entry: next entry\n :rtype: VectoredNextEntry\n :return: vectored next entry\n "
] |
Please provide a description of the function:def remove_vectored_io_slice_suffix_from_name(name, slice):
# type: (str, int) -> str
suffix = '.bxslice-{}'.format(slice)
if name.endswith(suffix):
return name[:-len(suffix)]
else:
return name | [
"Remove vectored io (stripe) slice suffix from a given name\n :param str name: entity name\n :param int slice: slice num\n :rtype: str\n :return: name without suffix\n "
] |
Please provide a description of the function:def generate_vectored_io_stripe_metadata(local_path, metadata):
# type: (blobxfer.models.upload.LocalPath, dict) -> dict
md = {
_JSON_KEY_VECTORED_IO: {
_JSON_KEY_VECTORED_IO_MODE: _JSON_KEY_VECTORED_IO_STRIPE,
_JSON_KEY_VECTORED_... | [
"Generate vectored io stripe metadata dict\n :param blobxfer.models.upload.LocalPath local_path: local path\n :param dict metadata: existing metadata dict\n :rtype: dict\n :return: merged metadata dictionary\n "
] |
Please provide a description of the function:def vectored_io_from_metadata(md):
# type: (dict) -> collections.namedtuple
try:
mdattr = json.loads(
md[JSON_KEY_BLOBXFER_METADATA])[_JSON_KEY_VECTORED_IO]
except (KeyError, TypeError):
pass
else:
if mdattr[_JSON_KEY_... | [
"Convert vectored io metadata in json metadata\n :param dict md: metadata dictionary\n :rtype: VectoredStripe or None\n :return: vectored io metadata\n "
] |
Please provide a description of the function:def load_rsa_private_key_file(rsakeyfile, passphrase):
# type: (str, str) ->
# cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey
keypath = os.path.expandvars(os.path.expanduser(rsakeyfile))
with open(keypath, 'rb') as keyfile:
re... | [
"Load an RSA Private key PEM file with passphrase if specified\n :param str rsakeyfile: RSA private key PEM file to load\n :param str passphrase: optional passphrase\n :rtype: cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey\n :return: RSAPrivateKey\n "
] |
Please provide a description of the function:def load_rsa_public_key_file(rsakeyfile):
# type: (str, str) ->
# cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey
keypath = os.path.expandvars(os.path.expanduser(rsakeyfile))
with open(keypath, 'rb') as keyfile:
return cryptogra... | [
"Load an RSA Public key PEM file\n :param str rsakeyfile: RSA public key PEM file to load\n :rtype: cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey\n :return: RSAPublicKey\n "
] |
Please provide a description of the function:def rsa_decrypt_base64_encoded_key(rsaprivatekey, enckey):
# type: (cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey,
# str) -> bytes
return rsaprivatekey.decrypt(
base64.b64decode(enckey),
cryptography.hazmat.primitives.asy... | [
"Decrypt an RSA encrypted key encoded as base64\n :param rsaprivatekey: RSA private key\n :type rsaprivatekey:\n cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey\n :param str enckey: base64-encoded key\n :rtype: bytes\n :return: decrypted key\n "
] |
Please provide a description of the function:def rsa_encrypt_key_base64_encoded(rsaprivatekey, rsapublickey, plainkey):
# type: (cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey,
# cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey,
# bytes) -> str
if rsapublickey i... | [
"Encrypt a plaintext key using RSA and PKCS1_OAEP padding\n :param rsaprivatekey: RSA private key\n :type rsaprivatekey:\n cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey\n :param rsapublickey: RSA public key\n :type rsapublickey:\n cryptography.hazmat.primitives.asymmetric.rsa... |
Please provide a description of the function:def pkcs7_pad(buf):
# type: (bytes) -> bytes
padder = cryptography.hazmat.primitives.padding.PKCS7(
cryptography.hazmat.primitives.ciphers.
algorithms.AES.block_size).padder()
return padder.update(buf) + padder.finalize() | [
"Appends PKCS7 padding to an input buffer\n :param bytes buf: buffer to add padding\n :rtype: bytes\n :return: buffer with PKCS7_PADDING\n "
] |
Please provide a description of the function:def pkcs7_unpad(buf):
# type: (bytes) -> bytes
unpadder = cryptography.hazmat.primitives.padding.PKCS7(
cryptography.hazmat.primitives.ciphers.
algorithms.AES.block_size).unpadder()
return unpadder.update(buf) + unpadder.finalize() | [
"Removes PKCS7 padding a decrypted object\n :param bytes buf: buffer to remove padding\n :rtype: bytes\n :return: buffer without PKCS7_PADDING\n "
] |
Please provide a description of the function:def aes_cbc_decrypt_data(symkey, iv, encdata, unpad):
# type: (bytes, bytes, bytes, bool) -> bytes
cipher = cryptography.hazmat.primitives.ciphers.Cipher(
cryptography.hazmat.primitives.ciphers.algorithms.AES(symkey),
cryptography.hazmat.primitiv... | [
"Decrypt data using AES CBC\n :param bytes symkey: symmetric key\n :param bytes iv: initialization vector\n :param bytes encdata: data to decrypt\n :param bool unpad: unpad data\n :rtype: bytes\n :return: decrypted data\n "
] |
Please provide a description of the function:def aes_cbc_encrypt_data(symkey, iv, data, pad):
# type: (bytes, bytes, bytes, bool) -> bytes
cipher = cryptography.hazmat.primitives.ciphers.Cipher(
cryptography.hazmat.primitives.ciphers.algorithms.AES(symkey),
cryptography.hazmat.primitives.ci... | [
"Encrypt data using AES CBC\n :param bytes symkey: symmetric key\n :param bytes iv: initialization vector\n :param bytes data: data to encrypt\n :param bool pad: pad data\n :rtype: bytes\n :return: encrypted data\n "
] |
Please provide a description of the function:def _worker_process(self):
# type: (CryptoOffload) -> None
while not self.terminated:
try:
inst = self._task_queue.get(True, 0.1)
except queue.Empty:
continue
# UNUSED due to AES256-... | [
"Crypto worker\n :param CryptoOffload self: this\n "
] |
Please provide a description of the function:def add_decrypt_chunk(
self, final_path, internal_fdstart, offsets, symkey, iv,
hmac_datafile):
# type: (CryptoOffload, str, int, blobxfer.models.download.Offsets,
# bytes, bytes, str) -> None
self._task_queue.p... | [
"Add a chunk to decrypt\n :param CryptoOffload self: this\n :param str final_path: final path\n :param int internal_fdstart: internal fd offset start\n :param blobxfer.models.download.Offsets offsets: offsets\n :param bytes symkey: symmetric key\n :param bytes iv: initializ... |
Please provide a description of the function:def add_encrypt_chunk(self, local_file, offsets, symkey, iv): # noqa
# type: (CryptoOffload, pathlib.Path, blobxfer.models.upload.Offsets,
# bytes, bytes) -> None
self._task_queue.put(
(CryptoAction.Encrypt, str(local_file... | [
"Add a chunk to encrypt\n :param CryptoOffload self: this\n :param pathlib.Path local_file: local file\n :param blobxfer.models.upload.Offsets offsets: offsets\n :param bytes symkey: symmetric key\n :param bytes iv: initialization vector\n "
] |
Please provide a description of the function:def termination_check(self):
# type: (Downloader) -> bool
with self._transfer_lock:
with self._disk_operation_lock:
return (self._download_terminate or
len(self._exceptions) > 0 or
... | [
"Check if terminated\n :param Downloader self: this\n :rtype: bool\n :return: if terminated\n "
] |
Please provide a description of the function:def termination_check_md5(self):
# type: (Downloader) -> bool
with self._md5_meta_lock:
with self._transfer_lock:
return (self._download_terminate or
(self._all_remote_files_processed and
... | [
"Check if terminated from MD5 context\n :param Downloader self: this\n :rtype: bool\n :return: if terminated from MD5 context\n "
] |
Please provide a description of the function:def ensure_local_destination(creds, spec, dry_run):
# type: (blobxfer.operations.azure.StorageCredentials,
# blobxfer.models.download.Specification, bool) -> None
# ensure destination path is writable given the source
if len(sp... | [
"Ensure a local destination path given a download spec\n :param blobxfer.operations.azure.StorageCredentials creds: creds\n :param blobxfer.models.download.Specification spec: download spec\n :param bool dry_run: dry run\n "
] |
Please provide a description of the function:def create_unique_transfer_operation_id(ase):
# type: (blobxfer.models.azure.StorageEntity) -> str
return ';'.join(
(ase._client.primary_endpoint, ase.path, str(ase.vectored_io))
) | [
"Create a unique transfer operation id\n :param blobxfer.models.azure.StorageEntity ase: storage entity\n :rtype: str\n :return: unique transfer id\n "
] |
Please provide a description of the function:def create_unique_disk_operation_id(dd, offsets):
# type: (blobxfer.models.download.Descriptor,
# blobxfer.models.download.Offsets) -> str
return ';'.join(
(str(dd.final_path), dd.entity._client.primary_endpoint,
... | [
"Create a unique disk operation id\n :param blobxfer.models.download.Descriptor dd: download descriptor\n :param blobxfer.models.download.Offsets offsets: download offsets\n :rtype: str\n :return: unique disk id\n "
] |
Please provide a description of the function:def _update_progress_bar(self):
# type: (Downloader) -> None
blobxfer.operations.progress.update_progress_bar(
self._general_options,
'download',
self._download_start_time,
self._download_total,
... | [
"Update progress bar\n :param Downloader self: this\n "
] |
Please provide a description of the function:def _check_download_conditions(self, lpath, rfile):
# type: (Downloader, pathlib.Path,
# blobxfer.models.azure.StorageEntity) -> DownloadAction
if not lpath.exists():
if rfile.vectored_io is not None:
fpath ... | [
"Check for download conditions\n :param Downloader self: this\n :param pathlib.Path lpath: local path\n :param blobxfer.models.azure.StorageEntity rfile: remote file\n :rtype: DownloadAction\n :return: download action\n "
] |
Please provide a description of the function:def _pre_md5_skip_on_check(self, lpath, rfile):
# type: (Downloader, pathlib.Path,
# blobxfer.models.azure.StorageEntity) -> None
md5 = blobxfer.models.metadata.get_md5_from_metadata(rfile)
key = blobxfer.operations.download.Do... | [
"Perform pre MD5 skip on check\n :param Downloader self: this\n :param pathlib.Path lpath: 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, filename, size, md5_match):
# type: (Downloader, str, str, int, bool) -> None
with self._md5_meta_lock:
rfile = self._md5_map.pop(key)
lpath = pathlib.Path(filename)
if md5_match:
... | [
"Perform post MD5 skip on check\n :param Downloader self: this\n :param str key: md5 map key\n :param str filename: local filename\n :param int size: size of checked data\n :param bool md5_match: if MD5 matches\n "
] |
Please provide a description of the function:def _check_for_crypto_done(self):
# type: (Downloader) -> None
cv = self._crypto_offload.done_cv
while not self.termination_check:
result = None
cv.acquire()
while True:
result = self._crypt... | [
"Check queue for crypto done\n :param Downloader self: this\n "
] |
Please provide a description of the function:def _add_to_download_queue(self, lpath, rfile):
# type: (Downloader, pathlib.Path,
# blobxfer.models.azure.StorageEntity) -> None
# prepare remote file for download
dd = blobxfer.models.download.Descriptor(
lpath, r... | [
"Add remote file to download queue\n :param Downloader self: this\n :param pathlib.Path lpath: local path\n :param blobxfer.models.azure.StorageEntity rfile: remote file\n "
] |
Please provide a description of the function:def _initialize_transfer_threads(self):
# type: (Downloader) -> None
logger.debug('spawning {} transfer threads'.format(
self._general_options.concurrency.transfer_threads))
for _ in range(self._general_options.concurrency.transfe... | [
"Initialize transfer threads\n :param Downloader self: this\n "
] |
Please provide a description of the function:def _wait_for_disk_threads(self, terminate):
# type: (Downloader, bool) -> None
if terminate:
self._download_terminate = terminate
for thr in self._disk_threads:
blobxfer.util.join_thread(thr) | [
"Wait for disk threads\n :param Downloader self: this\n :param bool terminate: terminate threads\n "
] |
Please provide a description of the function:def _worker_thread_transfer(self):
# type: (Downloader) -> None
max_set_len = self._general_options.concurrency.disk_threads << 2
while not self.termination_check:
try:
if len(self._disk_set) > max_set_len:
... | [
"Worker thread download\n :param Downloader self: this\n "
] |
Please provide a description of the function:def _worker_thread_disk(self):
# type: (Downloader) -> None
while not self.termination_check:
try:
dd, offsets, data = self._disk_queue.get(
block=False, timeout=0.1)
except queue.Empty:
... | [
"Worker thread for disk\n :param Downloader self: this\n "
] |
Please provide a description of the function:def _process_download_descriptor(self, dd):
# type: (Downloader, blobxfer.models.download.Descriptor) -> None
# update progress bar
self._update_progress_bar()
# get download offsets
offsets, resume_bytes = dd.next_offsets()
... | [
"Process download descriptor\n :param Downloader self: this\n :param blobxfer.models.download.Descriptor dd: download descriptor\n "
] |
Please provide a description of the function:def _process_data(self, dd, offsets, data):
# type: (Downloader, blobxfer.models.download.Descriptor,
# blobxfer.models.download.Offsets, bytes) -> None
# decrypt if necessary
if dd.entity.is_encrypted:
# slice data... | [
"Process downloaded data for disk\n :param Downloader self: this\n :param blobxfer.models.download.Descriptor dd: download descriptor\n :param blobxfer.models.download.Offsets offsets: offsets\n :param bytes data: data to process\n "
] |
Please provide a description of the function:def _finalize_chunk(self, dd, offsets):
# type: (Downloader, blobxfer.models.download.Descriptor,
# blobxfer.models.download.Offsets) -> None
if dd.entity.is_encrypted:
dd.mark_unchecked_chunk_decrypted(offsets.chunk_num)
... | [
"Finalize written chunk\n :param Downloader self: this\n :param blobxfer.models.download.Descriptor dd: download descriptor\n :param blobxfer.models.download.Offsets offsets: offsets\n "
] |
Please provide a description of the function:def _cleanup_temporary_files(self):
# type: (Downloader) -> None
# iterate through dd map and cleanup files
for key in self._dd_map:
dd = self._dd_map[key]
try:
dd.cleanup_all_temporary_files()
... | [
"Cleanup temporary files in case of an exception or interrupt.\n This function is not thread-safe.\n :param Downloader self: this\n "
] |
Please provide a description of the function:def _catalog_local_files_for_deletion(self):
# type: (Downloader) -> None
if not (self._spec.options.delete_extraneous_destination and
self._spec.destination.is_dir):
return
dst = str(self._spec.destination.path)
... | [
"Catalog all local files if delete extraneous enabled\n :param Downloader self: this\n "
] |
Please provide a description of the function:def _delete_extraneous_files(self):
# type: (Downloader) -> None
logger.info('attempting to delete {} extraneous files'.format(
len(self._delete_after)))
for file in self._delete_after:
if self._general_options.dry_run... | [
"Delete extraneous files cataloged\n :param Downloader self: this\n "
] |
Please provide a description of the function:def _run(self):
# type: (Downloader) -> None
# mark start
self._start_time = blobxfer.util.datetime_now()
logger.info('blobxfer start time: {0}'.format(self._start_time))
# ensure destination path
blobxfer.operations.d... | [
"Execute Downloader\n :param Downloader self: this\n "
] |
Please provide a description of the function:def encryption_metadata_exists(md):
# type: (dict) -> bool
try:
if blobxfer.util.is_not_empty(
md[EncryptionMetadata._METADATA_KEY_NAME]):
return True
except (KeyError, TypeError):
p... | [
"Check if encryption metadata exists in json metadata\n :param dict md: metadata dictionary\n :rtype: bool\n :return: if encryption metadata exists\n "
] |
Please provide a description of the function:def create_new_metadata(self, rsa_public_key):
# type: (EncryptionMetadata,
# cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey)
# -> None
self._rsa_public_key = rsa_public_key
self._symkey = os.urandom(... | [
"Create new metadata entries for encryption (upload)\n :param EncryptionMetadata self: this\n :param cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey:\n rsa public key\n "
] |
Please provide a description of the function:def convert_from_json(self, md, entityname, rsaprivatekey):
# type: (EncryptionMetadata, dict, str,
# cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKey)
# -> None
# populate from encryption data
ed = js... | [
"Read metadata json into objects\n :param EncryptionMetadata self: this\n :param dict md: metadata dictionary\n :param str entityname: entity name\n :param rsaprivatekey: RSA private key\n :type rsaprivatekey:\n cryptography.hazmat.primitives.asymmetric.rsa.RSAPrivateKe... |
Please provide a description of the function:def convert_to_json_with_mac(self, md5digest, hmacdigest):
# type: (EncryptionMetadata, str, str) -> dict
# encrypt keys
enc_content_key = blobxfer.operations.crypto.\
rsa_encrypt_key_base64_encoded(
None, self._rs... | [
"Constructs metadata for encryption\n :param EncryptionMetadata self: this\n :param str md5digest: md5 digest\n :param str hmacdigest: hmac-sha256 digest (data)\n :rtype: dict\n :return: encryption metadata\n "
] |
Please provide a description of the function:def initialize_hmac(self):
# type: (EncryptionMetadata) -> hmac.HMAC
if self._signkey is not None:
return hmac.new(self._signkey, digestmod=hashlib.sha256)
else:
return None | [
"Initialize an hmac from a signing key if it exists\n :param EncryptionMetadata self: this\n :rtype: hmac.HMAC or None\n :return: hmac\n "
] |
Please provide a description of the function:def remote_is_file(self):
# type: (Descriptor) -> bool
return self.dst_entity.mode == blobxfer.models.azure.StorageModes.File | [
"Remote destination is an Azure File\n :param Descriptor self: this\n :rtype: bool\n :return: remote is an Azure File\n "
] |
Please provide a description of the function:def remote_is_page_blob(self):
# type: (Descriptor) -> bool
return self.dst_entity.mode == blobxfer.models.azure.StorageModes.Page | [
"Remote destination is an Azure Page Blob\n :param Descriptor self: this\n :rtype: bool\n :return: remote is an Azure Page Blob\n "
] |
Please provide a description of the function:def remote_is_block_blob(self):
# type: (Descriptor) -> bool
return self.dst_entity.mode == blobxfer.models.azure.StorageModes.Block | [
"Remote destination is an Azure Block Blob\n :param Descriptor self: this\n :rtype: bool\n :return: remote is an Azure Block Blob\n "
] |
Please provide a description of the function:def complete_offset_upload(self, chunk_num):
# type: (Descriptor, int) -> None
with self._meta_lock:
self._outstanding_ops -= 1
# save resume state
if self.is_resumable:
# only set resumable complet... | [
"Complete the upload for the offset\n :param Descriptor self: this\n :param int chunk_num: chunk num completed\n "
] |
Please provide a description of the function:def _compute_chunk_size(self):
# type: (Descriptor) -> int
if self._src_block_list is not None:
blen = len(self._src_block_list)
if blen == 0:
# this is a one-shot block blob
return self._src_as... | [
"Compute chunk size given block list\n :param Descriptor self: this\n :rtype: int\n :return: chunk size bytes\n "
] |
Please provide a description of the function:def _compute_total_chunks(self, chunk_size):
# type: (Descriptor, int) -> int
try:
if self._src_block_list is not None:
blen = len(self._src_block_list)
if blen > 0:
return blen
... | [
"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 _resume(self):
# type: (Descriptor) -> int
if self._resume_mgr is None or self._offset > 0:
return None
# check if path exists in resume db
rr = self._resume_mgr.get_record(self._dst_ase)
if rr is None:
... | [
"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 next_offsets(self):
# type: (Descriptor) -> Offsets
resume_bytes = self._resume()
with self._meta_lock:
if self._chunk_num >= self._total_chunks:
return None, resume_bytes
if self._chunk_size == -1 ... | [
"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 can_rename(self):
# type: (LocalSourcePaths) -> bool
return len(self._paths) == 1 and (
self._paths[0].is_file() or
blobxfer.models.upload.LocalSourcePath.is_stdin(
str(self._paths[0]))
) | [
"Check if source can be renamed\n :param LocalSourcePath self: this\n :rtype: bool\n :return: if rename possible\n "
] |
Please provide a description of the function:def files(self, dry_run):
# type: (LocalSourcePaths, bool) -> LocalPath
for _path in self._paths:
_ppath = os.path.expandvars(os.path.expanduser(str(_path)))
# check of path is stdin
if blobxfer.models.upload.Local... | [
"Generator for files in paths\n :param LocalSourcePath self: this\n :param bool dry_run: dry run\n :rtype: LocalPath\n :return: LocalPath\n "
] |
Please provide a description of the function:def remote_is_append_blob(self):
# type: (Descriptor) -> bool
return self.entity.mode == blobxfer.models.azure.StorageModes.Append | [
"Remote destination is an Azure Append Blob\n :param Descriptor self: this\n :rtype: bool\n :return: remote is an Azure Append Blob\n "
] |
Please provide a description of the function:def complete_offset_upload(self, chunk_num):
# type: (Descriptor, int) -> None
with self._meta_lock:
self._outstanding_ops -= 1
# save resume state
if self.is_resumable:
# only set resumable complet... | [
"Complete the upload for the offset\n :param Descriptor self: this\n :param int chunk_num: chunk num completed\n "
] |
Please provide a description of the function:def _initialize_encryption(self, options):
# type: (Descriptor, blobxfer.models.options.Upload) -> None
if (options.rsa_public_key is not None and self.local_path.size > 0 and
(self._ase.mode == blobxfer.models.azure.StorageModes.Bloc... | [
"Download is resume capable\n :param Descriptor self: this\n :param blobxfer.models.options.Upload options: upload options\n "
] |
Please provide a description of the function:def _compute_remote_size(self, options):
# type: (Descriptor, blobxfer.models.options.Upload) -> None
size = self.local_path.size
if (self._ase.mode == blobxfer.models.azure.StorageModes.Page and
self.local_path.use_stdin):
... | [
"Compute total remote file size\n :param Descriptor self: this\n :param blobxfer.models.options.Upload options: upload options\n :rtype: int\n :return: remote file size\n "
] |
Please provide a description of the function:def _adjust_chunk_size(self, options):
# type: (Descriptor, blobxfer.models.options.Upload) -> None
chunk_size = options.chunk_size_bytes
# auto-select chunk size
if chunk_size == 0:
if self._ase.mode != blobxfer.models.az... | [
"Adjust chunk size for entity mode\n :param Descriptor self: this\n :param blobxfer.models.options.Upload options: upload options\n "
] |
Please provide a description of the function:def _compute_total_chunks(self, chunk_size):
# type: (Descriptor, int) -> int
try:
chunks = int(math.ceil(self._ase.size / chunk_size))
except ZeroDivisionError:
chunks = 1
# for stdin, override and use 1 chunk... | [
"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.Upload) -> None
if self._ase.is_encrypted:
# ensure symmetric key exists
if blobxfer.util.is_none_or_empty(
se... | [
"Initialize file integrity checkers\n :param Descriptor self: this\n :param blobxfer.models.options.Upload options: upload options\n "
] |
Please provide a description of the function:def _resume(self):
# type: (Descriptor) -> int
if self._resume_mgr is None or self._offset > 0:
return None
# check if path exists in resume db
rr = self._resume_mgr.get_record(self._ase)
if rr is None:
... | [
"Resume upload\n :param Descriptor self: this\n :rtype: int\n :return: resume bytes\n "
] |
Please provide a description of the function:def next_offsets(self):
# type: (Descriptor) -> Offsets
resume_bytes = self._resume()
with self._meta_lock:
if self._chunk_num >= self._total_chunks:
return None, resume_bytes
if self._offset + self._ch... | [
"Retrieve the next offsets\n :param Descriptor self: this\n :rtype: Offsets\n :return: upload offsets\n "
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.