File: //usr/lib/python3/dist-packages/apport/__pycache__/ui.cpython-38.pyc
U
��8d�& � @ sh d Z ddlZddlZddlZddlZddlZddlZddlZddl Z ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlmZ ddlmZ ejjdkr�ddlmZ e dZnddl mZ dZd Z!d
d� Z"ej#�$dd
�Z%dZ&dd� Z'ddd�Z(dd� Z)dd� Z*ddd�Z+G dd� d�Z,G dd� d�Z-dS )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.11c C s( t jjdkr t| ��t�� d�S t| �S )z$Return exception message as unicode.r �replace)�sys�version_info�major�str�decode�locale�getpreferredencoding)Z exception� r �+/usr/lib/python3/dist-packages/apport/ui.py�excstr( s r ZAPPORT_SYMPTOMS_DIRz/usr/share/apport/symptomsi c C sD z$t �d| �dd���d�}t|�W S ttfk
r> Y d S X d S )Nz
Pid: (.*)
Z
ProcStatus� � )�re�search�get�group�int�
IndexError�AttributeError)�report�pidr r r �get_pid5 s
r c C s2 zt tj| �W S ttfk
r, | Y S X dS )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.
N)r �os�environ�KeyError�
ValueError)�key�defaultr r r �_get_env_int= s r# c K sl t dt d��}|dks t� �� s:tj| fddi|�� dS dddd t|� g}tj|| fddi|�� dS )
z�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.
�SUDO_UID�
PKEXEC_UIDNZcheckF�sudo�-H�-u�#)r# r Zis_root�
subprocess�runr
)�args�kwargs�uid�sudo_prefixr r r �run_as_real_userI s r0 c
C sR zt �t| �d� W n8 tk
rL } z|jtjkr<W Y �dS W 5 d }~X Y nX dS )Nr FT)r �killr �OSError�errno�ESRCH)r �er r r �
still_runningX s r6 c
C s` z| � � W n tk
r Y nX | �� |r�i }znt|��}tt|�� |d�|� W 5 Q R X |d | |�}|s�t�d|� W dS t j
�t j
�|��d | d<