Spamworldpro Mini Shell
Spamworldpro


Server : Apache/2.4.52 (Ubuntu)
System : Linux webserver 6.8.0-49-generic #49~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Nov 6 17:42:15 UTC 2 x86_64
User : www-data ( 33)
PHP Version : 8.1.2-1ubuntu2.21
Disable Function : NONE
Directory :  /lib/python3/dist-packages/twisted/python/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/twisted/python/__pycache__/logfile.cpython-310.pyc
o

�b�'�@s�dZddlZddlZddlZddlZddlmZmZmZddl	m
Z
Gdd�d�ZGdd�de�Ze
�
e�Gd	d
�d
e�Ze
�
e�Gdd�d�ZdS)
z!
A rotating, browsable log file.
�N)�BinaryIO�Optional�cast)�
threadablec	@s~eZdZdZddgZ	ddededeeddfd	d
�Ze	dd��Z
d
d�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�ZdS)�BaseLogFilez<
    The base class for a log file that can be rotated.
    �write�rotateN�name�	directory�defaultMode�returncCs`||_||_tj�||�|_|dur'tj�|j�r't�t�|j�tj�|_	n||_	|�
�dS)a
        Create a log file.

        @param name: name of the file
        @param directory: directory holding the file
        @param defaultMode: permissions used to create the file. Default to
        current permissions of the file if the file exists.
        N)r
r	�os�path�join�exists�stat�S_IMODE�ST_MODEr�	_openFile)�selfr	r
r�r�8/usr/lib/python3/dist-packages/twisted/python/logfile.py�__init__s�zBaseLogFile.__init__cOs4tj�|�}|tj�|�tj�|�g|�Ri|��S)z=
        Construct a log file from a full file path.
        )r
r�abspath�basename�dirname)�cls�filename�args�kwargs�logPathrrr�fromFullPath2s(zBaseLogFile.fromFullPathcCst�)zc
        Override with a method to that returns true if the log
        should be rotated.
        )�NotImplementedError�rrrr�shouldRotate:szBaseLogFile.shouldRotatec	Cs�d|_tj�|j�rttt|jdd��|_|j�dd�n.|j	dur@t�
d�}zttt|jdd��|_Wt�
|�nt�
|�wttt|jdd��|_|j	durfzt�|j|j	�WdStyeYdSwdS)z[
        Open the log file.

        The log file is always opened in binary mode.
        Fzrb+r�Ni�zwb+)
�closedr
rrrr�open�_file�seekr�umask�chmod�OSError)r�oldUmaskrrrrAs"


��zBaseLogFile._openFilecCs<|��r|��|��t|t�r|�d�}|j�|�dS)z�
        Write some data to the file.

        @param data: The data to write.  Text will be encoded as UTF-8.
        @type data: L{bytes} or L{unicode}
        �utf8N)r$�flushr�
isinstance�str�encoder(r�r�datarrrr\s

zBaseLogFile.writecCs|j��dS)z!
        Flush the file.
        N)r(r/r#rrrr/jszBaseLogFile.flushcCsd|_|j��|`dS)z[
        Close the file.

        The file cannot be used once it has been closed.
        TN)r&r(�closer#rrrr5ps
zBaseLogFile.closecCs|��|��dS)a"
        Reopen the log file. This is mainly useful if you use an external log
        rotation tool, which moves under your feet.

        Note that on Windows you probably need a specific API to rename the
        file, as it's not supported to simply use os.rename, for example.
        N)r5rr#rrr�reopenzszBaseLogFile.reopencCs
t|j�S)z>
        Return a LogReader for the current log file.
        )�	LogReaderrr#rrr�
getCurrentLog�s
zBaseLogFile.getCurrentLog�N)�__name__�
__module__�__qualname__�__doc__�synchronizedr1r�intr�classmethodr!r$rrr/r5r6r8rrrrrs,����
�

rc@sXeZdZdZ			ddd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�ZdS)�LogFilezf
    A log file that can be rotated.

    A rotateLength of None disables automatic log rotation.
    �@BNcCs t�||||�||_||_dS)a`
        Create a log file rotating on length.

        @param name: file name.
        @type name: C{str}
        @param directory: path of the log file.
        @type directory: C{str}
        @param rotateLength: size of the log file where it rotates. Default to
            1M.
        @type rotateLength: C{int}
        @param defaultMode: mode used to create the file.
        @type defaultMode: C{int}
        @param maxRotatedFiles: if not None, max number of log files the class
            creates. Warning: it removes all log files above this number.
        @type maxRotatedFiles: C{int}
        N)rr�rotateLength�maxRotatedFiles)rr	r
rCrrDrrrr�s
zLogFile.__init__cCst�|�|j��|_dSr9)rrr(�tell�sizer#rrrr�s
zLogFile._openFilecCs|jo|j|jkS)zL
        Rotate when the log file size is larger than rotateLength.
        )rCrFr#rrrr$�szLogFile.shouldRotatecCs*d|j|f}tj�|�std��t|�S)zK
        Given an integer, return a LogReader for an old log file.
        �%s.%d�no such logfile exists)rr
r�
ValueErrorr7�r�
identifierrrrr�getLog�szLogFile.getLogcCs"t�||�|jt|�7_dS)z.
        Write some data to the file.
        N)rrrF�lenr3rrrr�sz
LogFile.writecCs�t�|jtj�rt�|jtj�sdS|��}|��|D])}|jdur3||jkr3t�d|j|f�qt�	d|j|fd|j|df�q|j
��t�	|jd|j�|��dS)z�
        Rotate the file and create a new one.

        If it's not possible to open new logfile, this will fail silently,
        and continue logging to old logfile.
        NrG�z%s.1)
r
�accessr
�W_OKr�listLogs�reverserD�remove�renamer(r5r)r�logs�irrrr�s &
zLogFile.rotatec	Cs\g}t�d|j�D]}zt|�d�d�}|r|�|�Wq
ty'Yq
w|��|S)zM
        Return sorted list of integers - the old logs' identifiers.
        z%s.*�.���)�globrr?�split�appendrI�sort)r�resultr	�counterrrrrQ�s
��zLogFile.listLogscC�t�|�}|d=|S)NrF�r�__getstate__�r�staterrrra��
zLogFile.__getstate__)rBNN)r:r;r<r=rrr$rLrrrQrarrrrrA�s

�	rAc@sPeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�ZdS)�DailyLogFilezAA log file that is rotated daily (at or after midnight localtime)cCs&t�|�|�t�|j�d�|_dS)N�)rr�toDater
rr�lastDater#rrrr�s
zDailyLogFile._openFilecCs|��|jkS)z1Rotate when the date has changed since last write)rgrhr#rrrr$�szDailyLogFile.shouldRotatecGstj|�dd�S)aConvert a unixtime to (year, month, day) localtime tuple,
        or return the current (year, month, day) localtime tuple.

        This function primarily exists so you may overload it with
        gmtime, or some cruft to make unit testing possible.
        N�)�time�	localtime)rrrrrrgszDailyLogFile.toDatec
Cs<z	d�tt|��WStyd�tt|�|���YSw)z>Return the suffix given a (year, month, day) tuple or unixtime�_)r�mapr1�
BaseExceptionrg)r�	tupledaterrr�suffix
s
�zDailyLogFile.suffixcCsJ|�|�|jkr|��S|j�d|�|���}tj�|�s!td��t|�S)z:Given a unix time, return a LogReader for an old log file.rWrH)	rgrhr8rrpr
rrIr7rJrrrrLszDailyLogFile.getLogcCs"t�||�t|j|���|_dS)zWrite some data to the log fileN)rr�maxrhrgr3rrrrszDailyLogFile.writecCspt�|jtj�rt�|jtj�sdS|j�d|�|j���}tj�|�r&dS|j�	�t�
|j|�|��dS)z�Rotate the file and create a new one.

        If it's not possible to open new logfile, this will fail silently,
        and continue logging to old logfile.
        NrW)r
rOr
rPrrprhrr(r5rTr)r�newpathrrrr#s 
zDailyLogFile.rotatecCr_)Nrhr`rbrrrra2rdzDailyLogFile.__getstate__N)r:r;r<r=rr$rgrprLrrrarrrrre�s
	rec@s*eZdZdZdd�Zd
dd�Zdd�Zd	S)r7zRead from a log file.cCst|�|_dS)z�
        Open the log file for reading.

        The comments about binary-mode for L{BaseLogFile._openFile} also apply
        here.
        N)r'r()rr	rrrr>szLogReader.__init__�
cCs4g}t|�D]}|j��}|s|S|�|�q|S)zRead a list of lines from the log file.

        This doesn't returns all of the files lines - call it multiple times.
        )�ranger(�readliner[)r�linesr]rV�linerrr�	readLinesGs
�zLogReader.readLinescCs|j��dSr9)r(r5r#rrrr5TszLogReader.closeN)rs)r:r;r<r=rrxr5rrrrr7;s

	
r7)r=rYr
rrj�typingrrr�twisted.pythonrrrA�synchronizerer7rrrr�<module>sw
f
C

Spamworldpro Mini