File: //lib/python3/dist-packages/apport/__pycache__/report.cpython-38.pyc
U
��8dL � @ s� d Z ddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlZddlmZ e
jdkr�dZddlmZ ddlmZ ddlmZ eef n d ZddlmZ ddlmZ eZddl Z ddl!Z!ddl"Z!dd
l#m$Z% ddl&m'Z' ej(�)dd
�Z*de* Z+de* Z,dZ-dZ.dZ/dZ0dddddddddddgZ1dd � Z2d5d!d"�Z3d6d#d$�Z4d%d&� Z5d7d'd(�Z6d)d*� Z7d+d,� Z8d-d.� Z9d/d0� Z:d1d2� Z;G d3d4� d4e j<�Z=dS )8z;Representation of and data collection for a problem report.� N)�
ExpatError�3F)�URLError)�urlopen)�unquoteT)�impl)�kill_pkttyagentZAPPORT_DATA_DIRz/usr/share/apportz%s/package-hooks/z%s/general-hooks/z/optz~/.apport-ignore.xmlz/etc/apport/blacklist.dz/etc/apport/whitelist.dZshZbashZdashZcshZtcshzpython*zruby*Zphpzperl*zmono*Zawkc C sV zt �| � W n tk
r$ Y dS X t �| �D ] }||kr0|�|� t||� q0dS )z7Recursively add dependencies of package to depends_set.N)� packaging�get_version�
ValueErrorZget_dependencies�add�_transitive_dependencies)�packageZdepends_set�d� r �//usr/lib/python3/dist-packages/apport/report.pyr
9 s
r
c C s, t s|dk rtj| |d�S t�d|| f �S )zrUse readlink() to resolve link.
Return a string representing the path to which the symbolic link points.
N��dir_fd�/proc/%s/%s)�_python2�os�readlink)�path�pidr r r r �_read_proc_linkF s r c
C s� znt s(|dk r(tj| tjtjB |d�}nd|| f }t�|d��&}|�� �� jddd�W 5 Q R � W S Q R X W n6 t t
fk
r� } zdt|� W Y �S d}~X Y nX dS ) zXRead file content.
Return its content, or return a textual error if it failed.
Nr r �rb�UTF-8�replace��errors�Error: )r r �open�O_RDONLY� O_CLOEXEC�io�read�strip�decode�OSError�IOError�str)r r r Z proc_file�fd�er r r �_read_proc_fileQ s .r- c
sx d}t rdS z0td� fdd�d��}|�� �� }W 5 Q R X W n6 ttfk
rr } zdt|� W Y �S d}~X Y nX |S ) z�Read /proc/pid/maps.
Since /proc/$pid/maps may become unreadable unless we are ptracing the
process, detect this, and attempt to attach/detach.
z%Error: unable to read /proc maps filezDError: python2 does not provide a secure way to read /proc maps file�mapsc s t j| |� d�S )Nr )r r! )r �mode��proc_pid_fdr r �<lambda>n � z_read_maps.<locals>.<lambda>)Zopenerr N)r r! r% r&