HEX
Server: Apache
System: Linux infong-uk86 4.4.400-icpu-106 #2 SMP Mon Sep 15 08:23:40 UTC 2025 x86_64
User: u44115835 (4976590)
PHP: 8.4.17
Disabled: NONE
Upload Files
File: //kunden/lib/python3/dist-packages/breezy/__pycache__/crash.cpython-39.pyc
a

�*�^�%�@s�dZddlmZddlZddlZddlZddlZddlZddlZddl	m
Z
mZmZm
Z
mZddlmZdd�Zd	d
�Zdd�Zd
d�Zdd�Zdd�Zdd�Zdd�ZdS)aHandling and reporting crashes.

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

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.
�)�absolute_importN�)�bedding�debug�osutils�plugin�trace)�StringIOc
Cs�dtjvstj�dd�r"t||�Szt||�r4WdSWnjtyh}zt�	d|�WYd}~nBd}~0t
y�}z"t�	d|�t��WYd}~n
d}~00t||�S)NZ	no_apportZAPPORT_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�ImportErrorrZmutter�	ExceptionZlog_exception_quietly)�exc_info�stderr�e�r�./usr/lib/python3/dist-packages/breezy/crash.py�
report_bugBs
�


"rcs�t�|����d�ddl���fdd�}|dtjt�tj�t	j	dd�f�|d	tj
�|�jd
t�
�ddd
�d�|dt��t��tj�d�f���d�dS)z4Report a bug by just printing a message to the user.�
rNcs���j|ddd�d�dS)N�N�    ��widthZsubsequent_indentr)�write�fill)�l��err_file�textwraprr�
print_wrappedZs
��z(report_bug_legacy.<locals>.print_wrappedzbrz %s on python %s (%s)
r�Zaliasedzarguments: %r
z	plugins: rrrz"encoding: %r, fsenc: %r, lang: %r
�LANGz�
*** Bazaar has encountered an internal error.  This probably indicates a
    bug in Bazaar.  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_exceptionrr"�breezy�__version__�_format_version_tuple�sys�version_info�platform�argvrrZformat_concise_plugin_listr�get_user_encoding�getfilesystemencodingrrr
)rr!r#rr rrTs6


��
��
���rcCsBddl}t|�}|dur$|�d�nt�||�|�d|�|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.
    rNz9
apport is set to ignore crashes in this version of brz.
z�
You can report this problem to Bazaar's developers by running
    apport-bug %s
if a bug-reporting window does not automatically appear.
)�apport�_write_apport_report_to_filerrr&)rrr0Zcrash_filenamerrrrus�	rc
CsPddl}ddlm}|\}}}|�}|��|d=|��d|d<d|d<t�tj�|d<t	j
|d<t	�tj�|d	<t
j
d
d�|d<t��|d
<t��|d<tj�dd�|d<t�|d<t�|d<t�tj�|d<d|d<d|d<d|d<t�}|j||||d�|��|d<t|�|��|���r,dSt�\}}	|�|	�|	� �|SdS)Nr)�ReportZProcMapsZbrzZ
SourcePackageZPackageZCommandLineZ
BrzVersionZ
PythonVersionrr$ZPlatformZUserEncodingZFileSystemEncodingr%�CZLocaleZ
BrzPluginsZPythonLoadedModulesZ
BrzDebugFlagsZCrashDb)�fileZ	Traceback)!�	tracebackZ
apport.reportr2Z
add_proc_infoZ
add_user_info�pprint�pformatr*r-r'r(r)r+r,rr.r/rrr
�_format_plugin_list�_format_module_listrr
r	r&�getvalue�_attach_log_tailZ	anonymizeZ
check_ignored�_open_crash_filer�close)
rr5r2�exc_typeZ
exc_objectZexc_tb�prZtb_fileZcrash_file_nameZ
crash_filerrrr1�sB






r1c
Cs�ztt��d�}Wn6ttfyH}zt|�|d<WYd}~dSd}~00z*|��}d�|dd��|d<W|��n
|��0dS)NZrtZ
BrzLogTail�i���)	�openrZ_get_brz_log_filename�IOError�OSError�repr�	readlines�joinr=)r?Zbrz_logr�linesrrrr;�sr;cCs�t��}t�|�s tj|dd�t�dt���}t	j
dkr@d}ndt��}t�|d||f�}|t�
t�|tjtjBtjBd�d�fS)	Ni�)�modez%Y-%m-%dT%H:%MZwin32r@z.%dzbrz%s.%s.crash�wb)r�	crash_dirr�isdirr�makedirs�time�strftime�gmtimer*r,�getuidZpathjoin�fdopenrA�O_WRONLY�O_CREAT�O_EXCL)rJZdate_stringZ	user_part�filenamerrrr<�s*

����r<cCsd�tjdd��S)Nr@T)Z
show_paths)rFrZdescribe_pluginsrrrrr8sr8cCst�tj�S)N)r6r7r*�modulesrrrrr9sr9)�__doc__Z
__future__rrr,r6r*rMr'r@rrrrrZsixishr	rrrr1r;r<r8r9rrrr�<module>s"!!N