%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/apport/crashdb_impl/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/apport/crashdb_impl/__pycache__/memory.cpython-312.pyc

�

�!f{-��^�dZddlZddlZddlZGd�dej
j�Zy)zISimple in-memory CrashDatabase implementation, mainly useful for testing.�Nc��eZdZdZd�Zdd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Z			dd�Zd�Z
d
�Zd�Zd�Zd�Zd�Zd�Zd�Zdd�Zd�Zd�Zd�Zd�Zy)�
CrashDatabasez�Simple implementation of crash database interface which keeps everything
    in memory.

    This is mainly useful for testing and debugging.
    c���tjjj|||�g|_t�|_t�|_d|_d|_	d|vr|j�yy)ztInitialize crash database connection.

        This class does not support bug patterns and authentication.
        rN�sample_data)�apport�crashdbr�__init__�reports�set�
unretraced�
dup_unchecked�upload_delay�
upload_msg�add_sample_data)�self�	auth_file�optionss   �</usr/lib/python3/dist-packages/apport/crashdb_impl/memory.pyr	zCrashDatabase.__init__sd��
	���$�$�-�-�d�I�w�G�����%��� �U����������G�#�� � �"�$�Nc��|j|�sJ�|r/|jr#||jd|jd�|jj|dddd��t	|j�dz
}d|vr|j
j
|�n|jj
|�|jr5|r	|dd�tj|j�|r	|dd�|S)z�Store the report and return a handle number (starting from 0).

        This does not support (nor need) progress callbacks.
        r�N�)�report�
fixed_version�dup_of�comment�	Traceback�d)�acceptsrr
�append�lenr
�addrr�time�sleep)rr�progress_callback�user_message_callback�crash_ids     r�uploadzCrashDatabase.upload/s���
�|�|�F�#�#�#� �T�_�_�!�$�/�/�!�"4�d�o�o�a�6H�I���������QS�T�	
��t�|�|�$�q�(���&� ����"�"�8�,��O�O����)���� �!�!�S�)��J�J�t�(�(�)� �!�#�s�+��rc�*�d|vrd|d�d|��Sd|��S)z�Return http://<sourcepackage>.bugs.example.com/<handle> for package
        bugs or http://bugs.example.com/<handle> for reports without a
        SourcePackage.
        �
SourcePackagezhttp://z.bugs.example.com/zhttp://bugs.example.com/�)rr�handles   r�get_comment_urlzCrashDatabase.get_comment_urlLs3��
�f�$��V�O�4�5�5G��x�P�P�)�&��2�2rc�&�|j||�S)z�Return URL for a given report ID.

        The report is passed in case building the URL needs additional
        information from it, such as the SourcePackage name.

        Return None if URL is not available or cannot be determined.
        )r-)rrr's   r�
get_id_urlzCrashDatabase.get_id_urlUs���#�#�F�H�5�5rc�&�|j|dS)z>Download the problem report from given ID and return a Report.r�r
�rr's  r�downloadzCrashDatabase.download_s���|�|�H�%�h�/�/rc�.�|j|ddgS)z5Return list of affected source packages for given ID.rr*r1r2s  r�get_affected_packagesz#CrashDatabase.get_affected_packagescs�����X�&�x�0��A�B�Brc��y)z3Check whether the user is the reporter of given ID.Tr+r2s  r�is_reporterzCrashDatabase.is_reportergs��rc�$�|j|�S)aBCheck whether the user is eligible to update a report.

        A user should add additional information to an existing ID if (s)he is
        the reporter or subscribed, the bug is open, not a duplicate, etc. The
        exact policy and checks should be done according to  the particular
        implementation.
        )r7r2s  r�
can_updatezCrashDatabase.can_updateks������)�)rc��|j|}||d<|r|D]}||vs�|||d|<�y|dj|�y)ahUpdate the given report ID with all data from report.

        This creates a text comment with the "short" data (see
        ProblemReport.write_mime()), and creates attachments for all the
        bulk/binary data.

        If change_description is True, and the crash db implementation supports
        it, the short data will be put into the description instead (like in a
        new bug).

        comment will be added to the "short" data. If attachment_comment is
        given, it will be added to the attachment uploads.

        If key_filter is a list or set, then only those keys will be added.
        rrN)r
�update)	rr'rr�change_description�attachment_comment�
key_filter�r�fs	         rr;zCrashDatabase.updateusY��0
�L�L��"����)����
/����;�%+�A�Y�A�h�K��N�
/�
�h�K���v�&rc�,�|j|ddS)zNGet 'DistroRelease: <release>' from the given report ID and return
        it.r�
DistroReleaser1r2s  r�get_distro_releasez CrashDatabase.get_distro_release�s���|�|�H�%�h�/��@�@rc��t�}t|j�D]"\}}|d��|d��|j|��$|S)aXReturn an ID set of all crashes which are not yet fixed.

        The list must not contain bugs which were rejected or duplicate.

        This function should make sure that the returned list is correct. If
        there are any errors with connecting to the crash database, it should
        raise an exception (preferably OSError).
        rr)r�	enumerater
r")r�result�irs    r�get_unfixedzCrashDatabase.get_unfixed�sN�����"�4�<�<�0�	�I�A�v��h��'�F�?�,C�,K��
�
�1�
�	��
rc�l�	|j|d�y|j|dS#t$rYywxYw)aReturn the package version that fixes a given crash.

        Return None if the crash is not yet fixed, or an empty string if the
        crash is fixed, but it cannot be determined by which version. Return
        'invalid' if the crash report got invalidated, such as closed a
        duplicate or rejected.

        This function should make sure that the returned result is correct. If
        there are any errors with connecting to the crash database, it should
        raise an exception (preferably OSError).
        r�invalidr)r
�
IndexErrorr2s  r�get_fixed_versionzCrashDatabase.get_fixed_version�sD��	��|�|�H�%�h�/�;� ��<�<��)�/�:�:���	��	�s�'�'�	3�3c�&�|j|dS)zcReturn master ID for a duplicate bug.

        If the bug is not a duplicate, return None.
        rr1r2s  r�duplicate_ofzCrashDatabase.duplicate_of�s��
�|�|�H�%�h�/�/rc�(�||j|d<y)zlMark a crash id as duplicate of given master ID.

        If master is None, id gets un-duplicated.
        rNr1)rrr'�	master_ids    r�close_duplicatezCrashDatabase.close_duplicate�s��
,5����X��x�(rc�V�|j|d�J�d|��|j|d<y)zyMark a crash id as reintroducing an earlier crash which is
        already marked as fixed (having ID 'master').
        rNzregression, already fixed in #rr1)rr'�masters   r�mark_regressionzCrashDatabase.mark_regression�s8���|�|�F�#�O�4�@�@�@�.L�V�H�,U����X��y�)rc�Z�	|jj|�y#t$rYywxYw)z/Mark crash id as checked for being a duplicate.N)r
�remove�KeyError)rr'rs   r�_mark_dup_checkedzCrashDatabase._mark_dup_checked�s-��	����%�%�h�/���	��	�s��	*�*c�:�|jj|�y)zMark crash id as retraced.N)rrVr2s  r�
mark_retracedzCrashDatabase.mark_retraced�s�������x�(rc��y)ztMark crash id as 'failed to retrace'.

        This is a no-op since this crash DB is not interested in it.
        Nr+)rr'�invalid_msgs   r�mark_retrace_failedz!CrashDatabase.mark_retrace_failed�s�rc��|jS)z}Return an ID set of all crashes which have not been retraced yet and
        which happened on the current host architecture.)r�rs r�get_unretracedzCrashDatabase.get_unretraced�s�����rc��|jS)a,Return an ID set of all crashes which have not been checked for
        being a duplicate.

        This is mainly useful for crashes of scripting languages such as
        Python, since they do not need to be retraced. It should not return
        bugs that are covered by get_unretraced().
        )r
r_s r�get_dup_uncheckedzCrashDatabase.get_dup_unchecked�s���!�!�!rc�2�t|j�dz
S)z0Return the ID of the most recently filed report.r)r!r
r_s r�	latest_idzCrashDatabase.latest_id�s���4�<�<� �1�$�$rc���tjj�}d|d<d|d<d|d<d|d<d	|d
<d|d<|j|�tjj�}d
|d<d|d<d|d<d|d<d	|d
<d|d<|j|�tjj�}d|d<d|d<d|d<d|d<d|d
<d|d<|j|�tjj�}d|d<d|d<d|d<d|d
<d|d<|j|�tjj�}d|d<d|d<d|d<d|d
<d|d<|j|�y)zWAdd some sample crash reports.

        This is mostly useful for test suites.
        z
libfoo1 1.2-3�Package�foor*z
FooLinux Pi/2rB�11�Signalz
/bin/crash�ExecutablePathz�foo_bar (x=1) at crash.c:28
d01 (x=1) at crash.c:29
raise () from /lib/libpthread.so.0
<signal handler called>
__frob (x=1) at crash.c:30�
StacktraceTopz
libfoo1 1.2-4z
Testux 1.0z�foo_bar (x=2) at crash.c:28
d01 (x=3) at crash.c:29
raise () from /lib/libpthread.so.0
<signal handler called>
__frob (x=4) at crash.c:30zbar 42-4�barz/usr/bin/brokenzuh (p=0x0) at crash.c:25
g (x=1, y=42) at crash.c:26
f (x=1) at crash.c:27
e (x=1) at crash.c:28
d (x=1) at crash.c:29zpython-goo 3epsilon1�pygooz
Testux 2.2z/usr/bin/pygooz�Traceback (most recent call last):
  File "test.py", line 7, in <module>
    print(_f(5))
  File "test.py", line 5, in _f
    return g_foo00(x+1)
  File "test.py", line 2, in g_foo00
    return x/0
ZeroDivisionError: integer division or modulo by zerorzpython-goo 5N)rr�Reportr()rr?s  rrzCrashDatabase.add_sample_data�s���
�M�M� � �"��&��)��"��/��,��/����(��*��
��
�	
��	
�	
���A��
�M�M� � �"��&��)��"��/��)��/����(��*��
��
�	
��	
�	
���A��
�M�M� � �"��!��)��"��/��)��/����(��/��
��
�	
��	
�	
���A��
�M�M� � �"��-��)��$��/��)��/��.��
��
9�	
��	
�	
���A��
�M�M� � �"��%��)��$��/��)��/��.��
��
9�	
��	
�	
���A�r)NN)FNN)N)�__name__�
__module__�__qualname__�__doc__r	r(r-r/r3r5r7r9r;rCrHrLrNrQrTrXrZr]r`rbrdrr+rrrrs����#�&�:3�6�0�C��*�!��� '�DA�
� �&0�5�V��)���
"�%�\rr)rrr#�apport.crashdbr�
apport.reportrrr+rr�<module>rus+��O�����F�N�N�0�0�r

Zerion Mini Shell 1.0