%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/duplicity/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/duplicity/__pycache__/progress.cpython-312.pyc

�

�2e6����dZddlmZmZddlZddlZddlZddlZddlZddl	m
Z
ddl	mZddl	mZda
daGd�dej�ZGd	�d
e�Zd�ZGd�d
ej(�Zy)a�
Functions to compute progress of compress & upload files
The heuristics try to infer the ratio between the amount of data collected
by the deltas and the total size of the changing files. It also infers the
compression and encryption ration of the raw deltas before sending them to
the backend.
With the inferred ratios, the heuristics estimate the percentage of completion
and the time left to transfer all the (yet unknown) amount of data to send.
This is a forecast based on gathered evidence.
�)�datetime�	timedeltaN)�config)�log)�utilc�V��eZdZdZed��Zd�Zd	�fd�	Zd�Zd�Z	d�Z
�fd�Z�xZS)
�Snapshotz�
    A convenience class for storing snapshots in a space/timing efficient manner
    Stores up to 10 consecutive progress snapshots, one for each volume
    c���t�}tj�ltjjdk\rO	t	tj
j�d�d�}tj|�}|j�|S|S#t$rY}tjdtj|���tjj �t�}Yd}~|Sd}~wwxYw)z9
        De-serializes cached data it if present
        N�z	/progress�rz@Warning, cannot read stored progress info from previous backup: )r	r�restart�	start_vol�open�archive_dir_path�name�pickle�load�close�	Exceptionr�Warnr�uexc�WarningCode�cannot_stat)�snapshot�
progressfd�es   �4/usr/lib/python3/dist-packages/duplicity/progress.py�
unmarshallzSnapshot.unmarshall;s���
�:���>�>�%�&�.�.�*B�*B�a�*G�	
&�!�V�%<�%<�%A�%A�$B�)�"L�c�R�
�!�;�;�z�2��� � �"���x����
&����V�W[�W`�W`�ab�Wc�Vd�e��O�O�/�/��$�:�����
&�s�AB	�		C+�AC&�&C+c��tdtjjzd�}t	j
||�|j
�y)z,
        Serializes object to cache
        s%s/progresszwb+N)rrrrr�dumpr)�selfrs  r�marshallzSnapshot.marshallPs;���.�6�+B�+B�+G�+G�G��O�
����D�*�%�����c�<��|�g}t�|�||�d|_y�Nr)�super�__init__�last_vol)r!�iterable�maxlen�	__class__s   �rr'zSnapshot.__init__Xs$������H�
����6�*���
r#c	��t|�}|dkry|tdt||z|jz
dz
|dz
��S)Nr�r)�len�max�minr()r!�volume�nitemss   r�get_snapshotzSnapshot.get_snapshot^sD���T����Q�;���C��3�v������>��B�F�Q�J�O�P�Q�Qr#c�4�|j|�||_y�N)�appendr()r!r1�
snapshot_datas   r�
push_snapshotzSnapshot.push_snapshotds�����M�"���
r#c�"�|j�Sr5)�popleft�r!s r�pop_snapshotzSnapshot.pop_snapshoths���|�|�~�r#c�0��t�|��d|_yr%)r&�clearr(�r!r+s �rr>zSnapshot.clearks���
��
����
r#)N�
)
�__name__�
__module__�__qualname__�__doc__�staticmethodrr"r'r3r8r<r>�
__classcell__�r+s@rr	r	5s@����
����(��R����r#r	c�<�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
y	)
�ProgressTrackerc�B�d|_d|_d|_d|_d|_d|_d|_d|_d|_d|_	d|_
d|_t�|_
d|_tj �|_d|_d|_d|_d|_y)Nrr-F)�total_stats�nsteps�
start_time�change_mean_ratio�change_r_estimation�progress_estimation�time_estimation�total_bytecount�last_total_bytecount�last_bytecount�stall_last_time�	last_timer�elapsed_sum�speed�sys_collections�deque�	transfers�is_full�current_estimation�prev_estimation�	prev_datar;s rr'zProgressTracker.__init__qs������������!$���#&�� �#&�� � ��� ���$%��!����#������$�;�����
�(�.�.�0������"%���"�����r#c��|j�A|jj||j�|jj�yy)z�
        Snapshots the current progress status for each volume into the disk cache
        If backup is interrupted, next restart will deserialize the data and try start
        progress from the snapshot
        N)r_r8rPr"�r!r1s  r�snapshot_progressz!ProgressTracker.snapshot_progress�s=���>�>�%��N�N�(�(���1I�1I�J��N�N�#�#�%�&r#c��|jduS)z�
        Returns true if the progress computation is on and duplicity has not
        yet started the first dry-run pass to collect some information
        N)rKr;s r�has_collected_evidencez&ProgressTracker.has_collected_evidence�s��
���t�+�+r#c���tjr|j�sytj�}|j
�||_|j�||jz
}n
t�}||_|j�||_||jz
jtddtjz�kDr]tjd|jz|j|j ||j
z
j|j"d�y|xj$dz
c_	ddlm}|j*j,|j*j.z}|j0j,|j0j.z}|dk(s|j*j2dk(ry|j}|j4r(t7|j �t7|�z|_�n�t7|j �t7|j*j2�z}||j:z
}|xj:|t7|j$�zz
c_|xj<|||j:z
zz
c_t?j@t?jB|j<t7|j$�z��}		t7|�t7|�z|j:d	|	zz
d
|j8z
z|j:d	|	zz|j8zzz|_	|j8d
kDr_t7|�t7|�z|j:d|	zz
d
|j8z
z|j:d|	zz|j8zzz|_	|j8d
kDr)|j:t7|�zt7|�z|_	tdtE|jFd
|jFz
|j8zzd
��|_	|xjH|z
c_$d
}
|jdkDrd
|jz
|jz}
tK|
t7|jHjM��z�|_|j|kr||_	|jM�dkDrU|jNjQt7|j |jRz
�t7|jM��z�|j |_)tU|jN�dkDr|jNjW�d|_|jND]}d|zd|j"zz|_�tjd|jz|j|j ||j
z
j|j"d�y)zV
        Aproximative and evolving method of computing the progress of upload
        N��gY@Trr)�diffdirgq=
ףp�?g�?g��Q��?r-�G�z��?�g333333�?gffffff�?F),r�progressrdr�nowrMrVrrU�secondsr/�
progress_rater�TransferProgressrPrQrRrXrL�	duplicityrh�stats�NewFileSize�ChangedFileSizerK�RawDeltaSizer\�floatr]rNrO�math�sqrt�fabsr0r^rW�int�
total_secondsr[r6rSr.r:)r!�current_time�elapsedrh�changes�
total_changes�last_progress_estimation�change_ratio�change_delta�change_sigma�
projection�xs            r�log_upload_progressz#ProgressTracker.log_upload_progress�s0�����d�&A�&A�&C���|�|�~���?�?�"�*�D�O��>�>�%�"�T�^�^�3�G��k�G�%������'�#/�D� ��4�/�/�/�8�8�3�q�!�f�FZ�FZ�BZ�;[�[�� � ���0�0�0��$�$��$�$�����/�8�8��
�
��

�
����q���		�	&��-�-�+�+�g�m�m�.K�.K�K���(�(�4�4�t�7G�7G�7W�7W�W�
��A�����!;�!;�q�!@��$(�#;�#;� ��<�<�&+�D�,@�,@�&A�E�-�DX�&X�D�#�!��!5�!5�6��w�}�}�?Y�?Y�9Z�Z�L�'�$�*@�*@�@�L��"�"�l�U�4�;�;�5G�&G�G�"��$�$���t�G]�G]�8]�(^�^�$��9�9�T�Y�Y�t�/G�/G�%�PT�P[�P[�J\�/\�%]�^�L�
��g���
�&�'��+�+�d�\�.A�A�c�D�Lc�Lc�Fc�d��-�-��|�0C�C�t�G^�G^�^�_��
�#�
��&�&��,��'�N��M�*�+��/�/�$��2E�E�#�PT�Pg�Pg�Jg�h��1�1�D�<�4G�G�4�Kb�Kb�b�c���'�
��&�&��,�*.�*@�*@�5��>�*Q�TY�Zg�Th�*h��'�	�
$'����$�$��d�.B�.B�(B�d�F]�F]�']�]��
�$
�� �	�	
���G�#���
��#�#�a�'��� 8� 8�8�D�<T�<T�T�J�"�:��d�6F�6F�6T�6T�6V�0W�#W�X����#�#�&>�>�'?�D�$�	�� � �"�Q�&��N�N�!�!��d�*�*�T�-F�-F�F�G�%�PW�Pe�Pe�Pg�Jh�h�
�%)�$8�$8��!��t�~�~���#��N�N�"�"�$���
����	4�A��q��3����#3�3�D�J�	4�	����D�,�,�,�� � �� � �
�D�O�O�
+�4�4��J�J��
	
r#c��t||jz
d�}|xjt|�z
c_||_|dkDrt	j
�|_yy)z�
        Annotate the number of bytes that have been added/changed since last time
        this function was called.
        bytecount param will show the number of bytes since the start of the current
        volume and for the current volume
        rN)r/rTrRryrrlrU)r!�	bytecount�changings   r�annotate_written_bytesz&ProgressTracker.annotate_written_bytes.sR���y�4�#6�#6�6��:������H�
�-��'����a�<�#+�<�<�>�D� �r#c� �||_||_y)z�
        Stores the collected statistics from a first-pass dry-run, to use this
        information later so as to estimate progress
        N)rKr\)r!rqr\s   r�set_evidencezProgressTracker.set_evidence;s��
!�����r#c��tj�|_|jj|�|_tdt
|jd��|_y)Nr-ri)r	rr_r3r^r/r0rPras  r�set_start_volumez ProgressTracker.set_start_volumeCsE��!�,�,�.���#�~�~�:�:�6�B���#&�s�C��0D�0D�d�,K�#L�� r#c�X�tj�|jz
jS)zT
        Elapsed seconds since the first call to log_upload_progress method
        )rrlrMrmr;s r�total_elapsed_secondsz%ProgressTracker.total_elapsed_secondsHs���������0�9�9�9r#N)rArBrCr'rbrdr�r�r�r�r��r#rrIrIps-���*&�,�U
�n2��M�
:r#rIc�J�t�t�tj|�yyy)z�
    Method to call tracker.annotate_written_bytes from outside
    the class, and to offer the "function(long, long)" signature
    which is handy to pass as callback
    N)�progress_thread�trackerr�)r��
totalbytess  r�report_transferr�Os%���"�w�':��&�&�y�1�(;�"r#c�(��eZdZdZ�fd�Zd�Z�xZS)�LogProgressThreadz_
    Background thread that reports progress to the log,
    every --progress-rate seconds
    c�>��t�|��d|_d|_y)NTF)r&r'�daemon�finishedr?s �rr'zLogProgressThread.__init__as���
���������
r#c��tjsxtjrgtj	�rR|j
sEtj
�tjtj�|j
s�Dyyyyyr5)
r�dry_runrkr�rdr�r��time�sleeprnr;s r�runzLogProgressThread.runfsR���~�~�&�/�/�g�6T�6T�6V��m�m��+�+�-��
�
�6�/�/�0��m�m�7W�/�~r#)rArBrCrDr'r�rFrGs@rr�r�[s����
�
1r#r�)rDrr�collectionsrYrvr�	threadingr�rprrrr�r�rZr	�objectrIr��Threadr�r�r#r�<module>r�sl��0	��&��
������
����8��$�$�8�v\:�f�\:�~	2�1�	�(�(�1r#

Zerion Mini Shell 1.0