OwlCyberSecurity - MANAGER
Edit File: config.cpython-38.opt-1.pyc
U ����e5d�����������������������@���sN��d�Z�ddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl mZmZ�dZ ejZdad+dd�Zdd ��Zd d��Zdd ��Zdd��Zdd��Zdd��Zdd��Ze�dej�Zdd��ZG�dd��de�ZG�dd��dee�Z G�dd��de!e�Z"G�dd ��d e#e�Z$G�d!d"��d"e�Z%G�d#d$��d$e%�Z&e&Z'd%d&��Z(e dfd'd(�Z)d)d*��Z*dS�),a�� Configuration functions for the logging package for Python. The core package is based on PEP 282 and comments thereto in comp.lang.python, and influenced by Apache's log4j system. Copyright (C) 2001-2019 Vinay Sajip. All Rights Reserved. To use, simply 'import logging' and log away! �����N)�ThreadingTCPServer�StreamRequestHandleriF#��Tc�����������������C���s����ddl�}t|�|j�r|�}n*|�|�}t|�d�r:|�|���n |�|���t|�}t� ���z t���t||�}t |||��W�5�t� ���X�dS�)aD�� Read the logging configuration from a ConfigParser-format file. This can be called several times from an application, allowing an end user the ability to select from various pre-canned configurations (if the developer provides a mechanism to present the choices and load the chosen configuration). r���N�readline)�configparser� isinstanceZRawConfigParserZConfigParser�hasattrZ read_file�read�_create_formatters�logging�_acquireLock�_releaseLock�_clearExistingHandlers�_install_handlers�_install_loggers)Zfname�defaults�disable_existing_loggersr����cp� formatters�handlers��r����&/usr/lib64/python3.8/logging/config.py� fileConfig3���s���� r���c�������������� ���C���sl���|���d�}�|��d�}t|�}|�D�]F}|d�|�}zt||�}W�q �tk rd���t|��t||�}Y�q X�q |S�)z)Resolve a dotted name to a global object.�.r���)�split�pop� __import__�getattr�AttributeError)�name�used�found�nr���r���r����_resolveU���s���� r"���c�����������������C���s���t�tj|��S��N)�map�str�strip)Zalistr���r���r���� _strip_spacesc���s����r'���c�����������������C���s����|�d�d�}t�|�si�S�|�d�}t|�}i�}|D�]v}d|�}|�j|dddd�}|�j|d ddd�}|�j|d ddd�}tj}|�|��d�} | r�t| �}||||�} | ||<�q2|S�) zCreate and return formattersr����keys�,zformatter_%s�formatTN)�raw�fallback�datefmt�style�%�class)�lenr���r'����getr ���� Formatterr"���)r���Zflistr���ZformZsectnameZfsZdfsZstl�c� class_name�fr���r���r���r ���f���s$���� r ���c�������������� ���C���s^��|�d�d�}t�|�si�S�|�d�}t|�}i�}g�}|D��]}|�d|��}|d�}|�dd�}zt|tt��}W�n �ttfk r����t |�}Y�nX�|�dd �} t| tt��} |�d d�} t| tt��} || | �}d|kr�|d�}|� |��t�|�r�|�||���t|tj j��r2|�d d�} t�| ��r2|�|| f��|||<�q6|D�]\}}|�||����q@|S�)zInstall and return handlersr���r(���r)���z handler_%sr0���� formatter���args�()�kwargsz{}�level�target)r1���r���r'���r2����eval�varsr ���r���� NameErrorr"����setLevel�setFormatter� issubclassr���� MemoryHandler�appendZ setTarget)r���r����hlistr���Zfixups�hand�section�klass�fmtr9���r;����hr<���r=����tr���r���r���r���|���sB���� r���c�����������������C���sT���t�j}|�D�]D}|jj|�}||krHt|t�j�sN|�t�j��g�|_d|_ q ||_ q dS�)a��� When (re)configuring logging, handle loggers which were in the previous configuration but are not in the new configuration. There's no point deleting them as other threads may continue to hold references to them; and by disabling them, you stop them doing any logging. However, don't disable children of named loggers, as that's probably not what was intended by the user. Also, allow existing loggers to NOT be disabled if disable_existing is false. TN)r ����root�manager� loggerDictr���ZPlaceHolderrA���ZNOTSETr���� propagate�disabled)�existing� child_loggers�disable_existingrM����log�loggerr���r���r����_handle_existing_loggers����s����rW���c�����������������C���s��|�d�d�}|��d�}tt|��}|�d��|�d�}tj}|}d|krX|d�}|�|��|jdd��D�]}|�|��qf|d�} t | �r�| ��d�} t| �} | D�]} |� || ���q�t|jj� ���}|����g�}|D��](}|�d |��}|d �} |jddd �}t�| �}| |k�rv|�| �d�}| d�}t |�}t |�}||k��rl||�d|��|k�r`|�||���|d7�}�q2|�| ��d|k�r�|d�}|�|��|jdd��D�]}|�|���q�||_d|_|d�} t | �r�| ��d�} t| �} | D�]} |� || ����q�q�t|||��dS�)zCreate and install loggers�loggersr(���r)���rM���Zlogger_rootr<���Nr���z logger_%s�qualnamerP�������)r,���r���r���)r����listr'����remover ���rM���rA���r���� removeHandlerr1���� addHandlerrN���rO���r(����sortZgetint� getLogger�indexrE���rP���rQ���rW���)r���r���rT���ZllistrH���rM���rU���r<���rK���rF���rG���rR���rS���ZqnrP���rV����i�prefixed�pflen�num_existingr���r���r���r�������sd���� r���c�������������������C���s.���t�j����t��t�jdd����t�jdd�=�dS�)z!Clear and close existing handlersN)r ���� _handlers�clearZshutdownZ_handlerListr���r���r���r���r �����s���� r ���z^[a-z_][a-z0-9_]*$c�����������������C���s���t��|��}|std|����dS�)Nz!Not a valid Python identifier: %rT)� IDENTIFIER�match� ValueError)�s�mr���r���r����valid_ident��s���� rm���c�������������������@���s"���e�Zd�ZdZddd�Zdd��ZdS�) �ConvertingMixinz?For ConvertingXXX's, this mixin class provides common functionsTc�����������������C���sB���|�j��|�}||k r>|r ||�|<�t|�tttfkr>|�|_||_|S�r#���)�configurator�convert�type�ConvertingDict�ConvertingList�ConvertingTuple�parent�key)�selfrv����value�replace�resultr���r���r����convert_with_key"��s���� �z ConvertingMixin.convert_with_keyc�����������������C���s0���|�j��|�}||k r,t|�tttfkr,|�|_|S�r#���)ro���rp���rq���rr���rs���rt���ru���)rw���rx���rz���r���r���r���rp���.��s���� �zConvertingMixin.convertN)T)�__name__� __module__�__qualname__�__doc__r{���rp���r���r���r���r���rn�����s��� rn���c�������������������@���s,���e�Zd�ZdZdd��Zd dd�Zd dd�ZdS�)rr���z A converting dictionary wrapper.c�����������������C���s���t��|�|�}|��||�S�r#���)�dict�__getitem__r{����rw���rv���rx���r���r���r���r����C��s����zConvertingDict.__getitem__Nc�����������������C���s���t��|�||�}|��||�S�r#���)r����r2���r{����rw���rv����defaultrx���r���r���r���r2���G��s����zConvertingDict.getc�����������������C���s���t��|�||�}|�j||dd�S��NF)ry���)r����r���r{���r����r���r���r���r���K��s����zConvertingDict.pop)N)N)r|���r}���r~���r���r����r2���r���r���r���r���r���rr���@��s��� rr���c�������������������@���s"���e�Zd�ZdZdd��Zddd�ZdS�) rs���zA converting list wrapper.c�����������������C���s���t��|�|�}|��||�S�r#���)r[���r����r{���r����r���r���r���r����Q��s����zConvertingList.__getitem__���c�����������������C���s���t��|�|�}|��|�S�r#���)r[���r���rp���)rw����idxrx���r���r���r���r���U��s����zConvertingList.popN)r����)r|���r}���r~���r���r����r���r���r���r���r���rs���O��s���rs���c�������������������@���s���e�Zd�ZdZdd��ZdS�)rt���zA converting tuple wrapper.c�����������������C���s���t��|�|�}|�j||dd�S�r����)�tupler����r{���r����r���r���r���r����[��s����zConvertingTuple.__getitem__N)r|���r}���r~���r���r����r���r���r���r���rt���Y��s���rt���c�������������������@���s����e�Zd�ZdZe�d�Ze�d�Ze�d�Ze�d�Z e�d�Z ddd �Zee �Zd d��Zdd ��Zdd��Zdd��Zdd��Zdd��Zdd��ZdS�)�BaseConfiguratorzI The configurator base class which defines some useful defaults. z%^(?P<prefix>[a-z]+)://(?P<suffix>.*)$z^\s*(\w+)\s*z^\.\s*(\w+)\s*z^\[\s*(\w+)\s*\]\s*z^\d+$�ext_convert�cfg_convert)ZextZcfgc�����������������C���s���t�|�|�_|�|�j_d�S�r#���)rr����configro���)rw���r����r���r���r����__init__t��s���� zBaseConfigurator.__init__c����������� ��� ���C���s����|��d�}|�d�}z^|��|�}|D�]H}|d|�7�}zt||�}W�q$�tk rj���|��|��t||�}Y�q$X�q$|W�S��tk r����t���dd��\}}td||f��}||�|_ |_ |�Y�nX�dS�)z` Resolve strings to objects using standard import and attribute syntax. r���r���rZ���NzCannot resolve %r: %s)r���r����importerr���r����ImportError�sys�exc_inforj���� __cause__� __traceback__) rw���rk���r���r���r ���Zfrag�e�tb�vr���r���r����resolvex��s"���� zBaseConfigurator.resolvec�����������������C���s ���|���|�S�)z*Default converter for the ext:// protocol.)r�����rw���rx���r���r���r���r�������s����zBaseConfigurator.ext_convertc�����������������C���s����|}|�j��|�}|dkr&td|���n�||���d��}|�j|���d��}|r�|�j�|�}|rn||���d��}nd|�j�|�}|r�|���d�}|�j�|�s�||�}n2zt |�}||�}W�n�t k r����||�}Y�nX�|r�||���d��}qHtd||f���qH|S�)z*Default converter for the cfg:// protocol.NzUnable to convert %rr���zUnable to convert %r at %r)�WORD_PATTERNri���rj����endr�����groups�DOT_PATTERN� INDEX_PATTERN� DIGIT_PATTERN�int� TypeError)rw���rx����restrl����dr����r!���r���r���r���r�������s4���� �zBaseConfigurator.cfg_convertc�����������������C���s����t�|t�s$t�|t�r$t|�}|�|_n�t�|t�sHt�|t�rHt|�}|�|_n�t�|t�svt�|t�rvt|d�svt|�}|�|_nVt�|t �r�|�j �|�}|r�|���}|d�}|�j �|d�}|r�|d�}t|�|�}||�}|S�)z� Convert values to an appropriate type. dicts, lists and tuples are replaced by their converting alternatives. Strings are checked to see if they have a conversion format and are converted if they do. �_fields�prefixN�suffix)r���rr���r����ro���rs���r[���rt���r����r���r%����CONVERT_PATTERNri���� groupdict�value_convertersr2���r���)rw���rx���rl���r����r����Z converterr����r���r���r���rp������s0���� �� zBaseConfigurator.convertc��������������������sj�������d�}t|�s|��|�}����dd�}��fdd���D��}|f�|�}|rf|���D�]\}}t|||��qP|S�)z1Configure an object with a user-supplied factory.r:���r���Nc��������������������s���i�|�]}t�|�r|��|��qS�r����rm�����.0�k�r����r���r���� <dictcomp>���s�������z5BaseConfigurator.configure_custom.<locals>.<dictcomp>)r����callabler�����items�setattr)rw���r����r4����propsr;���rz���r���rx���r���r����r����configure_custom���s���� z!BaseConfigurator.configure_customc�����������������C���s���t�|t�rt|�}|S�)z0Utility function which converts lists to tuples.)r���r[���r����r����r���r���r����as_tuple���s���� zBaseConfigurator.as_tupleN)r|���r}���r~���r����re�compiler����r����r����r����r����r�����staticmethodr���r����r����r����r����r����rp���r����r����r���r���r���r���r����`��s"��� �"r����c�������������������@���s^���e�Zd�ZdZdd��Zdd��Zdd��Zdd ��Zd d��Zdd ��Z ddd�Z ddd�Zddd�ZdS�)�DictConfiguratorz] Configure logging using a dictionary-like object to describe the configuration. c�����������������C���s���|�j�}d|krtd��|d�dkr2td|d����|�dd�}i�}t�����zn|�r�|�d|�}|D�]�}|tjkr�td|���qdz6tj|�}||�}|�d d �}|r�|�t� |���W�qd�t k r��} �ztd|��| �W�5�d } ~ X�Y�qdX�qd|�d|�} | D�]N}z|��|| |�d ��W�q��t k �rF�} �ztd|��| �W�5�d } ~ X�Y�q�X�q�|�dd �}|�r�z|��|d ��W�n.�t k �r��} �ztd�| �W�5�d } ~ X�Y�nX��n|�dd �}t ���|�d|�} | D�]P}z|��| |��| |<�W�n2�t k �r�} �ztd|��| �W�5�d } ~ X�Y�nX��q�|�d|�}|D�]P}z|��||��||<�W�n2�t k �rp�} �ztd|��| �W�5�d } ~ X�Y�nX��q$|�d|�}g�}t|�D�]v}z |��||��}||_|||<�W�nN�t k �r��} �z.dt| j�k�r�|�|��ntd|��| �W�5�d } ~ X�Y�nX��q�|D�]Z}z |��||��}||_|||<�W�n2�t k �r`�} �ztd|��| �W�5�d } ~ X�Y�nX��q tj}t|jj����}|����g�}|�d|�} | D�]�}||k�r|�|�d�}|d�}t|�}t|�}||k��r||�d |��|k�r�|�||���|d7�}�q�|�|��z|��|| |���W�n2�t k �rV�} �ztd|��| �W�5�d } ~ X�Y�nX��q�t|||��|�dd �}|�r�z|��|��W�n.�t k �r��} �ztd�| �W�5�d } ~ X�Y�nX�W�5�t����X�d S�)zDo the configuration.�versionz$dictionary doesn't specify a versionrZ���zUnsupported version: %s�incrementalFr���zNo handler found with name %rr<���NzUnable to configure handler %rrX���TzUnable to configure logger %rrM���zUnable to configure root loggerr���r���z Unable to configure formatter %r�filterszUnable to configure filter %r�target not configured yetr���) r����rj���r���r ���r���r���r2���rf���rA����_checkLevel� Exception�configure_logger�configure_rootr ����configure_formatter�configure_filter�sorted�configure_handlerr���r%���r����rE���rM���r[���rN���rO���r(���r_���ra���r1���r\���rW���)rw���r����r����Z EMPTY_DICTr���r����handlerZhandler_configr<���r����rX���rM���rT���r���r����ZdeferredrR���rS���rb���rc���rd���re���r���r���r���� configure���s��� � �������������� ����zDictConfigurator.configurec����������� ��� ���C���s����d|krr|d�}z|���|�}W�q��tk rn�}�z2dt|�kr>��|�d�|d<�||d<�|���|�}W�5�d}~X�Y�q�X�nl|�dd�}|�dd�}|�dd�}|�d d�}|s�tj} nt|�} d |kr�| ||||d ��}n| |||�}|S�)z(Configure a formatter from a dictionary.r:���z'format'r*���rJ���Nr-���r.���r/���r0���Zvalidate)r����r����r%���r���r2���r ���r3���r"���) rw���r�����factoryrz����terJ���Zdfmtr.����cnamer4���r���r���r���r�������s*����z$DictConfigurator.configure_formatterc�����������������C���s.���d|kr|���|�}n|�dd�}t�|�}|S�)z%Configure a filter from a dictionary.r:���r���r8���)r����r2���r ���ZFilter)rw���r����rz���r���r���r���r���r�������s ���� z!DictConfigurator.configure_filterc�����������������C���sX���|D�]N}z|��|�jd�|���W�q�tk rP�}�ztd|��|�W�5�d}~X�Y�qX�qdS�)z/Add filters to a filterer from a list of names.r����zUnable to add filter %rN)Z addFilterr����r����rj���)rw���Zfiltererr����r6���r����r���r���r����add_filters���s ����zDictConfigurator.add_filtersc�������������� ������s���t����}���dd�}|r\z|�jd�|�}W�n0�tk rZ�}�ztd|��|�W�5�d}~X�Y�nX����dd�}���dd�}d��kr����d�}t|�s�|��|�}|}�n���d�} |��| �} t| tj j ��rFd ��k�rFz>|�jd ���d ��}t|tj��s��� |��td��|��d <�W�n6�tk �rB�}�ztd��d ���|�W�5�d}~X�Y�nX�nZt| tj j��rtd ��k�rt|����d ����d <�n,t| tj j��r�d��k�r�|����d����d<�| }���dd�}��fdd���D��} z|f�| �}W�nL�tk �r�}�z,dt|�k�r��| �d�| d<�|f�| �}W�5�d}~X�Y�nX�|�r.|�|��|dk �rH|�t�|���|�rZ|��||��|�r�|���D�]\}}t|||���qh|S�)z&Configure a handler from a dictionary.r7���Nr���zUnable to set formatter %rr<���r����r:���r0���r=���r���r����zUnable to set target handler %rZmailhostZaddressr���c��������������������s���i�|�]}t�|�r|��|��qS�r���r����r����r����r���r���r�������s�������z6DictConfigurator.configure_handler.<locals>.<dictcomp>z'stream'�streamZstrm)r����r���r����r����rj���r����r����rC���r ���r���rD���r���ZHandler�updater����ZSMTPHandlerr����Z SysLogHandlerr%���rB���rA���r����r����r����r����)rw���r����Zconfig_copyr7���r����r<���r����r4���r����r����rI���Zthr����r;���rz���r����r���rx���r���r����r���r�������s~������ � ���� z"DictConfigurator.configure_handlerc�����������������C���sX���|D�]N}z|��|�jd�|���W�q�tk rP�}�ztd|��|�W�5�d}~X�Y�qX�qdS�)z.Add handlers to a logger from a list of names.r���zUnable to add handler %rN)r^���r����r����rj���)rw���rV���r���rK���r����r���r���r����add_handlers���s ����zDictConfigurator.add_handlersFc�����������������C���s����|��dd�}|dk r$|�t�|���|s~|jdd��D�]}|�|��q6|��dd�}|rb|��||��|��dd�}|r~|��||��dS�)zU Perform configuration which is common to root and non-root loggers. r<���Nr���r����)r2���rA���r ���r����r���r]���r����r����)rw���rV���r����r����r<���rK���r���r����r���r���r����common_logger_config��s����z%DictConfigurator.common_logger_configc�����������������C���s6���t��|�}|��|||��|�dd�}|dk r2||_dS�)z.Configure a non-root logger from a dictionary.rP���N)r ���r`���r����r2���rP���)rw���r���r����r����rV���rP���r���r���r���r������s ���� z!DictConfigurator.configure_loggerc�����������������C���s���t����}|��|||��dS�)z*Configure a root logger from a dictionary.N)r ���r`���r����)rw���r����r����rM���r���r���r���r������s����zDictConfigurator.configure_rootN)F)F)F) r|���r}���r~���r���r����r����r����r����r����r����r����r����r����r���r���r���r���r�������s����$ ? r����c�����������������C���s���t�|������dS�)z%Configure logging using a dictionary.N)�dictConfigClassr����r����r���r���r���� dictConfig&��s����r����c��������������������sD���G�dd��dt��}G�dd��dt�}G���fdd�dtj�����|||�|�S�)au�� Start up a socket server on the specified port, and listen for new configurations. These will be sent as a file suitable for processing by fileConfig(). Returns a Thread object on which you can call start() to start the server, and which you can join() when appropriate. To stop the server, call stopListening(). Use the ``verify`` argument to verify any bytes received across the wire from a client. If specified, it should be a callable which receives a single argument - the bytes of configuration data received across the network - and it should return either ``None``, to indicate that the passed in bytes could not be verified and should be discarded, or a byte string which is then passed to the configuration machinery as normal. Note that you can return transformed bytes, e.g. by decrypting the bytes passed in. c�������������������@���s���e�Zd�ZdZdd��ZdS�)z#listen.<locals>.ConfigStreamHandlerz� Handler for a logging configuration request. It expects a completely new logging configuration and uses fileConfig to install it. c�����������������S���sD���z |�j�}|�d�}t|�dk�r t�d|�d�}|�j��|�}t|�|k�rb||�|t|����}q>|�jjdk rz|�j�|�}|dk r�|�d�}zddl}|� |�}t |��W�nH�tk r����t� |�}zt|��W�n�tk r����t����Y�nX�Y�nX�|�jj�r |�jj����W�n2�tk �r>�}�z|jtk�r.��W�5�d}~X�Y�nX�dS�)z� Handle a request. Each request is expected to be a 4-byte length, packed using struct.pack(">L", n), followed by the config file. Uses fileConfig() to do the grunt work. ����z>Lr���Nzutf-8)Z connectionZrecvr1����structZunpack�server�verify�decode�json�loadsr����r�����io�StringIOr���� traceback� print_exc�ready�set�OSError�errno�RESET_ERROR)rw���Zconn�chunkZslenr����r�����filer����r���r���r����handleF��s6���� z*listen.<locals>.ConfigStreamHandler.handleN)r|���r}���r~���r���r����r���r���r���r����ConfigStreamHandler?��s���r����c�������������������@���s0���e�Zd�ZdZdZdedddfdd�Zdd��ZdS�) z$listen.<locals>.ConfigSocketReceiverzD A simple TCP socket-based logging config receiver. rZ���Z localhostNc�����������������S���s>���t��|�||f|��t����d|�_t����d|�_||�_||�_d�S�)Nr���rZ���) r���r����r ���r����abortr����timeoutr����r����)rw���Zhost�portr����r����r����r���r���r���r����t��s����z-listen.<locals>.ConfigSocketReceiver.__init__c�����������������S���s`���dd�l�}d}|sT|��|�j���gg�g�|�j�\}}}|r<|�����t����|�j}t����q|�� ���d�S�)Nr���) �selectZsocket�filenor����Zhandle_requestr ���r���r����r���Zserver_close)rw���r����r����ZrdZwrZexr���r���r����serve_until_stopped~��s������ z8listen.<locals>.ConfigSocketReceiver.serve_until_stopped)r|���r}���r~���r���Zallow_reuse_address�DEFAULT_LOGGING_CONFIG_PORTr����r����r���r���r���r����ConfigSocketReceiverm��s������ r����c�����������������������s&���e�Zd�Z���fdd�Zdd��Z���ZS�)zlisten.<locals>.Serverc��������������������s4���t���|������||�_||�_||�_||�_t���|�_d�S�r#���) �superr�����rcvr�hdlrr����r����� threadingZEventr����)rw���r����r����r����r����)�Server� __class__r���r���r�������s����zlisten.<locals>.Server.__init__c�����������������S���sZ���|�j�|�j|�j|�j|�jd�}|�jdkr0|jd�|�_|�j����t����|a t� ���|����d�S�)N)r����r����r����r����r���rZ���)r����r����r����r����r����Zserver_addressr����r ���r���� _listenerr���r����)rw���r����r���r���r����run���s����� zlisten.<locals>.Server.run)r|���r}���r~���r����r����� __classcell__r����r����)r����r���r�������s���r����)r���r���r����ZThread)r����r����r����r����r���r����r����listen+��s����.r����c�������������������C���s*���t�����ztrdt_daW�5�t�����X�dS�)zN Stop the listening server which was created with a call to listen(). rZ���N)r ���r���r���r����r����r���r���r���r���� stopListening���s����r����)NT)+r���r����r����r ���Zlogging.handlersr����r����r����r����r����Zsocketserverr���r���r����Z ECONNRESETr����r����r���r"���r'���r ���r���rW���r���r ���r�����Irh���rm����objectrn���r����rr���r[���rs���r����rt���r����r����r����r����r����r����r���r���r���r����<module>���sH��� "%W! ���Az