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/django/utils/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/django/utils/__pycache__/autoreload.cpython-310.pyc
o

3�a�^�@sddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZddl
mZddlmZddlmZddlZddlmZddlmZddlmZdd	lmZdd
lmZe�Ze�ZdZ e�!d�Z"gZ#da$zddl%Z%Wne&y�dZ%Ynwzddl'Z'Wne&y�dZ'Ynwd
d�Z(dd�Z)dd�Z*dd�Z+dd�Z,dd�Z-ej.dd�dd��Z/ej.dd�dd��Z0dd �Z1d!d"�Z2d#d$�Z3d%d&�Z4Gd'd(�d(�Z5Gd)d*�d*e5�Z6Gd+d,�d,e7�Z8Gd-d.�d.e5�Z9d/d0�Z:d1d2�Z;d3d4�Z<dS)5�N)�defaultdict)�Path)�
ModuleType)�zipimporter)�apps)�request_finished)�Signal)�cached_property)�get_version_tuple�RUN_MAINzdjango.utils.autoreloadcCs|j�d�S)z7Return True if the given module is nested under Django.zdjango.)�__name__�
startswith)�module�r�9/usr/lib/python3/dist-packages/django/utils/autoreload.py�is_django_module1srcCsttj�jt|�jvS)z:Return True if the given file path is nested under Django.)r�django�__file__�parent�parents)�pathrrr�is_django_path6srcst����fdd��}|S)Ncstz
�|i|��WdSty9t��at\}}}t|dd�dur,t�|�dd}n|j}|tvr8t�	|��w)N�filename���r)
�	Exception�sys�exc_info�
_exception�getattr�	traceback�
extract_tbr�_error_files�append)�args�kwargs�et�ev�tbr��fnrr�wrapper<s

�zcheck_errors.<locals>.wrapper)�	functools�wraps)r)r*rr(r�check_errors;sr-cCstdurtd�dS)N�)rrrrr�raise_last_exceptionTs�r/cCs�trtj��s	dSt�tj�}|dtj@sE|dtjO<ttd�r-t�tjtj	�}nd}t�
tjtj|�|durGt�tj|�dSdSdS)z}
    Ensure that echo mode is enabled. Some tools such as PDB disable
    it which causes usability issues after reload.
    N��SIGTTOU)�termiosr�stdin�isatty�	tcgetattr�ECHO�hasattr�signalr1�SIG_IGN�	tcsetattr�TCSANOW)�	attr_list�old_handlerrrr�ensure_echo_onZs
�r>cCs4ttj�}tdd�ttjj|�D��}t|tt��S)Ncss �|]}t|tj�s|VqdS�N)�
isinstance�weakref�
ProxyTypes)�.0�mrrr�	<genexpr>ss�z/iter_all_python_module_files.<locals>.<genexpr>)	�sortedr�modules�tuple�map�__getitem__�iter_modules_and_files�	frozensetr!)�keysrGrrr�iter_all_python_module_filesms
rNr.)�maxsizecCsg}|D]:}t|t�sq|jdkrt|d�r|�|j�qt|dd�dur&q|j}|jr>t|j	t
�r6|j	jn|j}|�|�qt
�}t�||�D]6}|sMqHt|�}z|��sXWqHWntyr}	z
t�d|	|�WYd}	~	qHd}	~	ww|����}
|�|
�qHt|�S)z1Iterate through all modules needed to be watched.�__main__r�__spec__Nz%"%s" raised when resolving path: "%s")r@rrr7r"rrrQ�has_location�loaderr�archive�origin�set�	itertools�chainr�exists�
ValueError�logger�debug�resolve�absolute�addrL)rG�extra_files�sys_file_pathsr�specrU�resultsrr�e�
resolved_pathrrrrKws@



����rKcsbtdd�|D�tdd�}i}|D]}|}|D]}|�|i�}q|��q�fdd��t�|d��S)a
    Return a tuple of common roots that are shared between the given paths.
    File system watchers operate on directories and aren't cheap to create.
    Try to find the minimum set of directories to watch that encompass all of
    the files that need to be watched.
    cS�g|]}|j�qSr)�parts)rC�xrrr�
<listcomp>��z common_roots.<locals>.<listcomp>T)�key�reversec3s@�|��D]\}}�|||f�EdHq|st|�VdSdSr?)�itemsr)�noder�prefix�child��_walkrrrr�s��zcommon_roots.<locals>._walkr)rF�len�
setdefault�clearrH)�paths�
path_parts�tree�chunksrn�chunkrrqr�common_roots�s
r{ccsH�tjD]}t|�}|��sq|����}|��r|jVq|VqdS)zZ
    Yield absolute directories from sys.path, ignoring entries that don't
    exist.
    N)rrrrYr]r^�is_filer)rrerrr�sys_path_directories�s�

�r}cCs�ddl}ttjd�}tjgdd�tjD�}t|dd�dur6|jjr6|d|jjg7}|tjdd�7}|S|�	�sp|�
d�}|�	�rOt|�gtjdd��S|�d	|j
�}|�	�rjg|�t|��tjdd��Std
|��|tj7}|S)z�
    Return the executable. This contains a workaround for Windows if the
    executable is reported to not have the .exe extension which can cause bugs
    on reloading.
    rNcSsg|]}d|�qS)z-W%sr)rC�orrrri�sz'get_child_arguments.<locals>.<listcomp>rQz-mr.z.exez%s-script.pyzScript %s does not exist.)rPrr�argv�
executable�warnoptionsrrQrrY�with_suffix�str�	with_name�name�RuntimeError)rP�	py_scriptr#�exe_entrypoint�script_entrypointrrr�get_child_arguments�s"�

r�cCst�d|�t�d�dS)Nz%s changed, reloading.r0)r[�infor�exit)rrrr�trigger_reload�sr�cCs<itj�tdi�}t�}	tj||dd�}|jdkr|jSq
)N�trueTF)�env�	close_fdsr0)�os�environ�DJANGO_AUTORELOAD_ENVr��
subprocess�run�
returncode)�new_environr#�prrr�restart_with_reloader�s
�r�c@sneZdZdd�Zdd�Zddd�Zdd	�Zd
d�Zdd
�Zdd�Z	e
dd��Zdd�Ze
dd��Zdd�ZdS)�BaseReloadercCs t�|_tt�|_t��|_dSr?)rVr`r�directory_globs�	threading�Event�_stop_condition��selfrrr�__init__	s
zBaseReloader.__init__cCs\t|�}z|��}Wntytjd|dd�YdSwt�d||�|j|�|�dS)Nz6Unable to watch directory %s as it cannot be resolved.T)rzWatching dir %s with glob %s.)rr^�FileNotFoundErrorr[r\r�r_)r�r�globrrr�	watch_dirs��zBaseReloader.watch_dirTccsT�t�EdH|jEdH|r&|j��D]\}}|D]
}|�|�EdHqqdSdS)zq
        Yield all files that need to be watched, including module files and
        files within globs.
        N)rNr`r�rmr�)r��
include_globs�	directory�patterns�patternrrr�
watched_filess���zBaseReloader.watched_filescCs0|��r|jjdd�r
dS|��st�d�dS)a�
        Wait until Django reports that the apps have been loaded. If the given
        thread has terminated before the apps are ready, then a SyntaxError or
        other non-recoverable error has been raised. In that case, stop waiting
        for the apps_ready event and continue processing.

        Return True if the thread is alive and the ready event has been
        triggered, or False if the thread is terminated while waiting for the
        event.
        皙�����?��timeoutTz8Main Django thread has terminated before apps are ready.F)�is_alive�ready_event�waitr[r\)r��app_reg�django_main_threadrrr�wait_for_apps_ready(s�
z BaseReloader.wait_for_apps_readycCsdt�d�|�t|�ddlm}z|�jWn	ty Ynwt�d�tj	|d�|�
�dS)NzWaiting for apps ready_event.r)�get_resolverz>Apps ready_event triggered. Sending autoreload_started signal.)�sender)r[r\r�r�django.urlsr��urlconf_moduler�autoreload_started�send�run_loop)r�r�r�rrrr�:s
�
zBaseReloader.runcCs@|��}|jszt|�Wn	tyYnw|jr|��dSr?)�tick�should_stop�next�
StopIteration�stop)r��tickerrrrr�Ks��zBaseReloader.run_loopcC�td��)aX
        This generator is called in a loop from run_loop. It's important that
        the method takes care of pausing or otherwise waiting for a period of
        time. This split between run_loop() and tick() is to improve the
        testability of the reloader implementations by decoupling the work they
        do from the loop.
        z!subclasses must implement tick().��NotImplementedErrorr�rrrr�TszBaseReloader.tickcCr�)Nz/subclasses must implement check_availability().r���clsrrr�check_availability^szBaseReloader.check_availabilitycCs>tj||d�}t�d||�tdd�|D��st|�dSdS)N)r��	file_pathz+%s notified as changed. Signal results: %s.css�|]}|dVqdS)r.Nr)rC�resrrrrEes�z3BaseReloader.notify_file_changed.<locals>.<genexpr>)�file_changedr�r[r\�anyr�)r�rrcrrr�notify_file_changedbs
�z BaseReloader.notify_file_changedcCs
|j��Sr?)r��is_setr�rrrr�is
zBaseReloader.should_stopcCs|j��dSr?)r�rVr�rrrr�mszBaseReloader.stopN)T)r�
__module__�__qualname__r�r�r�r�r�r�r��classmethodr�r��propertyr�r�rrrrr�s
	


r�c@s,eZdZdZdd�Zdd�Zedd��ZdS)	�StatReloaderr.ccsz�i}	|��D]*\}}|�|�}|||<|dur!t�d||�q||kr2t�d|||�|�|�qt�|j�dVq)NTz File %s first seen with mtime %sz-File %s previous mtime: %s, current mtime: %s)�snapshot_files�getr[r\r��time�sleep�
SLEEP_TIME)r��mtimes�filepath�mtime�old_timerrrr�ts �

��zStatReloader.tickc	csZ�t�}|��D]"}||vrqz|��j}Wn	tyYqw|�|�||fVqdSr?)rVr��stat�st_mtime�OSErrorr_)r��
seen_files�filer�rrrr��s��
�zStatReloader.snapshot_filescCsdS)NTrr�rrrr��szStatReloader.check_availabilityN)rr�r�r�r�r�r�r�rrrrr�qsr�c@seZdZdS)�WatchmanUnavailableN)rr�r�rrrrr��sr�cs�eZdZ�fdd�Zedd��Zdd�Ze��dd��Z	d	d
�Z
dd�Zd
d�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Z�fdd�Zd"dd�Zed d!��Z�ZS)#�WatchmanReloadercs6tt�|_t��|_ttj�	dd��|_
t���dS)N�DJANGO_WATCHMAN_TIMEOUT�)
rrV�rootsr�r��processed_request�intr�r�r��client_timeout�superr�r���	__class__rrr��s

zWatchmanReloader.__init__cCstj|jd�S)Nr�)�
pywatchman�clientr�r�rrrr��szWatchmanReloader.clientcCst|��s|j��st�d|�dS|j}|j�dt|����}d|vr+t�d|d�t�d|�|d|�	d�fS)Nz>Unable to watch root dir %s as neither it or its parent exist.z
watch-project�warningzWatchman warning: %sz!Watchman watch-project result: %s�watch�
relative_path)
rYrr[r�r��queryr�r^r\r�)r��root�resultrrr�_watch_root�s

zWatchmanReloader._watch_rootcCs|j�d|�dS)N�clock)r�r�)r�r�rrr�
_get_clock�szWatchmanReloader._get_clockcCsn|�|�\}}ddddgddgg|g}|dg|�|�dd�}|r$||d	<t�d
|||�|j�d|||�dS)N�allof�anyof�type�f�lr�T)�
expression�fields�since�
dedup_results�
relative_rootz8Issuing watchman subscription %s, for root %s. Query: %s�	subscribe)r�r�r[r\r�r�)r�r�r�r�r��rel_path�only_files_expressionr�rrr�
_subscribe�s��zWatchmanReloader._subscribecsv���s(�j��st�d��dSd�j}�fdd�|D�}�j�d|dg}nd}d|g}|��d|�f|�dS)	N�?Unable to watch directory %s as neither it or its parent exist.zfiles-parent-%sc�g|]	}d�j|f�qS�z%s/%s�r�)rCr�r�rrri��z3WatchmanReloader._subscribe_dir.<locals>.<listcomp>r��	wholename�files�%s:%s)rYrr[r�r�r)r�r��	filenamesror�rrr�_subscribe_dir�s

zWatchmanReloader._subscribe_dircs�d}���s$�j��st�d��dSd�j}�fdd�|D�}�j�dg}|D]
}|�d|d	g�q)|��d
|�f|�dS)a�
        Watch a directory with a specific glob. If the directory doesn't yet
        exist, attempt to watch the parent directory and amend the patterns to
        include this. It's important this method isn't called more than one per
        directory when updating all subscriptions. Subsequent calls will
        overwrite the named subscription, so it must include all possible glob
        expressions.
        r�rNzglob-parent-%scrrr)rCr�rrrri�rz0WatchmanReloader._watch_glob.<locals>.<listcomp>r��matchr	r)rYrr[r�r�r"r)r�r�r�ror�r�rrr�_watch_glob�s	

zWatchmanReloader._watch_globcCs8|j��}dd�|D�}tt��}tg|�|�|�R�S)NcSrfr�r)rCr�rrrri�rjz2WatchmanReloader.watched_roots.<locals>.<listcomp>)r�rM�listr}rL)r�r��extra_directories�watched_file_dirs�	sys_pathsrrr�
watched_roots�s

zWatchmanReloader.watched_rootscs�t|jdd��}t|�|��}t�dt|��t�d|�t|�D]}|�|�q!|j	�
�D]
\�}|��|�q.t|dd�d�}tj
|dd�d�D]\�}|���fd	d
�|D��qJdS)NF)r�zWatching %s fileszFound common roots: %scS�|jSr?r�r�rrr�<lambda>	�z2WatchmanReloader._update_watches.<locals>.<lambda>)rkcSrr?rrrrrr
rcsg|]	}t|�����qSr)r��relative_to)rCr�rrrrirz4WatchmanReloader._update_watches.<locals>.<listcomp>)rr�r{rr[r\rsrFr�r�rmrrW�groupbyr
)r�r��found_rootsr�r��sorted_files�grouprrr�_update_watches�s�z WatchmanReloader._update_watchesc
CsBz|��WdSty }z
|�|�r�WYd}~dSd}~wwr?)rr�check_server_status)r��exrrr�update_watchess
���zWatchmanReloader.update_watchescCsr|j�|�}|s
dSt�d|�|D]$}t|d�dd�d�}t�d|�|�dg�D]	}|�||�q,qdS)Nz%Watchman subscription %s has results.�subscription�:r.zFound root directory %sr
)r��getSubscriptionr[r\r�splitr�r�)r��subr#r��root_directoryr�rrr�_check_subscriptions��z$WatchmanReloader._check_subscriptioncKst�d�|j��dS)Nz0Request processed. Setting update_watches event.)r[r\r�rV)r�r$rrr�request_processed%�
z"WatchmanReloader.request_processedc
cs��t�|j�|��	|j��r|��|j��z|j��Wn't	j
y+Yn.t	jyH}zt�
d|�|�|�WYd}~nd}~wwt|jj���D]}|�|�qQdVt�d�q)NTz+Watchman error: %s, checking server status.r�)r�connectr*r"r�r�rur��receiver��
SocketTimeout�
WatchmanErrorr[r\r r�subsrMr)r�r�)r�r!r'rrrr�)s*�

��
�zWatchmanReloader.tickcs|j��t���dSr?)r��closer�r�r�r�rrr�>r+zWatchmanReloader.stopNcCs0z	|j�d�WdStytt|��|�w)z'Return True if the server is available.�versionT)r�r�rr�r�)r��inner_exrrrr Bs��z$WatchmanReloader.check_server_statuscCshtstd��tjdd�}z|��}Wntytd��wt|d�}t�d|�|dkr2td��dS)	Nzpywatchman not installed.r�r�z'Cannot connect to the watchman service.r2zWatchman version %s)��	z"Watchman 4.9 or later is required.)r�r�r��capabilityCheckrr
r[r\)r�r�r�r2rrrr�Js��z#WatchmanReloader.check_availabilityr?)rr�r�r�r	r�r�r+�	lru_cacher�rr
rrrr"r)r*r�r�r r�r��
__classcell__rrr�rr��s(


r�cCs*zt��Wt�Styt�YSw)z7Return the most suitable reloader for this environment.)r�r�r�r�rrrr�get_reloader\s
�
�r9c
Os�t�t|�}tj|||dd�}d|_|��|jsJz|�|�Wn#tyD}zt	�}t
�d|�t
�d|j
j�WYd}~nd}~ww|jrdSdS)Nzdjango-main-thread)�targetr#r$r�Tz Error connecting to Watchman: %s�!Watching for file changes with %s)r>r-r��Thread�daemon�startr�r�r�r�r[�errorr�r�r)�reloader�	main_funcr#r$r�r!rrr�start_djangoes���rBcOs�t�tjdd��z-tj�t�dkr,t�}t�d|j	j
�t||g|�Ri|��WdSt�}t
�|�WdSty@YdSw)NcWs
t�d�S)Nr)rr�)r#rrrrys
z#run_with_reloader.<locals>.<lambda>r�r;)r8�SIGTERMr�r�r�r�r9r[r�r�rrBr�rr��KeyboardInterrupt)rAr#r$r@�	exit_coderrr�run_with_reloaderxs�rF)=r+rW�loggingr�r8r�rr�r�rrA�collectionsr�pathlibr�typesr�	zipimportrr�django.appsr�django.core.signalsr�django.dispatchr�django.utils.functionalr	�django.utils.versionr
r�r�r��	getLoggerr[r!rr2�ImportErrorr�rrr-r/r>rNr7rKr{r}r�r�r�r�r�r�r�r�r9rBrFrrrr�<module>sv
��



-
%	i&B	

https://t.me/RX1948 - 2025