https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/duplicity/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/duplicity/__pycache__/progress.cpython-310.pyc
o

b�aQ6�@s�dZddlmZddlmZddlmZddlmZmZddlZ	ddl
Z
ddlZddlZddl
Z
ddlmZddlmZdd	lmZdadaGd
d�de	j�ZGdd
�d
e�Zdd�ZGdd�dej�ZdS)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.
�)�absolute_import)�division)�object)�datetime�	timedeltaN)�config)�log)�utilcs^eZdZdZedd��Zdd�Zgdf�fdd�	Zd	d
�Zdd�Z	d
d�Z
�fdd�Z�Z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
Cs�t�}tjdurHtjjdkrHztdtjjd�}t�|�}|�	�W|St
yG}zt�d�
t�|��tjj�t�}WYd}~|Sd}~ww|S)z9
        De-serializes cached data it if present
        N�z%s/progress�rzBWarning, cannot read stored progress info from previous backup: {})r
r�restart�	start_vol�open�archive_dir_path�name�pickle�load�close�	Exceptionr�Warn�formatr	�uexc�WarningCode�cannot_stat)�snapshot�
progressfd�e�r�4/usr/lib/python3/dist-packages/duplicity/progress.py�
unmarshall<s 

����zSnapshot.unmarshallcCs*tdtjjd�}t�||�|��dS)z,
        Serializes object to cache
        s%s/progresszwb+N)rrrrr�dumpr)�selfrrrr�marshallOszSnapshot.marshall�
cstt|��||�d|_dS�Nr)�superr
�__init__�last_vol)r"�iterable�maxlen��	__class__rrr'Ws
zSnapshot.__init__cCs:t|�}|dkr
dS|tdt|||jd|d��S)Nr�r)�len�max�minr()r"�volume�nitemsrrr�get_snapshot[s&zSnapshot.get_snapshotcCs|�|�||_dS�N)�appendr()r"r1�
snapshot_datarrr�
push_snapshotas

zSnapshot.push_snapshotcCs|��Sr4)�popleft�r"rrr�pop_snapshoteszSnapshot.pop_snapshotcstt|���d|_dSr%)r&r
�clearr(r9r+rrr;hs
zSnapshot.clear)
�__name__�
__module__�__qualname__�__doc__�staticmethodr r#r'r3r7r:r;�
__classcell__rrr+rr
6s
r
c@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�ProgressTrackercCs|d|_d|_d|_d|_d|_d|_d|_d|_d|_d|_	d|_
d|_t�|_
d|_t��|_d|_d|_d|_d|_dS)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_datar9rrrr'os&

zProgressTracker.__init__cCs,|jdur|j�||j�|j��dSdS)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)rWr7rHr#�r"r1rrr�snapshot_progress�s
�z!ProgressTracker.snapshot_progresscCs
|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)rCr9rrr�has_collected_evidence�s
z&ProgressTracker.has_collected_evidencecCsbtjr|��s	dSt��}|jdur||_|jdur ||j}nt�}||_|jdur.||_||jj	t
ddtj�krRt�
d|j|j|j||jj	|jd�dS|jd7_	ddlm}|jj|jj}|jj|jj}|dksz|jjdkr|dS|j}|jr�t|j�t|�|_n�t|j�t|jj�}||j}|j|t|j�7_|j|||j7_t� t�!|jt|j���}		t|�t|�|jd	|	d
|j|jd	|	|j|_	|jd
k�r	t|�t|�|jd|	d
|j|jd|	|j|_	|jd
k�r|jt|�t|�|_	t
dt"|j#d
|j#|jd
��|_	|j$|7_$d
}
|jdk�rGd
|j|j}
t%|
t|j$�&���|_|j|k�r\||_	|�&�dk�rv|j'�(t|j|j)�t|�&���|j|_)t*|j'�dk�r�|j'�+�d|_|j'D]
}d|d|j|_�q�t�
d|j|j|j||jj	|jd�dS)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�progressrZr�nowrErNrrM�secondsr/�
progress_rater�TransferProgressrHrIrJrPrD�	duplicityr]�stats�NewFileSize�ChangedFileSizerC�RawDeltaSizerT�floatrUrFrG�math�sqrt�fabsr0rVrO�int�
total_secondsrSr5rKr.r8)r"�current_time�elapsedr]�changes�
total_changes�last_progress_estimation�change_ratio�change_delta�change_sigma�
projection�xrrr�log_upload_progress�s�



�

	����
���
�


�z#ProgressTracker.log_upload_progresscCsBt||jd�}|jt|�7_||_|dkrt��|_dSdS)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/rLrJrnrrarM)r"�	bytecount�changingrrr�annotate_written_bytess�z&ProgressTracker.annotate_written_bytescCs||_||_dS)z�
        Stores the collected statistics from a first-pass dry-run, to use this
        information later so as to estimate progress
        N)rCrT)r"rfrTrrr�set_evidence(s
zProgressTracker.set_evidencecCs0t��|_|j�|�|_tdt|jd��|_dS)Nr-r^)r
r rWr3rVr/r0rHrXrrr�set_start_volume0s
z ProgressTracker.set_start_volumecCst��|jjS)zT
        Elapsed seconds since the first call to log_upload_progress method
        )rrarErbr9rrr�total_elapsed_seconds5sz%ProgressTracker.total_elapsed_secondsN)r<r=r>r'rYrZrzr}r~rr�rrrrrBms

rBcCs&tdurtdurt�|�dSdSdS)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{�
totalbytesrrr�report_transfer<s�r�cs(eZdZdZ�fdd�Zdd�Z�ZS)�LogProgressThreadz_
    Background thread that reports progress to the log,
    every --progress-rate seconds
    cs"tt|���|�d�d|_dS)NTF)r&r�r'�	setDaemon�finishedr9r+rrr'Ms

zLogProgressThread.__init__cCsHtjstjrt��r |js"t��t�tj	�|jr
dSdSdSdSdSr4)
r�dry_runr`r�rZr�rz�time�sleeprcr9rrr�runRs
��zLogProgressThread.run)r<r=r>r?r'r�rArrr+rr�Hsr�)r?�
__future__rr�builtinsrrr�collectionsrQrkr�	threadingr�rerrr	r�r�rRr
rBr��Threadr�rrrr�<module>s(7P

https://t.me/RX1948 - 2025