Spamworldpro Mini Shell
Spamworldpro


Server : Apache/2.4.52 (Ubuntu)
System : Linux webserver 6.8.0-49-generic #49~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Nov 6 17:42:15 UTC 2 x86_64
User : www-data ( 33)
PHP Version : 8.1.2-1ubuntu2.21
Disable Function : NONE
Directory :  /lib/python3/dist-packages/apport/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/apport/__pycache__/ui.cpython-310.pyc
o

�v�f�)�@s�dZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlmZddlmZejjdkrddl m Z e dZ!nddl"m Z dZ!d	Z#d
d�Z$ej%�&dd
�Z'dZ(dd�Z)	d)de*dej+e,dej+e,fdd�Z-de*de,dej+e,fdd�Z.de,de/e*e*ffdd�Z0dd�de1e*de2ddfdd �Z3d!d"�Z4		d*d#d$�Z5Gd%d&�d&�Z6Gd'd(�d(�Z7dS)+z�Abstract Apport user interface.

This encapsulates the workflow and common code for any user interface
implementation (like GTK, Qt, or CLI).
�N)�unicode_gettext)�get_process_user_and_group�)�ConfigParserFTz2.20.11cCs(tjjdkrt|��t��d�St|�S)z$Return exception message as unicode.r�replace)�sys�version_info�major�str�decode�locale�getpreferredencoding)�	exception�r�+/usr/lib/python3/dist-packages/apport/ui.py�excstr*sr�APPORT_SYMPTOMS_DIRz/usr/share/apport/symptomsi c	Cs>zt�d|�dd���d�}t|�WSttfyYdSw)Nz
Pid:	(.*)
�
ProcStatus��)�re�search�get�group�int�
IndexError�AttributeError)�report�pidrrr�get_pid7s
�r�key�default�returnc	Cs,zttj|�WSttfy|YSw)z�Get an environment variable as integer.

    Return None if it doesn't exist or failed to convert to integer.
    The optional second argument can specify an alternate default.
    )r�os�environ�KeyError�
ValueError)r r!rrr�_get_env_int?s
�r'�name�uidcCsDtjddddt|�|gdddd�}|jdks|jsdSt|j���S)	N�pgrepz-nz-x�-uTF)�capture_output�check�textr)�
subprocess�runr
�
returncode�stdoutr�strip)r(r)�processrrr�_get_newest_process_for_userMs�r5c	s�td|�}|duriSt�d|��tjtjBtjB�}z!ztj�|��Wnt	y5iYWt�
|�SwWt�
|�nt�
|�w�fdd�dD�S)z�Find D-BUS address and XDG_DATA_DIRS for the given user.

    The D-BUS address and XDG_DATA_DIRS is needed for xdg-open. It is
    incredibly hard, or alternatively, unsafe to funnel it through
    pkexec/env/sudo, so grab it from gvfsd.
    �gvfsdNz/proc/csi|]}|�vr|�|�qSrr)�.0r ��	gvfsd_envrr�
<dictcomp>ns
�z&_get_users_environ.<locals>.<dictcomp>)�DBUS_SESSION_BUS_ADDRESS�
XDG_DATA_DIRS)r5r#�open�O_RDONLY�O_PATH�O_DIRECTORY�apport�	fileutils�get_process_environ�OSError�close)r)�	gvfsd_pid�gvfsd_pid_fdrr8r�_get_users_environYs"
���
�rH��get_user_env�argsrJc
Ks�tdtd��}|dust���stj|fddi|��dSt�|�}td�}|dur-|j}dd�tj	�
�D�}|r?|t|�O}|j|d	<tj|fd|||t�
|j|�d
�|��dS)a`Call subprocess.run as real user if called via sudo/pkexec.

    If we are called through pkexec/sudo, determine the real user ID and
    run the command with it to get the user's web browser settings.
    If get_user_env is set to True, the D-BUS address and XDG_DATA_DIRS
    is grabbed from a running gvfsd and added to the process environment.
    �SUDO_UID�
PKEXEC_UIDNr-F�SUDO_GIDcSs(i|]\}}|�d�s|dkr||�qS)�SUDO_rM)�
startswith)r7�k�vrrrr:�s��z$run_as_real_user.<locals>.<dictcomp>�HOME)r-�env�userr�extra_groups)r'r�is_rootr/r0�pwd�getpwuid�pw_gidr#r$�itemsrH�pw_dir�getgrouplist�pw_name)rKrJ�kwargsr)�pwuid�gidrTrrr�run_as_real_userus2

�
��
�rbc
CsXzt�t|�d�WdSty+}z|jtjkr WYd}~dSWYd}~dSd}~ww)NrFT)r#�killrrD�errno�ESRCH)r�errr�
still_running�s�
���rgc
Cstz|��Wn	tyYnw|��|ri}zAt|��}tt|��|d�|�Wd�n1s3wY|d||�}|sJt�d|�WdSt	j
�t	j
�|��d|d<Wn%t
ygt�d�Ynty~t�d|�t��t�d�Ynw|s�d|vr�tj�|d�}ntd	��tj�|�}|r�|�|�z|�|�Wn'ty�|s�d
|vr��Ynty�}	zt|	�|d<WYd}	~	nd}	~	wwd|v�r5|�|�r�t�d�zDd|v�r d
t	jv�r d|vr�d
|vr�td�|d<n(tj� |d�!�d��s tj�"|d�!�d��s td�|d�!�d|d<Wnt�y4|�s2d
|v�r2�Ynwd|v�rE|�#�}
|
�rE|
|d<|�$d�dk�redt	jv�re|�%�}|�retd�d�&|�|d<|�r�z%t|d��}t	�'|d�|j(|dd�Wd�n	1�s�wYWnt)�y�}	zt�d||	f�WYd}	~	nd}	~	wwtj�*|�t	�'|d�dSdS)ayCollect information about report.

    Encapsulate calls to add_*_info() and update given report, so that this
    function is suitable for threading.

    ui must be a HookUI instance, it gets passed to add_hooks_info().

    If reportfile is not None, the file is written back with the new data.

    If symptom_script is given, it will be run first (for run_symptom()).
    �execNr0z8symptom script %s did not determine the affected packager�Symptomzsymptom script %s crashed:�ExecutablePathzAcalled without a package, and report does not have ExecutablePath�Snap�UnreportableReason�CrashDB�APPORT_DISABLE_DISTRO_CHECK�Packagez4This package does not seem to be installed correctlyz�This does not seem to be an official %s package. Please retry after updating the indexes of available packages, if that does not work then remove related third party packages and try again.�
DistroRelease�Title�ProblemType�Crash�APPORT_IGNORE_OBSOLETE_PACKAGESz�You have some obsolete package versions installed. Please upgrade the following packages and check if the problem still occurs:

%sz, �abT)�only_newzCannot update %s: %si�)+�add_gdb_inforD�add_os_infor=rh�compile�readrA�errorr#�path�splitext�basename�
StopIterationr�exit�	Exception�	traceback�	print_excrB�find_file_packager%�	find_snap�
add_snap_info�add_package_infor&�SystemErrorr�add_hooks_infor$�_�	packaging�is_distro_package�split�is_native_origin_package�standard_titler�obsolete_packages�join�chmod�write�IOError�mark_report_seen)r�
reportfile�package�ui�symptom_script�ignore_uninstalled�symb�f�snaprf�title�old_pkgsrrr�thread_collect_info�s�
�
� �
���


������
	������r�c@s�eZdZdZdd�Zdd�Zd_dd�Zd	d
�Zdd�Zd
d�Z	dd�Z
d`dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Z	0	dad1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Zd;d<�Zd=d>�Z d?d@�Z!dbdAdB�Z"dCdD�Z#dEdF�Z$dGdH�Z%dIdJ�Z&dKdL�Z'dMdN�Z(dOdP�Z)dQdR�Z*dSdT�Z+dUdV�Z,dWdX�Z-dYdZ�Z.d[d\�Z/d]d^�Z0dS)c�
UserInterfaceaApport user interface API.

    This provides an abstract base class for encapsulating the workflow and
    common code for any user interface implementation (like GTK, Qt, or CLI).

    A concrete subclass must implement all the abstract ui_* methods.
    c
Cs�d|_d|_d|_d|_d|_d|_z	tj�d�|_Wn't	y5}zt�
dt|��WYd}~nd}~wtyBt�
d�Ynwt
�|j�|��dS)z8Initialize program state and parse command line options.rANFzDCould not import module, is a package upgrade in progress? Error: %sz8/etc/apport/crashdb.conf is damaged: No default database)�gettext_domainr�report_file�cur_package�
offer_restart�specified_a_pkgrA�crashdb�get_crashdb�ImportError�fatalr
r%�gettext�
textdomain�
parse_argv)�selfrfrrr�__init__'s ��zUserInterface.__init__cCsd}d|_t��dkrtj��}d}n(tj��}ts#tj�	t�
��}nt�dt�
�tjtj
BtjB�}tjj	|d�}|D]A}|�|�sEq=|rjd|jvrjd|jvrj|j��sWq=|d|jdksi|d	|j��krjq=|jd
dkrw|�|�n|�|�d}q=|S)a�Present all currently pending crash reports.

        Ask the user what to do about them, and offer to file bugs for them.

        Crashes that occurred in a different desktop (logind) session than the
        one that is currently running are not processed. This skips crashes
        that happened during logout, which are uninteresting and confusing to
        see at the next login.

        Return True if at least one crash report was processed, False
        otherwise.
        FTrN�/proc/%s)�proc_pid_fd�_LogindSession�Daterrr�Hang)r�r#�geteuidrArB�get_new_system_reports�get_new_reports�PY3�Report�get_logind_session�getpidr=r>r?r@�load_reportr�
get_timestamp�finish_hang�	run_crash)r��result�reports�logind_sessionr�r�rrr�run_crashes@s2


"



zUserInterface.run_crashesTc
Cs�||_z�ztj�|�Wn	tyYnw|js!|�|�s!WdSd|jvr)WdS|j�d�dkrfd|jvrfd|jvrfd|jvrftj	�
|j�dtd	���}td
�|}|�td�|d|td
�f�WdStj�
�}|�|�}|dsx|dr�d|jvr�|��|jdur�WdS|dr�|��WdS|dr�|��|dr�|j��z
|dr�|�|d�Wn	ty�Ynw|ds�WdSd|jvr�|jddkr�tj�|�|j�|j�r�|��r�WdS|��r�WdS|��WdSWdSt�yT}zT|jtjtjfv�r|�td�td��t� d�n,|jtj!k�r-|�td�td��t� d�n|�td�|j"�t� d�WYd}~dSWYd}~dSWYd}~dSd}~wt�yu}z|jtj#k�rit�$d�n�WYd}~dSd}~ww)z�Present and report a particular crash.

        If confirm is True, ask the user what to do about it, and offer to file
        a bug for it.

        If confirm is False, the user will not be asked, and the crash is
        reported right away.
        N�Ignorerrrs�Signal�CoreDump�
Stacktracerjzunknown programz+Sorry, the program "%s" closed unexpectedly�
Problem in %s�%s

%szxYour computer does not have enough free memory to automatically analyze the problem and send a report to the developers.r�examine�Dependencies�restart�	blacklist�remember�_MarkForUpload�False�Invalid problem reportz2You are not allowed to access this problem report.r�Errorz@There is not enough disk space available to process this report.zOut of memory, aborting)%r�rArBr�rDrr�rr#r|r~r��ui_error_message�allowed_to_report�ui_present_report_details�collect_infor�r��mark_ignore�remember_send_reportr%�mark_report_uploadr��accepts�handle_duplicate�check_unreportable�file_reportr�rd�EPERM�EACCESrr��ENOSPC�strerror�ENOMEMr�)r�r��confirm�subject�headingr��responserfrrrr�vs�	�
.
�




��
�
�
������zUserInterface.run_crashcCstj�|�tj�|�dS)z�Finish processing a hanging application after the core pipe handler
        has handed the report back.

        This will signal to whoopsie that the report needs to be uploaded.
        N)rArBr�r�)r�r�rrrr��szUserInterface.finish_hangc
Cs`t�d�|_|jjs|�td�td��dSz|j�|�Wn=ty[}z1t	|�dkr<|�td�td��t
�d�nt	|�d	krQ|�td
�td��t
�d�WYd}~nd}~ww|j��|j�
d
d�}tj�|�|_|j��tj��}|j||d�}|dr�tj�|j|�t�t|�tj�n	t�t|�tj�|dr�|�|�|��dSdS)a�Report an application hanging.

        This will first present a dialog containing the information it can
        collect from the running application (everything but the trace) with
        the option of terminating or restarting the application, optionally
        reporting that this error occurred.

        A SIGABRT will then be sent to the process and a series of
        noninteractive processes will collect the remaining information and
        mark the report for uploading.
        r�zNo PID specifiedz;You need to specify a PID. See --help for more information.Fzinvalid process�Invalid PIDz(The specified process ID does not exist.rznot accessiblezNot your PIDz0The specified process ID does not belong to you.Nrjr)�	modal_forrr�)rAr�r�optionsrr�r��
add_proc_infor&r
rr�r�rrBr�r�rxr�r��mark_hanging_processr#rcr�signal�SIGABRT�SIGKILL�wait_for_pidr�)r�rrfr|r�r�rrr�run_hang�sJ
�
�
�
��
	

�
�zUserInterface.run_hangc
CsX	z
t�t|�d�Wnty%}z|jtjkr WYd}~dS�d}~wwt�d�q)z�waitpid() does not work for non-child processes. Query the process
        state in a loop, waiting for "no such process."
        TrNr)r#rcrrDrdre�time�sleep)r�rrfrrrr�s��
�zUserInterface.wait_for_pidcCst�t|�tj�dS�N)r#rcrr��SIGSEGV)r�rrrr�	kill_segv"szUserInterface.kill_segvNc
Cs�|jjs|jjs|s|��rdS|�td�td��dSt�d�|_|jjr�z[d}t	rFt
�d|jjt
jt
j
Bt
jB�}t
jdt
j|d	�}nd
|jj}t�|��}|����}Wd�n1sbwYt|d�}|t@rvd|j_n
|jj|jj|d
�WnNtttfy�}z:t|d�r�|jtjkr�WYd}~dS|jtjkr�|�td�td��WYd}~dS|�td�td��WYd}~dSd}~ww|j��|jjr�|jj��|j_|jjdkr�tj��|_ n|jj|_ z|�!|�WnAt�y6}z4dt"|�v�r1dt"|�v�r1|j �s|�td�td�|�n
|�td�td�|j �WYd}~dS�d}~ww|�#��r>dS|�$�|�%��rIdSz|jd=Wn
t&�yYYnw|jj'�r�zWt
j(�)|jj'�}|�*d��r�t+�|d��}|j�,|�Wd�n	1�s�wYn%tt
j(�)|jj'�d��}|j�,|�Wd�n1�s�wYWdSWdSWdSttf�y�}z|�td�t-|��WYd}~dSd}~wwd}	|�.|	�}
|
d�r�|�/�dS)a@Report a bug.

        If a pid is given on the command line, the report will contain runtime
        debug information. Either a package or a pid must be specified; if none
        is given, show a list of symptoms.

        If a symptom script is given, this will be run first (used by
        run_symptom()).
        TzNo package specifiedzHYou need to specify a package or a PID. See --help for more information.F�BugNr��stat)�dir_fdz
/proc/%s/stat��linux)rr�rdzPermission deniedzfThe specified process does not belong to you. Please run this program as the process owner or as root.r�z6The specified process ID does not belong to a program.r�zdoes not existr�z7Symptom script %s did not determine an affected packagezPackage %s does not exist�ProcCmdlinez.gz�wb�Cannot create reportr)0r�r�r�run_symptomsr�r�rAr�rr�r#r=r>r?r@�iorzr�r�
PF_KTHREADr�r&r�rD�hasattrrd�ENOENTr��add_proc_environr3r��get_kernel_packager�r�r
r��add_extra_tagsr�r%�saver|�
expanduser�endswith�gzipr�rr�r�)r�r�r��	stat_filer�r��flagsrf�savefiler�r�rrr�run_report_bug%s�
�
�"�
�

�
���



�
���

�
�� ������

zUserInterface.run_report_bugcCs�|j�|jj�s|�td�td��dS|j�|jj�}|s)|�td��}|s)dSt�	d�|_
|jjr;|jj��g}n|j�
|jj�}d}|D]@}||_||j
d<||j
d<ztj�|�Wn ty~tj�tj�tj
jd|��s|td	|�YqGYnw|jd
d�d
}qG|s�|�td�td��dS|j
��|j
��|��|j
d
=z|j
d=Wn	ty�Ynwt|j
�dkr�|�td�td��dSd
}|�|�}|dr�|jj |jj|j
d|dd�d
SdS)z:Update an existing bug with locally collected information.zUpdating problem reportz�You are not the reporter or subscriber of this problem report, or the report is a duplicate or already closed.

Please create a new report using "apport-bug".FaHYou are not the reporter of this problem report. It is much easier to mark a bug as a duplicate of another than to move your comments and attachments to a new bug.

Subsequently, we recommend that you file a new bug report using "apport-bug" and make a comment in this bug about the one you file.

Do you really want to proceed?r��
SourcePackagerozsource_%s.pyz8Package %s not installed and no hook available, ignoringT)r�z$No additional information collected.r�rrzapport information)�change_description�attachment_comment)!r��
can_updater��
update_reportr�r��is_reporter�ui_question_yesnorAr�rr�r3�get_affected_packagesr�r��get_versionr&r#r|�existsr��	_hook_dir�printr��ui_info_message�
add_user_inforrr%�lenr��update)r�r�r�pkgs�info_collected�pr�r�rrr�run_update_report�sv
��

��
�

�
�
�zUserInterface.run_update_reportc		Cs�t�tj�td��}g}g}|D]h}tj�|��d�rqi}z!t|��}tt	|�
�|d�|�Wd�n1s9wYWntyRt�
d|�t��Yqwd|vr^t�
d|�q|�tj�tj�|��d�|�|�d	|d
��q|s}dSttt||���\}}t|�}t|�}|�d�|�d�|�td
�|d�}|dur�||d}|r�|�tj�t|d��dSdSdS)zlReport a bug from a list of available symptoms.

        Return False if no symptoms are available.
        z*.pyr�rhNzsymptom script %s is invalidr0z0symptom script %s does not define run() functionr�description���Fz
Other problemz+What kind of problem do you want to report?�.pyT)�globr#r|r��symptom_script_dirr~rPr=rhryrzr�rAr{r�r��appendr}r�zip�sorted�list�ui_question_choicer�r
)	r��scripts�
symptom_names�symptom_descriptions�scriptr�r��ch�symptomrrrr��sP
����


��zUserInterface.run_symptomscCsPtj�t|jjd�}tj�|�s!|�td�td�|jj�dS|�	|�dS)z#Report a bug with a symptom script.r%zUnknown symptomzThe symptom "%s" is not known.N)
r#r|r�r'r�r2rr�r�r
)r�r0rrr�run_symptoms
�zUserInterface.run_symptomc
Cs�|jjr
|��dS|jjr|�|jj�dS|jjr|��S|jjdur)|�	�S|jj
r3tt�dS|jj
r`z|�|jj
d�WdSty_}z|�td�t|��WYd}~dSd}~ww|jjr�t�d�dkrw|�td�td��dS|�d	td
��tjddgtjtjd
�}|��\}}|jdkr�zt|��d�|j_W|��Sty�|�td�td��YdSw|�td�td�d|�dS|��S)z�Call appopriate run_* method according to command line arguments.

        Return True if at least one report has been processed, and False
        otherwise.
        TNFr��XDG_SESSION_TYPE�waylandr�a<The window option cannot be used on Wayland.

Please find the window's process ID and then run 'ubuntu-bug <process ID>'.

The process ID can be found by running the System Monitor application. In the Processes tab, scroll until you find the correct application. The process ID is the number listed in the ID column.rz^After closing this message please click on an application window to report a problem about it.�xprop�_NET_WM_PID�r2�stderrrr$z2xprop failed to determine process ID of the window�

) r�r2r3�hangingr�r�filebugr
rr"�versionr�__version__�
crash_filer�rDr�r�r�windowr#�getenvrr/�Popen�PIPE�communicater1rr�r&r�)r�rfr6�out�errrrr�run_argv!s`���
�

�
�
��
�zUserInterface.run_argvcCs�t�td��}|jddtd�d�|jddgtd�d	�|��\|_|_t|j�d
ks2|jd��s<|�	d�t
�d
�t|jd�|j_
d
|j_d|j_d
|j_d
|j_d|j_g|_d
S)zgParse command line options when being invoked in update mode.

        Return (options, args).
        z%prog <report number>�-p�	--packagezSpecify package name.��help�--tagr(�@Add an extra tag to the report. Can be specified multiple times.��actionr!rKrrz-You need to specify a report number to updateNF)�optparse�OptionParserr��
add_option�
parse_argsr�rKr�isdigitr{rr�rrr2r<r?r=r;)r��	optparserrrr�parse_argv_update`s$�
�


zUserInterface.parse_argv_updatecCs,ttj�dkr9dtjvr$tj�tj�tjd�tj�tjd��tjd<tjd}|�	d�s3|�	d�r9|�
�dSt�t
d��}|jddd	d
dt
d�d
�|jddd	dt
d�d�|jddddt
d�d�|jdddt
d�d�|jddt
d�d �|jd!d"dt
d#�d$�|jd%d	dt
d&�d�|jd'd(d)t
d*�tjjd�|jd+d)t
d,�d�|jd-d.gt
d/�d�|jd0d1d	t
d2�d3�ttj�dkr�|�	d4�r�d5D]	}tj|�|�_q�|��\|_|_|jj�r|jjs�|jjs�|jjs�|jjs�|jjs�|jj�r|�d6�ttj�dk�rdSttj�d7k�r |�	d4��r d8|j_dSt|j�d7k�r*dStj� tj�t!|jdd9���rKd8|j_|jd|j_g|_dS|jd�	d:��s]|jd�	d;��ri|jd|j_g|_dS|jd�"��r�d8|j_|jd|j_g|_dSd<|jdv�r|jd�#d=��r�tj�$|jd�%d<�d>�}|�s�|�d?|jd�n'|�&d@dA��r�|�dB|jd|dC|d@f�n|�dD|jd|dCf�t�'d7�ntj(�)|jd�}|�s�|�dE|jd�t�'d7�g|_d8|j_||j_*dSd8|j_d8|_+|jd|j_*g|_dS)Fz�Parse command line options.

        If a single argument is given without any options, this tries to "do
        what I mean".
        r�APPORT_INVOKED_ASz-update-bugz-collectNzF%prog [options] [symptom|pid|package|program path|.apport/.crash file]�-fz
--file-bug�
store_truer<Fz�Start in bug filing mode. Requires --package and an optional --pid, or just a --pid. If neither is given, display a list of known symptoms. (Implied if a single argument is given.))rO�destr!rKz-wz--windowz7Click a window as a target for filing a problem report.rNr+z--update-bugrrz;Start in bug updating mode. Can take an optional --package.)�typerZrK�-sz	--symptom�SYMPTOMzWFile a bug report about a symptom. (Implied if symptom name is given as only argument.))�metavarrKrHrIz�Specify package name in --file-bug mode. This is optional if a --pid is specified. (Implied if package name is given as only argument.)rJ�-Pz--pidz�Specify a running program in --file-bug mode. If this is specified, the bug report will contain more information.  (Implied if pid is given as only argument.))r[rKz	--hangingz*The provided pid is a hanging application.�-cz--crash-file�PATHz�Report the crash from given .apport or .crash file instead of the pending ones in %s. (Implied if file is given as only argument.)z--savez�In bug filing mode, save the collected information into a file instead of reporting it. This file can then be reported later on from a different machine.rLr(rMz-vz	--versionz Print the Apport version number.)rOrKz-bug)rXr+r\rHr_r`zL-u/--update-bug option cannot be used together with options for a new reportrTr%z.crashz.apport�/z	/snap/binr$zx%s is provided by a snap. No contact address has been provided; visit the forum at https://forum.snapcraft.io/ for help.�contactr�G%s is provided by a snap published by %s. Contact them via %s for help.�	developer��%s is provided by a snap published by %s. No contact address has been provided; visit the forum at https://forum.snapcraft.io/ for help.z %s does not belong to a package.),rr�argvr#r$r|r��dirnamer~rrVrPrQr�rRrArB�
report_dir�
SUPPRESS_HELP�
get_optionrKrSr�rKrr<r@r2rr?rr{rr'rTrPr�r�rr�r��get_file_packager�r�)r��cmdrU�or��pkgrrrr�xs�

�

���
��
�
�
��
�
�
���
"
$

$

zUserInterface.parse_argvcCsP|dkrt�d|d�dS|dkrt�d|d�dSt�d|td��dS)	zCFormat the given integer as humanly readable and i18n'ed file size.i@Bz%.1fg@�@z KBiʚ;g��.Az MBz GB)r�format�float)r��sizerrr�format_filesize�s
zUserInterface.format_filesizec	Csdd}|jD]*}|j|r/z|t|j|j�dd7}Wqty.|t|j|�7}Yqwq|S)z'Return the size of the complete report.rr���rr�	gzipvaluer�r�rrrQrrr�get_complete_size�s

 ��zUserInterface.get_complete_sizec	Csld}|jD].}|dkr3|j|r3z|t|j|j�dd7}Wqty2|t|j|�7}Yqwq|S)z&Return the size of the reduced report.rr�r�rtrurwrrr�get_reduced_sizes

 ��zUserInterface.get_reduced_sizecCsr|jrd|jvr
dSztjddgtjtjd�dkrWdSWn
ty'YdSwz|�d�WSty8YdSw)z�Check whether to offer the "Examine locally" button.

        This will be true if the report has a core dump, apport-retrace is
        installed and a terminal is available (see ui_run_terminal()).
        r�F�whichzapport-retracer8rN)rr/�callrC�STDOUTrD�ui_run_terminal�NotImplementedError�r�rrr�can_examine_locallys&
�����z!UserInterface.can_examine_locallyc
CsTd|jvsJ�t��dkr(t��t�ddd|j�d|jd��t�d�dSdS)zReopen the crashed application.r�r�shr`�RespawnCommandrN)rr#�fork�setsid�execlprrr�rrrrr�(s �zUserInterface.restartcCs�|�td�td�td�td�|jgd�}|durdSdtj�d�}d	}d
|j�d
d�d
}|d||d||d
|d|d�}|�||d�dS)zLocally examine crash report.zJThis will launch apport-retrace in a terminal window to examine the crash.zRun gdb sessionz1Run gdb session without downloading debug symbolsz)Update %s with fully symbolic stack traceFNz"apport-retrace -S system -C %s -v z~/.cache/apport/retracezapport-retrace �'z'\''z--gdb z	--output � )rrrr)r,r�r�r#r|rrr})r�r��retrace_with_download�retrace_no_download�filearg�cmdsrrrr�2s(��	�

�zUserInterface.examinecCs�|rd}nd}zt�ddddddd	d
d|g
�t�gd��WdSttjfyF}z|�td
�dtd�t|�f�WYd}~dSd}~ww)z"Put whoopsie in auto or never mode�true�false�/usr/bin/gdbusr{�-y�-d�com.ubuntu.WhoopsiePreferences�-o�/com/ubuntu/WhoopsiePreferences�-mz/com.ubuntu.WhoopsiePreferences.SetReportCrashes)
r�r{r�r�r�r�r�r�z<com.ubuntu.WhoopsiePreferences.SetAutomaticallyReportCrashesr�z*Can't remember send report status settingsr�zLSaving crash reporting state failed. Can't set auto or never reporting mode.N)r/�check_outputrD�CalledProcessErrorr�r�r)r��send_reportrfrrrr�Ns"
����z"UserInterface.remember_send_reportc
Csd|jvrdS|jd���d�rjzt�|jd�}t|t�s!J�d|vs'J�WntyG}zd|jd|f|jd<WYd}~dSd}~wwztj	�
d|�|_	WdSttfyid	|jd|jd<YdSwztj	�
d|jd�|_	WdSttfy�d	|jd|jd<YdSw)
z*Process reports' CrashDB field, if presentrmT�{�implzBA package hook defines an invalid crash database definition:
%s
%srlNFzYA package hook wants to send this report to the crash database "%s" which does not exist.)r�lstriprP�ast�literal_eval�
isinstance�dictr�rAr��load_crashdbr�r%r�)r��specrfrrr�check_report_crashdbbs4
���
���z"UserInterface.check_report_crashdbFc
Csd|jd<|j�d�dkrd|jvs|j�d�dkr&d|jvr&|r$|�dS|j�d�dkr{|j�dd	�}tj�|�sVtd
�}|rJd||jdf}||jd<|rT|�dSd
|jvr{tj�|jd
�s{td
�}d||jd
f|jd<|ry|�dSd|jvr�d|jvr�t|jd�}|jd=tt�|jd�j�}||kr�d|jd<td�|jd|jd<dS|j	s�d|jvr�|s�|j�
��n?|��|j�
|j�r�t|�}nd}d|jv�r�tj��}	tjjtd|j|j|j	|||fd�}
|
��|
���r|��|�rz|��Wnt�yt�d�Ynw|
��s�|
��tj��tj�|	�z|
��Wnot t!t"j#f�yZ}zdtd�t$|�f|jd<d|jd<WYd}~nKd}~wt%�yud|jv�rstd�|jd<d|jd<Yn,t&�y�}zt�#t$|��td�dt'|�|jd<d|jd<WYd}~nd}~wwd|jv�rd|jv�rd|jdv�r�dg}n|�(td�td�|jdtd�|jdgd �}|dgk�r�|jd=d!|jv�r�|jd!=d"|jv�r�|jd"=n*|dgk�r|jd=d#|jv�r|jd#=d$|jv�r|jd$=n|�)�t�d�dSd|jv�rCd$|jv�rC|j�d%d	�}
|
�r5|
d&7}
|
|jd$|jd%<|jd$=d|jv�r�d#|jv�r�d|jv�r�|j*�r�tj+�,|j	�}|�d'd	��rztd(�|d)|d*|d'f|jd<ntd+�|d)|d*f|jd<d|jd<d|jv�s�|�-��s�|�)�|�r�|�dS|j�d�d,k�s�|j�d�d-k�s�d|jv�r+tjj|jj.|j�/�fd.�}|��|���r�|��z|�d/�Wnt�y�t�d�Ynw|���s�z|��Wn$t t!t"j#f�y}zdtd�t$|�f|jd<WYd}~nd}~ww|�0��r+|�0�|jd0<|j�d�d1k�r�tjj|jj1|jfd.�}|��|���ri|��z|�d/�Wnt�yct�d�Ynw|���sI|��|�0�}|du�r�|d2u�r�d3|jd0<n||jd0<tjj|jj2d4�}|��|���r�|��z|�d/�Wnt�y�t�d�Ynw|���s�|��|�)�d|jv�rd"|jv�r�d|jv�s�|j�dd	��3d5��sd|jv�rd#|jv�rd|jv�r|�4td6�td7��|�5�t�d�|�r
|�dSdS)8aHCollect additional information.

        Call all the add_*_info() methods and display a progress dialog during
        this.

        In particular, this adds OS, package and gdb information and checks bug
        patterns.

        If a symptom script is given, this will be run first (used by
        run_symptom()).
        �Truer�rrrsr�r�NrjrzIThis problem report applies to a program which is not installed any more.z%s (%s)rl�InterpreterPath�ExecutableTimestampr�zPThe problem happened with the program %s which changed since the crash occurred.r�)�targetr(rKrr��7This problem report is damaged and cannot be processed.z5This report is about a package that is not installed.zBAn error occurred while attempting to process this problem report:r:rkroz(not installed)rzcYou have two versions of this application installed, which one do you want to report a bug against?z%s snapz%s deb packageF�PackageArchitecturer�
SnapSource�SnapTags�Tagsr�rcrdr(rerf�KernelCrash�
KernelOops�r�rK皙�����?�_KnownReportr�T�1)r��Kernelr�z7Could not determine the package or source package name.)6rrr#r|rr�rr��st_mtimer�rx�!ui_start_info_collection_progressr�r��HookUIr$�copyrA�REThreadr�r��start�is_alive�!ui_pulse_info_collection_progress�
process_event�KeyboardInterruptrr�r��clearr�	exc_raiser��EOFError�zlibr{�reprr&r�r
r,� ui_stop_info_collection_progressr�rBr�r��search_bug_patterns�get_bugpattern_baseurl�return_value�known�	anonymizerPr��ui_shutdown)r�r�r��on_finished�exe_path�msg�	orig_time�cur_time�hookui�orig_env�icthreadrf�res�current_tagsr��bpthread�known_thread�val�anonymize_threadrrrr��s�

4


���

��
��
��
��
���
����
,&
0
�
�
����
�
�
�



�
��$
�

�zUserInterface.collect_infoc

Cs<t��\}}t��dkrKt�|�t��\}}|r8td�}td|�}t�|���}|r2|d|7}|�||�zt�|�WdSt	yJYdSwt�
�t�|�z#z
td|gdd�Wnt	yutj
|ddd	�t�d�YnwWnty�}	zt�|t|	��t�d
�WYd}	~	nd}	~	wwt�d�dS)zjOpen the given URL in a new browser window.

        Display an error dialog if everything fails.
        rzUnable to start web browserz'Unable to start web browser to open %s.�
Nzxdg-openTrI)�new�	autoraiser)r#�piper�rE�waitr��fdopen�readliner�rDr�rb�
webbrowserr=rr�r�r�r
�_exit)
r��urlr�wr�statusr�r{�messagerfrrr�open_urlgsD
��
����zUserInterface.open_urlc
Cs(|j�|j�s	dS|j�d�|j�d�kr%z|jd=Wn	ty$Ynwz|jd=Wn	ty4Ynwdadd�}t|j�D]}|�d�rK|j|=q@|��t	j
j
|jj|j|fd�}|��|�
�r�|�t�z|�d	�|��Wnzty�t�d
�Ynmt	jjy�}z3td�}|�|t|��}|dur�|\}}|j�||�t	j
j
|jj|j|fd�}|��WYd}~n1d}~wtttfy��ty�}z|�td�d
td�t|�f�WYd}~dSd}~ww|�
�se|��|��}	|��|j� |j|	�}
|
�r|�!|
�dSdS)zGUpload the current report and guide the user to the reporting web page.Nr��Architecture�StacktraceAddressSignaturecSst|�|adSr�)rq�_UserInterface__upload_progress)�sent�totalrrr�progress_callback�sz4UserInterface.file_report.<locals>.progress_callbackr�r�r�rzDPlease enter your account information for the %s bug tracking systemzNetwork problemr�zHCannot connect to crash database, please check your Internet connection.)"r�r�rrr%r�r+rP�ui_start_upload_progressrAr��uploadr�r��ui_set_upload_progressr�r�r�rr��NeedsCredentialsr��ui_question_userpassr�set_credentials�	TypeError�SyntaxErrorr&r�r�r��ui_stop_upload_progress�get_comment_urlr�)r�r�rQ�upthreadrfr��datarU�password�ticketr�rrrr��s|��
��

��
������zUserInterface.file_reportcCsXz-t��|_t|d��}|jj|dd�Wd�n1swYd|jvr,td��Wn_tyDd|_|�td�td��Yd	St	yb}zd|_|�td
�|j
�WYd}~d	Sd}~wtttt
jfy�}zd|_|�td
�dtd�t|�f�WYd}~d	Sd}~wwd
|jvr�|jd
��d|_dStj�|j�dd��|_dS)z�Load report from given path and do some consistency checks.

        This might issue an error message and return False if the report cannot
        be processed, otherwise self.report is initialized and True is
        returned.
        �rb�
compressed)�binaryNrrz+Report does not contain "ProblemType" fieldzMemory exhaustionzEYour system does not have enough memory to process this crash report.Fr�r�r�rorrjrT)rAr�rr=�loadr&�MemoryErrorr�r�r�r�r��AssertionErrorr�r{r�r�r�rBr�r)r�r|r�rfrrrr��sF
�
�
��
����
�zUserInterface.load_reportcCs�|j�|j�s	dSd|jvrFt|jd�tkr"|jd�d�|jd<d|jvr5td�|jd��d}nd}|�|td�|jd�d	SdS)
znCheck if the current report is unreportable.

        If so, display an info message and return True.
        Frl�UTF-8ror�rrz#The problem cannot be reported:

%sT)	r�r�rr[�bytesrr�r�r)r�r�rrrr��s

�z UserInterface.check_unreportablec
Csd|jvrtj�|jd�r|jd}nz	tj�|j�}Wn
ty'YdSw|s,dSt	r9t
ddd�}ddi}nt
�}i}z|j|fi|��Wn.tyw}z"dt
|j�vrrdt
|j�vrrtj�d	|t
|�f�WYd}~dS�d}~ww|�d
�sdSt|�d
��}d|vr�dS|S)z�Return a .desktop info dictionary for the current report.

        Return None if report cannot be associated to a .desktop file.
        �DesktopFileNF)�
interpolation�strict�encodingr��onfig�arserzWarning! %s is broken: %s
z
Desktop Entryr()rr#r|rrArB�find_package_desktopfiler�r&r�rrzr�r
�	__class__rr9r��has_sectionr�r[)r��desktop_file�cpr_rfr�rrr�get_desktop_entry
s:�
��
zUserInterface.get_desktop_entrycCsp|j�|j�s	dSd|jvrdS|jd�d�r,|�td�td��|�|jd�dS|�td�td��dS)z�Check if current report matches a bug pattern.

        If so, tell the user about it, open the existing bug in a browser, and
        return True.
        Fr��httpzProblem already knownz�This problem was already reported in the bug report displayed in the web browser. Please check if you can add any further information that might be helpful for the developers.z;This problem was already reported to developers. Thank you!T)r�r�rrPrr�r�rrrrr�2s

�
��zUserInterface.handle_duplicatecCsL|jsJ�|jjr$|j�dd�}|r|d7}|d�|jj�|jd<dSdS)z6Add extra tags to report specified with --tags on CLI.r�rr�N)rr��tagrr�)r��tagsrrrrLs
�zUserInterface.add_extra_tagscC�td��)aShow details of the bug report.

        Return the action and options as a dictionary:

        - Valid keys are: report the crash ('report'), restart
          the crashed application ('restart'), or blacklist further crashes
          ('blacklist').
        �.this function must be overridden by subclasses�r~)r�r�r�rrrr�Z�	z'UserInterface.ui_present_report_detailscCr)z:Show an information message box with given title and text.rr�r�r�r.rrrre�zUserInterface.ui_info_messagecCr)z4Show an error message box with given title and text.rrrrrrr�jrzUserInterface.ui_error_messagecCr)z�Open a indefinite progress bar for data collection.

        This tells the user to wait while debug information is being
        collected.
        rrrrrrr�o�z/UserInterface.ui_start_info_collection_progresscCr)zaAdvance the data collection progress bar.

        This function is called every 100 ms.
        rrrrrrr�w�z/UserInterface.ui_pulse_info_collection_progresscCr)z,Close debug data collection progress window.rrrrrrr�~rz.UserInterface.ui_stop_info_collection_progresscCr)z{Open progress bar for data upload.

        This tells the user to wait while debug information is being uploaded.
        rrrrrrr��rz&UserInterface.ui_start_upload_progresscCr)z�Update data upload progress bar.

        Set the progress bar in the debug data upload progress window to the
        given ratio (between 0 and 1, or None for indefinite progress).

        This function is called every 100 ms.
        rr)r��progressrrrr���z$UserInterface.ui_set_upload_progresscCr)z(Close debug data upload progress window.rrrrrrr��rz%UserInterface.ui_stop_upload_progresscCsdS)zdCalled right before terminating the program.

        This can be used for for cleaning up.
        Nrrrrrr��szUserInterface.ui_shutdowncCr)aRun command in, or check for a terminal window.

        If command is given, run command in a terminal window; raise an exception
        if terminal cannot be opened.

        If command is None, merely check if a terminal application is available
        and can be launched.
        rr)r��commandrrrr}�rzUserInterface.ui_run_terminalcCr)��Show a yes/no question.

        Return True if the user selected "Yes", False if selected "No" or
        "None" on cancel/dialog closing.
        rr�r�r.rrrr�rzUserInterface.ui_question_yesnocCr)�mShow an question with predefined choices.

        options is a list of strings to present. If multiple is True, they
        should be check boxes, if multiple is False they should be radio
        buttons.

        Return list of selected option indexes, or None if the user cancelled.
        If multiple == False, the list will always have one element.
        rr�r�r.r��multiplerrrr,�s
z UserInterface.ui_question_choicecCr)�mShow a file selector dialog.

        Return path if the user selected a file, or None if cancelled.
        rrrrrr�ui_question_file�rzUserInterface.ui_question_filecCr)z�Request username and password from user.

        message is the text to be presented to the user when requesting for
        username and password information.

        Return a tuple (username, password), or None if cancelled.
        rr)r�r�rrrr��rz"UserInterface.ui_question_userpass)Tr�)NFN)TN)1�__name__�
__module__�__qualname__�__doc__r�r�r�r�r�r�r�r
r"r�r3rGrVr�rsrxryr�r�r�r�r�r�r�r�r�r�rr�rr�rr�r�r�r�r�r�r�r�r}rr,r r�rrrrr�sd
6f	/
nR1?r	

�h%I%%

r�c@sJeZdZdZdd�Zdd�Zdd�Zdd	d
�Zdd�Zd
d�Z	dd�Z
dS)r�agInteractive functions which can be used in package hooks.

    This provides an interface for package hooks which need to ask interactive
    questions. Directly passing the UserInterface instance to the hooks needs
    to be avoided, since we need to call the UI methods in a different thread,
    and also don't want hooks to be able to poke in the UI.
    cCs0||_t��|_t��|_d|_d|_d|_dS)zSCreate a HookUI object.

        ui is the UserInterface instance to wrap.
        N)r��	threading�Event�_request_event�_response_event�_request_fn�
_request_args�	_response)r�r�rrrr��s


zHookUI.__init__cCs|�dd|�S)z�Show an information with OK/Cancel buttons.

        This can be used for asking the user to perform a particular action,
        such as plugging in a device which does not work.
        rr��_trigger_ui_requestrrrr�information�szHookUI.informationcC�|�d|�S)rrr,rrrr�yesno�szHookUI.yesnoFcCs|�d|||�S)rr,r,rrrr�choices
z
HookUI.choicecCr/)rr r,rrrr�fileszHookUI.filecGsf|j��rJ�|j��rJ�|jdusJ�d|_||_||_|j��|j��d|_|j��|jS)z5Called by HookUi functions in info collection thread.N)	r'�is_setr(r)r+r*�setr�r�)r��fnrKrrrr-s


zHookUI._trigger_ui_requestcCsV|j�d�|j��s
dS|j��rJ�|j��t|j|j�|j�|_	|j�
�dS)z;Called by GUI thread to check and process hook UI requests.r�N)r'r�r3r(r��getattrr�r)r*r+r4rrrrr�*s

zHookUI.process_eventN)F)r!r"r#r$r�r.r0r1r2r-r�rrrrr��s
r�r�)NF)8r$r&r�os.pathr#rPr�rr�rr�rdr�r	rXr/r%r�r�r�r��typingrA�apport.fileutils�apport.REThread�apport.crashdbrr��apport.user_grouprrr	rr��configparserr>rr$rr'rrr
�Optionalrr'r5r�rHr+�boolrbrgr�r�r�rrrr�<module>szH�	���
����
�(	
�yB

Spamworldpro Mini