HEX
Server: LiteSpeed
System: Linux kapuas.iixcp.rumahweb.net 5.14.0-427.42.1.el9_4.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Nov 1 14:58:02 EDT 2024 x86_64
User: mirz4654 (1666)
PHP: 8.1.33
Disabled: system,exec,escapeshellarg,escapeshellcmd,passthru,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,popen,pclose,dl,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setsid,posix_setuid,posix_setpgid,ini_alter,show_source,define_syslog_variables,symlink,syslog,openlog,openlog,closelog,ocinumcols,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dll,ftp,myshellexec,socket_bind,mail,posix_getwpuid
Upload Files
File: //usr/local/lib/python3.9/site-packages/celery/backends/__pycache__/azureblockblob.cpython-39.pyc
a

X>h��@s�dZddlmZddlmZddlmZddlm	Z	ddl
mZddlm
Z
z2dd	lmmZdd
lmZmZddlmZWney�d	ZYn0dZee�Zd
ZGdd�de
�Zd	S)z0The Azure Storage Block Blob backend for Celery.�)�	Transport)�cached_property)�bytes_to_str)�ImproperlyConfigured)�
get_logger�)�KeyValueStoreBackendN)�ResourceExistsError�ResourceNotFoundError)�BlobServiceClient)�AzureBlockBlobBackendzazureblockblob://csheZdZdZd�fdd�	Zeefdd��Zedd��Z	d	d
�Z
dd�Zd
d�Zdd�Z
ddd�Z�ZS)rz,Azure Storage Block Blob backend for Celery.Ncs|t�j|i|��tdus$tjdkr,td��|jj}|�|�|_|pJ|d|_	|�
dd�|_|�
dd�|_|�
d	d
�|_
dS)z�
        Supported URL formats:

        azureblockblob://CONNECTION_STRING
        azureblockblob://DefaultAzureCredential@STORAGE_ACCOUNT_URL
        azureblockblob://ManagedIdentityCredential@STORAGE_ACCOUNT_URL
        NZ12zWYou need to install the azure-storage-blob v12 library touse the AzureBlockBlob backendZazureblockblob_container_nameZazureblockblob_base_path�Z!azureblockblob_connection_timeout�Zazureblockblob_read_timeout�x)�super�__init__�azurestorage�__version__rZapp�conf�
_parse_url�_connection_string�_container_name�get�	base_path�_connection_timeout�
_read_timeout)�self�urlZcontainer_name�args�kwargsr��	__class__��H/usr/local/lib/python3.9/site-packages/celery/backends/azureblockblob.pyrs���zAzureBlockBlobBackend.__init__cCs |t|�d�}|std��|S)NzInvalid URL)�lenr)�clsr�prefixZconnection_stringr"r"r#r<sz AzureBlockBlobBackend._parse_urlcCs�d|jvsd|jvr:t�|j�\}}t|||j|jd�}ntj|j|j|jd�}z |j|jd�d|j�d�}Wn t	y�d|j�d	�}Yn0t
�|�|S)
z�Return the Azure Storage Blob service client.

        If this is the first call to the property, the client is created and
        the container is created if it doesn't yet exist.

        ZDefaultAzureCredentialZManagedIdentityCredential)Zaccount_urlZ
credential�connection_timeout�read_timeout)r'r()�namezContainer created with name �.zContainer with name z* already.exists. This will not be created.)r�AzureStorageQueuesTransport�	parse_urirrrZfrom_connection_stringZcreate_containerrr	�LOGGER�info)rZcredential_r�client�msgr"r"r#�_blob_service_clientDs2	�����
z*AzureBlockBlobBackend._blob_service_clientcCs`t|�}t�d|j|�|jj|j|j�|��d�}z|�����	�WSt
yZYdS0dS)zwRead the value stored at the given key.

        Args:
              key: The key for which to read the value.
        zGetting Azure Block Blob %s/%s��	container�blobN)rr-�debugrr1�get_blob_clientrZ
download_blob�readall�decoder
�r�key�blob_clientr"r"r#rks�zAzureBlockBlobBackend.getcCsNt|�}t�d|j�d|���|jj|j|j�|��d�}|j|dd�dS)z�Store a value for a given key.

        Args:
              key: The key at which to store the value.
              value: The value to store.

        zCreating azure blob at �/r2T)�	overwriteN)rr-r5rr1r6rZupload_blob)rr:�valuer;r"r"r#�set~s�zAzureBlockBlobBackend.setcs�fdd�|D�S)zqRead all the values for the provided keys.

        Args:
              keys: The list of keys to read.

        csg|]}��|��qSr")r)�.0r:�rr"r#�
<listcomp>��z.AzureBlockBlobBackend.mget.<locals>.<listcomp>r")r�keysr"rAr#�mget�szAzureBlockBlobBackend.mgetcCsHt|�}t�d|j�d|���|jj|j|j�|��d�}|��dS)zlDelete the value at a given key.

        Args:
              key: The key of the value to delete.

        zDeleting azure blob at r<r2N)rr-r5rr1r6rZdelete_blobr9r"r"r#�delete�s�zAzureBlockBlobBackend.deleteFcsF|rt�|j��S|j�d�}d��fdd�|D�}t�d�|���S)N�;zAccountKey=cs$g|]}|���r��d�n|�qS)z**)�
startswith)r@�part�Zaccount_key_prefixr"r#rB�s�z0AzureBlockBlobBackend.as_uri.<locals>.<listcomp>)�"AZURE_BLOCK_BLOB_CONNECTION_PREFIXr�split�join)rZinclude_passwordZconnection_string_partsZ redacted_connection_string_partsr"rJr#�as_uri�s��
���zAzureBlockBlobBackend.as_uri)NN)F)�__name__�
__module__�__qualname__�__doc__r�classmethodrKrrr1rr?rErFrN�
__classcell__r"r"r r#rs�!
&	r)rRZ"kombu.transport.azurestoragequeuesrr+Zkombu.utilsrZkombu.utils.encodingrZcelery.exceptionsrZcelery.utils.logr�baserZazure.storage.blobZstorager4rZazure.core.exceptionsr	r
r�ImportError�__all__rOr-rKrr"r"r"r#�<module>s