o åvŽfÒã@sHdZddlZddlZddlmZddlZddlZGdd„dejjƒZdS)z Debian crash database interface.éN)ÚMIMETextc@s2eZdZdZdd„Zdd„Zd dd„Zd d „ZdS) Ú CrashDatabasezk Debian crash database This is a Apport CrashDB implementation for interacting with Debian BTS cCsLtjj |||¡||_|j d¡sd|jd<|j d¡s$d|jd<dSdS)z¹ Initialize crash database connection. Debian implementation is pretty basic as most of its bug management processes revolve around the email interface Úsmtphostzreportbug.debian.orgÚ recipientzsubmit@bugs.debian.orgN)ÚapportÚcrashdbrÚ__init__ÚoptionsÚget)ÚselfÚ auth_filer ©r úIncomplete backtrace. Please install the debug symbol packages)r r Úhas_useful_stacktracerrrÚaccepts)r Úreportr r rr(s zCrashDatabase.acceptsNc Csf| |¡sJ‚z |d d¡\}}Wn ttfyYdSwt ¡}|j d|d d¡¡|j d|d d¡¡|j d  d¡¡z|d =Wn tyTYnw| |¡|j  d ¡t |j  ¡  d¡ƒ}|d |d <|j d|d<|j d|d<| d|j d¡| dd|d ¡¡t |j d¡}| |j d|j d| ¡ d¡¡| ¡dS)zÍUpload 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: Ú zUTF-8z Version: z z============================= ÚCoreDumprÚTitleÚSubjectrÚFromrÚToz X-Debbugs-CCÚUsertagz apport-%sÚ ProblemTyperN)rÚsplitÚKeyErrorÚ ValueErrorÚtempfileÚNamedTemporaryFileÚfileÚwriteÚencodeÚseekrÚreadÚdecoder Ú add_headerÚlowerÚsmtplibÚSMTPÚsendmailÚ as_stringÚquit)r rÚprogress_callbackÚ buggyPackageÚ buggyVersionÚtempÚmsgÚsr r rÚupload6s4ÿ  ÿ   $ zCrashDatabase.uploadcCsdS)aA 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. Nr )r rÚhandler r rÚget_comment_urlhs zCrashDatabase.get_comment_url)N)Ú__name__Ú __module__Ú __qualname__Ú__doc__rrr7r9r r r rrs   2r) r=r,r"Úemail.mime.textrrÚapport.crashdbrrr r r rÚs