
    !f                     f    d Z ddlZddlZddlZddlZ G d dej                  j                        Zy)z Debian crash database interface.    Nc                   *    e Zd ZdZd Zd ZddZd Zy)CrashDatabaseziDebian crash database.

    This is a Apport CrashDB implementation for interacting with Debian BTS.
    c                    t         j                  j                  j                  | ||       || _        | j                  j                  d      sd| j                  d<   | j                  j                  d      sd| j                  d<   yy)zInitialize crash database connection.

        Debian implementation is pretty basic as most of its bug management
        processes revolve around the email interface
        smtphostzreportbug.debian.org	recipientzsubmit@bugs.debian.orgN)apportcrashdbr   __init__optionsget)self	auth_filer   s      </usr/lib/python3/dist-packages/apport/crashdb_impl/debian.pyr
   zCrashDatabase.__init__   sl     	$$--dIwG||
+'=DLL$||,(@DLL% -    c                     | j                   j                  d      s	d|vrd|d<   d|v r|j                         sd|d<   t        j                  j
                  j                  | |      S )zqCheck if this report can be uploaded to this database.
        Checks for the proper settings of apport.
        senderUnreportableReasonz<Please configure sender settings in /etc/apport/crashdb.conf
Stacktracez>Incomplete backtrace. Please install the debug symbol packages)r   r   has_useful_stacktracer   r	   r   accepts)r   reports     r   r   zCrashDatabase.accepts+   sn     ||).B&.PN '(
 6!&*F*F*HP '( ~~++33D&AAr   Nc                    | j                  |      sJ 	 |d   j                  d      \  }}t	        j
                         5 }|j                  j                  d| dj                  d             |j                  j                  d| dj                  d             |j                  j                  d	j                  d             	 |d
= |j                  |       |j                  j                  d       t        j                  j                  j                  |j                  j                         j                  d            }ddd       |d   d<   | j                   d   |d<   | j                   d   |d<   |j#                  d| j                   d          |j#                  dd|d   j%                                 t'        j(                  | j                   d         }|j+                  | j                   d   | j                   d   |j-                         j                  d             |j/                          y# t        t        f$ r Y yw xY w# t        $ r Y w xY w# 1 sw Y   xY w)zUpload given problem report return a handle for it.

        In Debian, we use BTS, which is heavily email oriented. This method
        crafts the bug into an email report understood by Debian BTS.
        Package Fz	Package: 
zUTF-8z	Version: z


z=============================

CoreDumpr   NTitleSubjectr   Fromr   TozX-Debbugs-CCUsertagzapport-ProblemTyper   T)r   splitKeyError
ValueErrortempfileNamedTemporaryFilefilewriteencodeseekemailmimetextMIMETextreaddecoder   
add_headerlowersmtplibSMTPsendmail	as_stringquit)	r   r   progress_callbackuser_message_callbackbuggy_packagebuggy_versiontempmsgsmtps	            r   uploadzCrashDatabase.upload<   s    ||F###	-3I->-D-DS-I*]M ((* 	MdIIOOib9@@IJIIOOif=DDWMNIIOO@HHQR:&
 LLIINN1**//**499>>+;+B+B7+KLC+	M.  Ill8,FLL-D	 	~t||H'=>yGF=,A,G,G,I+J"KL||DLL45LL"LL%MMO""7+	

 			S *% 		   	M 	MsC   H=  BI"IA<I"=II	II"II""I,c                      y)a8  Return an URL that should be opened after report has been uploaded
        and upload() returned handle.

        Should return None if no URL should be opened (anonymous filing without
        user comments); in that case this function should do whichever
        interactive steps it wants to perform.
        N )r   r   handles      r   get_comment_urlzCrashDatabase.get_comment_urlt   s     r   )NN)__name__
__module____qualname____doc__r
   r   r@   rD   rB   r   r   r   r      s    AB"6pr   r   )	rH   email.mime.textr,   r4   r&   apport.crashdbr   r	   r   rB   r   r   <module>rK      s.    &    iFNN00 ir   