§
    cÌc£%  ã                   ó’   — d Z ddlmZ ddlZddlZddlZddlZddlZddlZddl	m
Z
mZmZmZmZ d„ Zd„ Zd„ Zd	„ Zd
„ Zd„ Zd„ Zd„ ZdS )a  Handling and reporting crashes.

A crash is an exception propagated up almost to the top level of Breezy.

If we have apport <https://launchpad.net/apport/>, we store a report of the
crash using apport into its /var/crash spool directory, from where the user
can either manually send it to Launchpad.  In some cases (at least Ubuntu
development releases), Apport may pop up a window asking if they want
to send it.

Without apport, we just write a crash report to stderr and the user can report
this manually if the wish.

We never send crash data across the network without user opt-in.

In principle apport can run on any platform though as of Feb 2010 there seem
to be some portability bugs.

To force this off in brz turn set APPORT_DISABLE in the environment or
-Dno_apport.
é    )ÚStringIONé   )ÚbeddingÚdebugÚosutilsÚpluginÚtracec                 óš  — dt           j        v s t          j                             dd ¦  «        rt          | |¦  «        S 	 t          | |¦  «        rd S nj# t          $ r!}t          j	        d|z  ¦  «         Y d }~nDd }~wt          $ r4}t          j	        d|z  ¦  «         t          j        ¦   «          Y d }~nd }~ww xY wt          | |¦  «        S )NÚ	no_apportÚAPPORT_DISABLEz.couldn't find apport bug-reporting library: %sz,brz: failed to report crash using apport: %r)r   Údebug_flagsÚosÚenvironÚgetÚreport_bug_legacyÚreport_bug_to_apportÚImportErrorr	   ÚmutterÚ	ExceptionÚlog_exception_quietly)Úexc_infoÚstderrÚes      ú./usr/lib/python3/dist-packages/breezy/crash.pyÚ
report_bugr   >   s  € Ø•uÔ(Ð(Ð(ÝŒJ�NŠNÐ+¨TÑ2Ô2ð 	)å  ¨6Ñ2Ô2Ð2ð
&Ý ¨&Ñ1Ô1ð 	àˆFð	øõ ð Kð Kð KÝŒÐEÈÑIÑJÔJÐJÐJÐJÐJÐJÐJøøøøÝð &ð &ð &õ 	ŒÐCÀaÑGÑHÔHÐHÝÔ#Ñ%Ô%Ð%Ð%Ð%Ð%Ð%Ð%øøøøð	&øøøõ
 ˜X vÑ.Ô.Ð.s$   Á A Á
B:ÁA9Á9B:Â*B5Â5B:c           
      ó–  ‡‡— t          j        | ‰¦  «         ‰                     d¦  «         ddlŠˆˆfd„} |dt          j        ›dt	          j        t          j        ¦  «        ›dt          j	        d¬	¦  «        ›d
�¦  «          |dt          j
        z  ¦  «          |‰                     dt          j        ¦   «         z   dd¬¦  «        dz   ¦  «          |d                     t          j        ¦   «         t          j        ¦   «         t$          j                             d¦  «        ¦  «        ¦  «         ‰                     d¦  «         dS )z4Report a bug by just printing a message to the user.ú
r   Nc                 ód   •— ‰                      ‰                     | dd¬¦  «        dz   ¦  «         d S )NéN   ú    ©ÚwidthÚsubsequent_indentr   )ÚwriteÚfill)ÚlÚerr_fileÚtextwraps    €€r   Úprint_wrappedz(report_bug_legacy.<locals>.print_wrappedV   sG   ø€ Ø�Š�x—}’}Ø�R¨6ð %ñ 3ô 3Ø59ñ:ñ 	;ô 	;ð 	;ð 	;ð 	;ó    zbrz z on python z (r   ©Úaliasedz)
zarguments: %r
z	plugins: r   r    r!   z(encoding: {!r}, fsenc: {!r}, lang: {!r}
ÚLANGzþ
*** Breezy has encountered an internal error.  This probably indicates a
    bug in Breezy.  You can help us fix it by filing a bug report at
        https://bugs.launchpad.net/brz/+filebug
    including this traceback and a description of the problem.
)r	   Úprint_exceptionr$   r(   ÚbreezyÚ__version__Ú_format_version_tupleÚsysÚversion_infoÚplatformÚargvr%   r   Úformat_concise_plugin_listÚformatr   Úget_user_encodingÚgetfilesystemencodingr   r   r   )r   r'   r)   r(   s    ` @r   r   r   P   s„  øø€ å	Ô˜( HÑ-Ô-Ð-Ø‡N‚N�4ÑÔÐØ€O€O€Oð;ð ;ð ;ð ;ð ;ð ;ð €M€MÝÔ%Ð%Ð%ÝÔ/µÔ0@ÑAÔAÐAÐAÝÔ$¨QÐ/Ñ/Ô/Ð/Ð/ð1ñ 2ô 2ð 2ð €MÐ#¥c¤hÑ.Ñ/Ô/Ð/Ø€M�(—-’-Ø•fÔ7Ñ9Ô9Ñ9ØØ ð  ñ 
ô 
ð ñ	ñ ô ð ð
 €MØ3×:Ò:ÝÔ%Ñ'Ô'­Ô)BÑ)DÔ)DÝŒJ�NŠN˜6Ñ"Ô"ñ	$ô 	$ñ%ô %ð %ð
 ‡N‚Nð	Kñ
ô 
ð 
ð 
ð 
r*   c                 ó¶   — ddl }t          | ¦  «        }|€|                     d¦  «         n-t          j        | |¦  «         |                     d|z  ¦  «         |S )z…Report a bug to apport for optional automatic filing.

    :returns: The name of the crash file, or None if we didn't write one.
    r   Nz9
apport is set to ignore crashes in this version of brz.
zŠ
You can report this problem to Breezy's developers by running
    apport-bug %s
if a bug-reporting window does not automatically appear.
)ÚapportÚ_write_apport_report_to_filer$   r	   r.   )r   r   r;   Úcrash_filenames       r   r   r   q   s„   € ð €M€M€Må1°(Ñ;Ô;€NàÐØ�Šð Qñ 	ô 	ð 	ð 	õ 	Ô˜h¨Ñ/Ô/Ð/Ø�Šð Rð 'ñ	(ñ 	)ô 	)ð 	)ð Ðr*   c                 ó  — dd l }ddlm} | \  }}} |¦   «         }|                     ¦   «          |d= |                     ¦   «          d|d<   d|d<   t          j        t          j        ¦  «        |d<   t          j
        |d<   t          j        t          j        ¦  «        |d	<   t          j        d
¬¦  «        |d<   t          j        ¦   «         |d<   t          j        ¦   «         |d<   t"          j                             dd¦  «        |d<   t)          ¦   «         |d<   t+          ¦   «         |d<   t          j        t,          j        ¦  «        |d<   d|d<   d|d<   d|d<   t1          ¦   «         }|                     ||||¬¦  «         |                     ¦   «         |d<   t7          |¦  «         |                     ¦   «          |                     ¦   «         rd S t=          ¦   «         \  }}	|                     |	¦  «         |	                      ¦   «          |S )Nr   )ÚReportÚProcMapsÚbrzÚSourcePackageÚPackageÚCommandLineÚ
BrzVersionÚPythonVersionr   r+   ÚPlatformÚUserEncodingÚFileSystemEncodingr-   ÚCÚLocaleÚ
BrzPluginsÚPythonLoadedModulesÚBrzDebugFlagsÚCrashDb)ÚfileÚ	Traceback)!Ú	tracebackÚapport.reportr?   Úadd_proc_infoÚadd_user_infoÚpprintÚpformatr2   r5   r/   r0   r1   r3   r4   r   r8   r9   r   r   r   Ú_format_plugin_listÚ_format_module_listr   r   r   r.   ÚgetvalueÚ_attach_log_tailÚ	anonymizeÚcheck_ignoredÚ_open_crash_filer$   Úclose)
r   rR   r?   Úexc_typeÚ
exc_objectÚexc_tbÚprÚtb_fileÚcrash_file_nameÚ
crash_files
             r   r<   r<   ’   s  € ØÐÐÐØ$Ð$Ð$Ð$Ð$Ð$à#+Ñ €Hˆj˜&à	ˆ‰Œ€Bà×ÒÑÔÐð 	ˆ:ˆØ×ÒÑÔÐð
  €B€ÑØ€B€y�Måœ¥s¤xÑ0Ô0€B€}ÑÝÔ)€B€|ÑÝ Ô6µsÔ7GÑHÔH€B€ÑÝÔ&¨qÐ1Ñ1Ô1€B€z�NÝ Ô2Ñ4Ô4€B€~ÑÝ"Ô8Ñ:Ô:€BÐÑÝ”:—>’> &¨#Ñ.Ô.€B€x�LÝ*Ñ,Ô,€B€|ÑÝ 3Ñ 5Ô 5€BÐÑÝ œ.­Ô):Ñ;Ô;€B€Ñð
  €B€ÑØ€B€y�Mð €B€y�Må‰jŒj€GØ×Ò˜h¨
°FÀÐÑIÔIÐIØ×&Ò&Ñ(Ô(€B€{�Oå�RÑÔÐð$ ‡L‚L�N„N€Nà	×ÒÑÔð àˆtå&6Ñ&8Ô&8Ñ#ˆ˜Ø
�Š�ÑÔÐØ×ÒÑÔÐØÐr*   c                 ób  — 	 t          t          j        ¦   «         ¦  «        }n*# t          $ r}t	          |¦  «        | d<   Y d }~d S d }~ww xY w	 |                     ¦   «         }d                     |dd …         ¦  «        | d<   |                     ¦   «          d S # |                     ¦   «          w xY w)NÚ
BrzLogTailÚ iØÿÿÿ)Úopenr	   Ú_get_brz_log_filenameÚOSErrorÚreprÚ	readlinesÚjoinr_   )rc   Úbrz_logr   Úliness       r   r[   r[   à   s²   € ðÝ•uÔ2Ñ4Ô4Ñ5Ô5ˆˆøÝð ð ð Ý ™7œ7ˆˆ<ÑØˆˆˆˆˆøøøøðøøøðØ×!Ò!Ñ#Ô#ˆØŸ7š7 5¨¨¨¤;Ñ/Ô/ˆˆ<Ñà�Š‰Œˆˆˆøˆ�Š‰Œˆˆøøøs    ‚ # £
A
­AÁA
Á4B ÂB.c                  ó
  — t          j        ¦   «         } t          j        | ¦  «        st	          j        | d¬¦  «         t          j        dt          j        ¦   «         ¦  «        }t          j
        dk    rd}ndt	          j        ¦   «         z  }t          j        | d                     ||¦  «        ¦  «        }|t	          j        t	          j        |t          j        t          j        z  t          j        z  d¦  «        d¦  «        fS )	Ni€  )Úmodez%Y-%m-%dT%H:%MÚwin32ri   z.%dzbrz{}.{}.crashÚwb)r   Ú	crash_dirr   Úisdirr   ÚmakedirsÚtimeÚstrftimeÚgmtimer2   r4   ÚgetuidÚpathjoinr7   Úfdopenrj   ÚO_WRONLYÚO_CREATÚO_EXCL)rv   Údate_stringÚ	user_partÚfilenames       r   r^   r^   í   sì   € ÝÔ!Ñ#Ô#€IÝŒ=˜Ñ#Ô#ð +õ 	Œ�I EÐ*Ñ*Ô*Ð*Ý”-Ð 0µ$´+±-´-Ñ@Ô@€Kå
„|�wÒÐØˆ	ˆ	à�BœI™KœKÑ'ˆ	ÝÔØØ×ÒØØñ	ô 	ñô €Hð •R”YÝ
Œ�Ý”�bœjÑ(­2¬9Ñ4Øñ	ô 	ð 	ñ	ô ð ð r*   c                  óR   — d                      t          j        d¬¦  «        ¦  «        S )Nri   T)Ú
show_paths)ro   r   Údescribe_plugins© r*   r   rX   rX     s"   € Ø�7Š7•6Ô*°dÐ;Ñ;Ô;Ñ<Ô<Ð<r*   c                  ó>   — t          j        t          j        ¦  «        S )N)rV   rW   r2   Úmodulesrˆ   r*   r   rY   rY     s   € ÝŒ>�#œ+Ñ&Ô&Ð&r*   )Ú__doc__Úior   r   r4   rV   r2   ry   r/   ri   r   r   r   r   r	   r   r   r   r<   r[   r^   rX   rY   rˆ   r*   r   ú<module>r�      s'  ðð"ð ð8 Ð Ð Ð Ð Ð Ø 	€	€	€	Ø €€€Ø €€€Ø 
€
€
€
Ø €€€à €€€ðð ð ð ð ð ð ð ð ð ð ð ð ð ð/ð /ð /ð$
ð 
ð 
ðBð ð ðBKð Kð Kð\
ð 
ð 
ðð ð ð6=ð =ð =ð'ð 'ð 'ð 'ð 'r*   