%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__/github.cpython-312.pyc

�

�!f@+����dZddlZddlZddlmZddlmZddlmZddl	Z	ddl
Z
ddlZ
Gd�d�Zed�	�Gd
�d��Z
Gd�d
e
jj�Zy)z)Crash database implementation for Github.�N)�Callable)�	dataclass)�Anyc��eZdZUdZej�Zeed<d�Ze	de
defd��Zdedede
fd�Zdede
de
fd	�Zd
edede
de
fd�Zd
�Zde
ddfd�Zdefd�Zy)�Githubz:Wrapper around Github API, used to log in and post issues.�_Github__last_requestc�X�||_d|_d|_d|_d|_||_y�N)�_Github__client_id�_Github__authentication_data�_Github__access_token�_Github__cooldown�_Github__expiry�message_callback)�self�	client_idrs   �</usr/lib/python3/dist-packages/apport/crashdb_impl/github.py�__init__zGithub.__init__s0��$���%)��"�"��������
� 0����data�returnc�N�d}|j�D]\}}|�d|�d|��}�|S)z4Takes a dict and returns it as a string for POSTing.��&�=)�items)r�string�key�values    r�
_stringifyzGithub._stringify%s=�����*�*�,�	/�J�C���x�q���Q�u�g�.�F�	/��
r�urlc��ddi}|jrd|j��|d<	tj|||d��}	tj
�|_|j�tj|j�S#tj$r }|j	dd|�d	�d
z�|�d}~wwxYw#tj
�|_wxYw)zKPosts the given data to the given URL.
        Uses auth token if available�Acceptzapplication/vnd.github.v3+jsonztoken �
Authorizationg@)�headersr�timeoutzFailed connectionzFailed connection to z.
z4Please check your internet connection and try again.N)r
�requests�post�RequestExceptionr�timer�raise_for_status�json�loads�text)rr!rr%�result�errs      r�_postzGithub._post-s����=�>�����)/��0C�0C�/D�'E�G�O�$�
	.��]�]�3��d�C�P�F�#'�)�)�+�D�����!��z�z�&�+�+�&�&���(�(�	��!�!�#�'��u�C�0�H�I�
�
�I��
	��#'�)�)�+�D��s#�B�B9�B4�4B9�9B<�<Cc�D�|j||j|��S)z$Authenticate against the GitHub API.)r1r )rr!rs   r�api_authenticationzGithub.api_authenticationBs���z�z�#�t���t�4�5�5r�owner�repoc�^�d|�d|�d�}|j|tj|��S)z'Open a new issue on the GitHub project.zhttps://api.github.com/repos/�/z/issues)r1r,�dumps)rr4r5rr!s     r�api_open_issuezGithub.api_open_issueFs0��-�e�W�A�d�V�7�C���z�z�#�t�z�z�$�/�0�0rc�@�|jdd�}d}|j||�}d}|d}|d}|jd|j||���|j|d	�d
d�|_|d|_t
|d
�tj�z|_|S)z2Enters login process. At exit, login process ends.�public_repo)r�scopez$https://github.com/login/device/codez�Posting an issue requires a Github account. If you have one, please follow these steps to log in.

Open the following URL. When requested, write this code to enable apport to open an issue.
URL:  {url}
Code: {code}�verification_uri�	user_codezLogin required)r!�code�device_codez,urn:ietf:params:oauth:grant-type:device_code)rr@�
grant_type�interval�
expires_in)	rr3r�formatrr�intr*r)rrr!�response�promptr?s      r�	__enter__zGithub.__enter__Ks���!�-�-�
�F��4���*�*�3��5��
�	��)�*����$�����.��
�
�#�D�
�0Q�R��)�)�&�}�5�6�H�&
��"�
#�:�.����H�\�2�3�d�i�i�k�A��
��r�_Nc�.�d|_d|_d|_y)Nr)rrr)rrIs  r�__exit__zGithub.__exit__js��%)��"������
rc��|jstd��tj�}|j||jz
z
}||z|j
kDr|j
dd�td��|dkDrtj|�d}|j||j�}d|vr3|ddk(ry	|dd
k(rt|d�|_y	td|����d
|vr|d
|_
ytd|����)znAsks Github if the user has logged in already.
        It respects the wait-time requested by Github.
        z9Authentication not started. Use a with statement to do sozFailed loginz0Github authentication expired. Please try again.zGithub authentication expiredrz+https://github.com/login/oauth/access_token�error�authorization_pendingF�	slow_downrBzUnknown error from Github: �access_tokenTzUnknown response from Github: )r�RuntimeErrorr*rrrr�sleepr3rEr
)r�current_time�waittimer!rFs     r�authentication_completezGithub.authentication_completeos���)�)��K��
��y�y�{���?�?�l�T�5H�5H�&H�I���(�"�T�]�]�2��!�!�� R�
��>�?�?��a�<��J�J�x� �;���*�*�3��0J�0J�K���h���� �$;�;���� �K�/�"%�h�z�&:�";�����!<�X�J�G�H�H��X�%�"*�>�":�D����;�H�:�F�G�Gr)�__name__�
__module__�__qualname__�__doc__r*r�float�__annotations__r�staticmethod�dict�strr rr1r3r9rHrK�boolrU�rrrrs���D�%�D�I�I�K�N�E�'�1�����#����'��'�C�'�C�'�*6�c�6��6�#�6�1�C�1�s�1�$�1�3�1�
�>�3��4��
 H�� HrrT)�frozenc��eZdZUeed<y)�IssueHandler!N)rVrWrXr^r[r`rrrcrc�s��	�Hrrcc	��eZdZdZd�Zdejdefd�Zd�Z			ddejde
dzd	e
dzdefd
�Zdejdede
fd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zdd�Zd�Z			d d�Zy)!�
CrashDatabasezjGithub crash database.
    This is a Apport CrashDB implementation for interacting with Github issues
    c���tjjj|||�|d|_|d|_|d|_t|d�|_d|_	d|_
y)z<Initialize some variables. Login is delayed until necessary.�repository_owner�repository_name�
github_app_id�labelsN)�apport�crashdbrerrgrh�app_id�setrj�	issue_url�github)r�	auth_file�optionss   rrzCrashDatabase.__init__�se�����$�$�-�-�d�I�w�G� '�(:� ;���&�'8�9����o�.����'�(�+�,��������r�reportrc��d}|j�D]\}}|d|�d|�d�z
}�d|t|j�d�S)z>Formats report info as markdown and creates Github issue JSON.rz**z**
z

zIssue submitted via apport)�title�bodyrj)r�listrj)rrs�
body_markdownrrs     r�_format_reportzCrashDatabase._format_report�sW���
� �,�,�.�	7�J�C���r�#��d�5�'��6�6�M�	7�2�!��4�;�;�'�
�	
rc��t|j|�5}|j�s	|j�s�|cddd�S#1swYyxYwr
)rrmrU)r�user_message_callbackrps   r�
_github_loginzCrashDatabase._github_login�sH��
�D�K�K�!6�
7�	�6��4�4�6���4�4�6��	�	�	�s�"A�A�AN�progress_callbackr{c���|j|�sJ�|j|�|_|j�td��|j	|�}|j
�|j�2|jj|j|j
|�}n7d|vr(d|vr$|jj|d|d|�}ntd��t|d��S)zaUpload given problem report return a handle for it.
        In Github, we open an issue.
        zFailed to login to Github�SnapGitOwner�SnapGitNamez9Couldn't determine which repository to file the report in�html_url�r!)	�acceptsr|rprQryrhrgr9rc)rrsr}r{rrFs      r�uploadzCrashDatabase.upload�s����|�|�F�#�#�#��(�(�)>�?����;�;���:�;�;��"�"�6�*���$�$�,��1F�1F�1N��{�{�1�1��%�%�t�';�';�T��H��v�
%�-�6�*A��{�{�1�1��~�&��}�(=�t��H��K��
��x�
�3�4�4r�handlec��|jS)zpReturn a URL that should be opened after report has been uploaded
        and upload() returned handle.
        r�)rrsr�s   r�get_comment_urlzCrashDatabase.get_comment_url�s���z�z�rc��td���Nz?This method is not relevant for Github database implementation.��NotImplementedError)r�crash_idrss   r�_mark_dup_checkedzCrashDatabase._mark_dup_checked����!�M�
�	
rc��td��r�r��rr�s  r�
can_updatezCrashDatabase.can_update�r�rc��td��r�r�)rrsr��	master_ids    r�close_duplicatezCrashDatabase.close_duplicate�r�rc��td��r�r�r�s  r�downloadzCrashDatabase.download�r�rc��td��r�r�r�s  r�duplicate_ofzCrashDatabase.duplicate_of�r�rc��td��r�r�r�s  r�get_affected_packagesz#CrashDatabase.get_affected_packages�r�rc��td��r�r�r�s  r�get_distro_releasez CrashDatabase.get_distro_release�r�rc��td��r�r��rs r�get_dup_uncheckedzCrashDatabase.get_dup_uncheckedr�rc��td��r�r�r�s  r�get_fixed_versionzCrashDatabase.get_fixed_versionr�rc��td��r�r�)rrsr�s   r�
get_id_urlzCrashDatabase.get_id_urlr�rc��td��r�r�r�s r�get_unfixedzCrashDatabase.get_unfixedr�rc��td��r�r�r�s r�get_unretracedzCrashDatabase.get_unretracedr�rc��td��r�r�r�s  r�is_reporterzCrashDatabase.is_reporterr�rc��td��r�r�)rr��masters   r�mark_regressionzCrashDatabase.mark_regressionr�rc��td��r�r�)rr��invalid_msgs   r�mark_retrace_failedz!CrashDatabase.mark_retrace_failed$r�rc��td��r�r�r�s  r�
mark_retracedzCrashDatabase.mark_retraced)r�rc��td��r�r�)rr�rs�comment�change_description�attachment_comment�
key_filters       r�updatezCrashDatabase.update.s��"�M�
�	
r)NNr
)FNN) rVrWrXrYrrk�Reportr]ryr|rrcr�r^r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r`rrrere�s�����

�V�]�]�

�t�

��.2�15�	5��
�
�5�$�d�?�5� (�$��	5�

�5�@�f�m�m��[��S��
�

�

�

�

�

�

�

�

�

�

�

�

�

�

�

�!���
rre)rYr,r*�collections.abcr�dataclassesr�typingrr'rk�apport.crashdbrrcrlrer`rr�<module>r�sg��/���$�!���
��wH�wH�t�$��
�
��
�b
�F�N�N�0�0�b
r

Zerion Mini Shell 1.0