HEX
Server: LiteSpeed
System: Linux s3.sitechai.com 4.18.0-553.51.1.lve.1.el8.x86_64 #1 SMP Wed May 14 14:34:57 UTC 2025 x86_64
User: workzeni (2217)
PHP: 8.1.32
Disabled: mail, show_source, system, shell_exec, passthru, exec, eval, shell
Upload Files
File: //usr/lib64/python3.6/site-packages/borg/testsuite/__pycache__/__init__.cpython-36.pyc
3

y��b$1�(@spddlmZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
mZddlmZddlmZddlmZmZmZddlmZyddlZeejd	�ZWnek
r�d
ZYnXyddlmZWndZYnXeed��pejjd
�Zy(e	j ��Z!ej"e!j#ej$�WdQRXWne%k
�rVd
ZYnXyddlZd�pjeZ&Wnek
�r�d
Z&YnXde'edg�k�r�dZ(ndej)�k�r�d,Z(nd-Z(ejjd��r�d.Z(edd��Z*ej+�dd��Z,ej+�dd��Z-ej+�dd��Z.ej+�dd��Z/ej+�d d!��Z0d"d#�Z1Gd$d%�d%ej2�Z3Gd&d'�d'�Z4Gd(d)�d)�Z5Gd*d+�d+�Z6dS)/�)�contextmanagerN�)�get_all)�	get_flags)�umount)�EXIT_SUCCESS�EXIT_WARNING�
EXIT_ERROR)�platform�st_mtime_nsF)�raisesZlchflags�linuxT�
HAVE_FUTIMENS�_have_functions�HAVE_UTIMES��	�netbsd�c
cs(tj��}tjj|d�VWdQRXdS)N�file)�tempfileZTemporaryDirectory�os�path�join)Ztempdir�r� /usr/lib64/python3.6/__init__.py�unopened_tempfile;s
rcCs\t��L}y0tjd|�tj|dd�r6tj|�dkr6dSWntk
rLYnXWdQRXdS)NZ	somewhereF)�follow_symlinksT)rr�symlink�stat�readlink�OSError)�filepathrrr�are_symlinks_supportedAsr#cCs�ttd�sdSt���}t��z}t|d�j�yPtj||�tj|�}tj|�}|j|jkoddknrz|j|jkrzdSWnt	k
r�YnXWdQRXWdQRXdS)N�linkF�wrT)
�hasattrrr�open�closer$r�st_nlink�st_inor!)Z	file1pathZ	file2pathZstat1Zstat2rrr�are_hardlinks_supportedMs


(r+cCs:t��*}ytj|�dStk
r*dSXWdQRXdS)NTF)rr�mkfifor!)r"rrr�are_fifos_supported`s
r-cCs�t��x}t�rtjd|�nt|d�j�y:tj|ddd�tj|dd�}|jdkrb|j	dkrbdSWnt
k
rxYnXdSQRXdS)	N�	somethingr%����F)rT)r/r0)rr#rrr'r(�utimer�st_atime�st_mtimer!)r"�	new_statsrrr�is_utime_fully_supportedjsr5cCs�ttjd�sdSt���}t�r,tjd|�nt|d�j�yfd
\}}}tj|||fdd�tj|||fdd�tj	|dd�}|j
|kr�|j|kr�|j|kr�d	SWnt
k
r�YnXdSQRXdS)N�st_birthtimeFr.r%��k8�Cm8��n8)rT)r7r8r9)r&r�stat_resultrr#rr'r(r1rr6r3r2r!)r"Z	birthtime�mtimeZatimer4rrr�is_birthtime_fully_supported|s 
r<csDd�t|t�r$�fdd�|j�D�St|t�r@�fdd�|D�SdS)Nzsecurity.selinuxcsi|]\}}|�kr||�qSrr)�.0�k�v)�SELINUX_KEYrr�
<dictcomp>�szno_selinux.<locals>.<dictcomp>csg|]}|�kr|�qSrr)r=r>)r@rr�
<listcomp>�szno_selinux.<locals>.<listcomp>)�
isinstance�dict�items�list)�xr)r@r�
no_selinux�s


rHc@s�eZdZdZejjZejjZ	ejj
ZejjZ
er:ee�ZnejjZedd��Zdd�Zddd�Zedd
d��Zdd
�dd�Zedd��Zd	S)�BaseTestCasez
    ccs@tjj|�stdj|���dVtjj|�s<tdj|���dS)Nz{} should not existz{} should exist)rr�exists�AssertionError�format)�selfrrrr�assert_creates_file�sz BaseTestCase.assert_creates_filecKstj||�}|j|f|�dS)N)�filecmpZdircmp�_assert_dirs_equal_cmp)rMZdir1Zdir2�kwargs�diffrrr�assert_dirs_equal�szBaseTestCase.assert_dirs_equalFc
s�|j|jg�|j|jg�|j|jg�|j|jg��x|jD�]}tjj|j	|�}tjj|j
|�}tj|dd��tj|dd���j�jk}dddg}	|s�tjj
|�r�|	jd�|g�fdd�|	D�}
|g�fd	d�|	D�}|
jd
t�j��|jd
t�j��|�s2|
jt|���|jt|���tj�j��rZtj�j��rZd|
d<tj�j��r�tj�j��r�d|d<t��r|�r�|
jt�jd��|jt�jd��nX|�r�t�r�|
jt�jd��|jt�jd��n$|
jt�jt��|jt�jt��|�sD|
jtt|dd���|jtt|dd���|j|
|�qBWx&|jj�D]}|j||||d
��q`WdS)NF)r�st_uid�st_gid�st_rdevr)csg|]}t�|��qSr)�getattr)r=�a)�s1rrrB�sz7BaseTestCase._assert_dirs_equal_cmp.<locals>.<listcomp>csg|]}t�|��qSr)rW)r=rX)�s2rrrB�s�rge��A)�ignore_bsdflags�
ignore_xattrs�	ignore_ns���r_) �assert_equalZ	left_onlyZ
right_onlyZ
diff_filesZfunny_files�commonrrr�left�rightr�st_dev�isdir�append�insert�oct�st_moder�S_ISCHR�S_ISBLKr5�intr�have_fuse_mtime_ns�round�st_mtime_ns_roundrHrZsubdirs�valuesrP)
rMrRr\r]r^�filenameZpath1Zpath2ZfuseZattrsZd1Zd2Zsub_diffr)rYrZrrP�sN

  z#BaseTestCase._assert_dirs_equal_cmpNcos�|dkrtj�}n
tj|�d|kr,d|d<|jd||f|�|�|jdt�tkr\dVdS|j|dd�dVt	|�|j|dd�tj
|�tjd�dS)N�forkT�mountZ	exit_code)�mountedFg�������?)
rZmkdtempr�mkdir�cmd�getrr	�wait_for_mountstater�rmdir�time�sleep)rM�location�
mountpointZoptionsrQrrr�
fuse_mount�s

	
zBaseTestCase.fuse_mount�)�timeoutcCs\|tj�7}x.|tj�kr:tjj|�|kr.dStjd�qWd|rFdnd|f}t|��dS)z4Wait until a path meets specified mount point statusNg�������?zWaiting for %s of %srsr)rzrr�ismountr{�TimeoutError)rMr}rtr��messagerrrrxsz BaseTestCase.wait_for_mountstateccs�tjjd�rd|}d|}nPtjjd�r<d|}d	|}n2tjjd
�rZd|}d|}nd
tj}|j|�z"tjd|�tj|�dVWdtj|�tjd|�XdS)a�Some paths need to be made read-only for testing

        If the tests are executed inside a fakeroot environment, the
        changes from chmod won't affect the real permissions of that
        folder. This issue is circumvented by temporarily disabling
        fakeroot with `LD_PRELOAD=`.

        Using chmod to remove write permissions is not enough if the
        tests are running with root privileges. Instead, the folder is
        rendered immutable with chattr or chflags, respectively.
        r
zchattr +i "%s"zchattr -i "%s"�darwin�freebsdr�openbsdzchflags uchg "%s"zchflags nouchg "%s"�sunoszchmod S+vimmutable "%s"zchmod S-vimmutable "%s"z7Testing read-only repos is not supported on platform %szLD_PRELOAD= chmod -R ugo-w "%s"NzLD_PRELOAD= chmod -R ugo+w "%s")r�r�rr�)�sysr
�
startswithZskipTestr�system)rMrZ
cmd_immutableZcmd_mutabler�rrr�	read_only
s"








zBaseTestCase.read_only)FFF)N)�__name__�
__module__�__qualname__�__doc__�unittest�TestCaseZassertInZ	assert_inZassertNotInZ
assert_not_inZassertEqualr`ZassertNotEqualZassert_not_equalr�staticmethodZ
assert_raisesZassertRaisesrrNrSrPr~rxr�rrrrrI�s

0 
rIc@s$eZdZdd�Zdd�Zdd�ZdS)�	changedircCs
||_dS)N)�dir)rMr�rrr�__init__1szchangedir.__init__cCstj�|_tj|j�dS)N)r�getcwd�old�chdirr�)rMrrr�	__enter__4s
zchangedir.__enter__cOstj|j�dS)N)rr�r�)rM�args�kwrrr�__exit__8szchangedir.__exit__N)r�r�r�r�r�r�rrrrr�0sr�c@s$eZdZdd�Zdd�Zdd�ZdS)�environment_variablecKs||_i|_dS)N)rp�
old_values)rMrprrrr�=szenvironment_variable.__init__cCsPxJ|jj�D]<\}}tjj|�|j|<|dkr>tjj|d�q|tj|<qWdS)N)rprEr�environrwr��pop)rMr>r?rrrr�As
zenvironment_variable.__enter__cOs>x8|jj�D]*\}}|dkr,tjj|d�q|tj|<qWdS)N)r�rErr�r�)rMr�r�r>r?rrrr�Iszenvironment_variable.__exit__N)r�r�r�r�r�r�rrrrr�<sr�c@s"eZdZdZdd�Zddd�ZdS)�
FakeInputszASimulate multiple user inputs, can be used as input() replacementcCs
||_dS)N)�inputs)rMr�rrrr�SszFakeInputs.__init__NcCs@|dk	rt|dd�y|jjd�Stk
r:td�YnXdS)N�)�endr)�printr�r��
IndexError�EOFError)rM�promptrrr�__call__VszFakeInputs.__call__)N)r�r�r�r�r�r�rrrrr�Qsr�i����i����r_)7�
contextlibrrO�	functoolsr�posixrr��	sysconfigrrzZuuidr�Zxattrrr
rZhelpersrrrr	r�Zllfuser&ZEntryAttributesrm�ImportErrorZpytestrr�Zhas_lchflagsZNamedTemporaryFilerZ	set_flags�name�	UF_NODUMPr!Z
has_llfuserWro�get_config_varsr�	lru_cacher#r+r-r5r<rHr�rIr�r�r�rrrr�<module>sn